~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/fetch.py

  • Committer: IWATA Hidetaka
  • Date: 2010-12-26 13:19:11 UTC
  • mto: This revision was merged to the branch mainline in revision 5593.
  • Revision ID: iwata0303@gmail.com-20101226131911-o7txs0fnji5zekq1
add icon resources tbzrcommand(w)

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,
33
31
    tsort,
34
32
    versionedfile,
35
33
    )
37
35
import bzrlib
38
36
from bzrlib import (
39
37
    errors,
40
 
    symbol_versioning,
41
38
    ui,
42
39
    )
43
40
from bzrlib.revision import NULL_REVISION
185
182
    This is for use by fetchers and converters.
186
183
    """
187
184
 
 
185
    # This is a class variable so that the test suite can override it.
 
186
    known_graph_threshold = 100
 
187
 
188
188
    def __init__(self, source):
189
189
        """Constructor.
190
190
 
246
246
        # yet, and are unlikely to in non-rich-root environments anyway.
247
247
        root_id_order.sort(key=operator.itemgetter(0))
248
248
        # Create a record stream containing the roots to create.
249
 
        if len(revs) > 100:
250
 
            # XXX: not covered by tests, should have a flag to always run
251
 
            # this. -- mbp 20100129
252
 
            graph = _get_rich_root_heads_graph(self.source, revs)
 
249
        if len(revs) > self.known_graph_threshold:
 
250
            graph = self.source.get_known_graph_ancestry(revs)
253
251
        new_roots_stream = _new_root_data_stream(
254
252
            root_id_order, rev_id_to_root_id, parent_map, self.source, graph)
255
253
        return [('texts', new_roots_stream)]
256
254
 
257
255
 
258
 
def _get_rich_root_heads_graph(source_repo, revision_ids):
259
 
    """Get a Graph object suitable for asking heads() for new rich roots."""
260
 
    st = static_tuple.StaticTuple
261
 
    revision_keys = [st(r_id).intern() for r_id in revision_ids]
262
 
    known_graph = source_repo.revisions.get_known_graph_ancestry(
263
 
                    revision_keys)
264
 
    return _mod_graph.GraphThunkIdsToKeys(known_graph)
265
 
 
266
 
 
267
256
def _new_root_data_stream(
268
257
    root_keys_to_create, rev_id_to_root_id_map, parent_map, repo, graph=None):
269
258
    """Generate a texts substream of synthesised root entries.