~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/fetch.py

  • Committer: John Arbash Meinel
  • Date: 2010-02-17 17:11:16 UTC
  • mfrom: (4797.2.17 2.1)
  • mto: (4797.2.18 2.1)
  • mto: This revision was merged to the branch mainline in revision 5055.
  • Revision ID: john@arbash-meinel.com-20100217171116-h7t9223ystbnx5h8
merge bzr.2.1 in preparation for NEWS entry.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2005, 2006, 2008, 2009 Canonical Ltd
 
1
# Copyright (C) 2005-2010 Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
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
            # XXX: not covered by tests, should have a flag to always run
 
258
            # this. -- mbp 20100129
 
259
            graph = _get_rich_root_heads_graph(self.source, revs)
256
260
        new_roots_stream = _new_root_data_stream(
257
261
            root_id_order, rev_id_to_root_id, parent_map, self.source, graph)
258
262
        return [('texts', new_roots_stream)]
259
263
 
260
264
 
 
265
def _get_rich_root_heads_graph(source_repo, revision_ids):
 
266
    """Get a Graph object suitable for asking heads() for new rich roots."""
 
267
    st = static_tuple.StaticTuple
 
268
    revision_keys = [st(r_id).intern() for r_id in revision_ids]
 
269
    known_graph = source_repo.revisions.get_known_graph_ancestry(
 
270
                    revision_keys)
 
271
    return _mod_graph.GraphThunkIdsToKeys(known_graph)
 
272
 
 
273
 
261
274
def _new_root_data_stream(
262
275
    root_keys_to_create, rev_id_to_root_id_map, parent_map, repo, graph=None):
263
276
    """Generate a texts substream of synthesised root entries.