~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/vf_repository.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2011-05-20 13:28:35 UTC
  • mfrom: (5852.1.11 fetch-limit)
  • Revision ID: pqm@pqm.ubuntu.com-20110520132835-3rf01eu5mbkz3zos
(jelmer) Add limit argument to Branch.fetch(). (Jelmer Vernooij)

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
 
20
20
from bzrlib.lazy_import import lazy_import
21
21
lazy_import(globals(), """
 
22
import itertools
 
23
 
22
24
from bzrlib import (
23
25
    check,
24
26
    debug,
2552
2554
    @needs_read_lock
2553
2555
    def search_missing_revision_ids(self,
2554
2556
            revision_id=symbol_versioning.DEPRECATED_PARAMETER,
2555
 
            find_ghosts=True, revision_ids=None, if_present_ids=None):
 
2557
            find_ghosts=True, revision_ids=None, if_present_ids=None,
 
2558
            limit=None):
2556
2559
        """Return the revision ids that source has that target does not.
2557
2560
 
2558
2561
        :param revision_id: only return revision ids included by this
2582
2585
        # stop searching at found target revisions.
2583
2586
        if not find_ghosts and (revision_ids is not None or if_present_ids is
2584
2587
                not None):
2585
 
            return self._walk_to_common_revisions(revision_ids,
 
2588
            result = self._walk_to_common_revisions(revision_ids,
2586
2589
                    if_present_ids=if_present_ids)
2587
 
        # generic, possibly worst case, slow code path.
2588
 
        target_ids = set(self.target.all_revision_ids())
2589
 
        source_ids = self._present_source_revisions_for(
2590
 
            revision_ids, if_present_ids)
2591
 
        result_set = set(source_ids).difference(target_ids)
 
2590
            if limit is None:
 
2591
                return result
 
2592
            result_set = result.get_keys()
 
2593
        else:
 
2594
            # generic, possibly worst case, slow code path.
 
2595
            target_ids = set(self.target.all_revision_ids())
 
2596
            source_ids = self._present_source_revisions_for(
 
2597
                revision_ids, if_present_ids)
 
2598
            result_set = set(source_ids).difference(target_ids)
 
2599
        if limit is not None:
 
2600
            topo_ordered = self.source.get_graph().iter_topo_order(result_set)
 
2601
            result_set = set(itertools.islice(topo_ordered, limit))
2592
2602
        return self.source.revision_ids_to_search_result(result_set)
2593
2603
 
2594
2604
    def _present_source_revisions_for(self, revision_ids, if_present_ids=None):