~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/fetch.py

  • Committer: Andrew Bennetts
  • Date: 2009-12-03 05:57:41 UTC
  • mfrom: (4857 +trunk)
  • mto: This revision was merged to the branch mainline in revision 4869.
  • Revision ID: andrew.bennetts@canonical.com-20091203055741-vmmg0fmjgjw2pwvu
MergeĀ lp:bzr.

Show diffs side-by-side

added added

removed removed

Lines of Context:
28
28
from bzrlib.lazy_import import lazy_import
29
29
lazy_import(globals(), """
30
30
from bzrlib import (
 
31
    graph as _mod_graph,
 
32
    static_tuple,
31
33
    tsort,
32
34
    versionedfile,
33
35
    )
36
38
from bzrlib import (
37
39
    errors,
38
40
    symbol_versioning,
 
41
    ui,
39
42
    )
40
43
from bzrlib.revision import NULL_REVISION
41
44
from bzrlib.trace import mutter
42
 
import bzrlib.ui
43
45
 
44
46
 
45
47
class RepoFetcher(object):
96
98
        # assert not missing
97
99
        self.count_total = 0
98
100
        self.file_ids_names = {}
99
 
        pb = bzrlib.ui.ui_factory.nested_progress_bar()
 
101
        pb = ui.ui_factory.nested_progress_bar()
100
102
        pb.show_pct = pb.show_count = False
101
103
        try:
102
104
            pb.update("Finding revisions", 0, 2)
123
125
            raise errors.IncompatibleRepositories(
124
126
                self.from_repository, self.to_repository,
125
127
                "different rich-root support")
126
 
        pb = bzrlib.ui.ui_factory.nested_progress_bar()
 
128
        pb = ui.ui_factory.nested_progress_bar()
127
129
        try:
128
130
            pb.update("Get stream source")
129
131
            source = self.from_repository._get_source(
251
253
        # yet, and are unlikely to in non-rich-root environments anyway.
252
254
        root_id_order.sort(key=operator.itemgetter(0))
253
255
        # Create a record stream containing the roots to create.
254
 
        from bzrlib.graph import FrozenHeadsCache
255
 
        graph = FrozenHeadsCache(graph)
 
256
        if len(revs) > 100:
 
257
            graph = _get_rich_root_heads_graph(self.source_repo, revs)
256
258
        new_roots_stream = _new_root_data_stream(
257
259
            root_id_order, rev_id_to_root_id, parent_map, self.source, graph)
258
260
        return [('texts', new_roots_stream)]
259
261
 
260
262
 
 
263
def _get_rich_root_heads_graph(source_repo, revision_ids):
 
264
    """Get a Graph object suitable for asking heads() for new rich roots."""
 
265
    st = static_tuple.StaticTuple
 
266
    revision_keys = [st(r_id).intern() for r_id in revision_ids]
 
267
    known_graph = source_repo.revisions.get_known_graph_ancestry(
 
268
                    revision_keys)
 
269
    return _mod_graph.GraphThunkIdsToKeys(known_graph)
 
270
 
 
271
 
261
272
def _new_root_data_stream(
262
273
    root_keys_to_create, rev_id_to_root_id_map, parent_map, repo, graph=None):
263
274
    """Generate a texts substream of synthesised root entries.