~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/graph.py

  • Committer: John Arbash Meinel
  • Date: 2007-12-18 19:42:10 UTC
  • mto: This revision was merged to the branch mainline in revision 3126.
  • Revision ID: john@arbash-meinel.com-20071218194210-hrciq0bscpg2ge3p
Deprecate get_parents() in favor of get_parent_map()

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
from bzrlib import (
18
18
    errors,
19
19
    revision,
 
20
    symbol_versioning,
20
21
    tsort,
21
22
    )
22
23
from bzrlib.deprecated_graph import (node_distances, select_farthest)
52
53
    def __repr__(self):
53
54
        return 'DictParentsProvider(%r)' % self.ancestry
54
55
 
 
56
    @symbol_versioning.deprecated_method(symbol_versioning.one_one)
55
57
    def get_parents(self, revisions):
56
58
        return [self.ancestry.get(r, None) for r in revisions]
57
59
 
69
71
    def __repr__(self):
70
72
        return "_StackedParentsProvider(%r)" % self._parent_providers
71
73
 
 
74
    @symbol_versioning.deprecated_method(symbol_versioning.one_one)
72
75
    def get_parents(self, revision_ids):
73
76
        """Find revision ids of the parents of a list of revisions
74
77
 
122
125
    def __repr__(self):
123
126
        return "%s(%r)" % (self.__class__.__name__, self._real_provider)
124
127
 
 
128
    @symbol_versioning.deprecated_method(symbol_versioning.one_one)
125
129
    def get_parents(self, revision_ids):
126
130
        """See _StackedParentsProvider.get_parents"""
127
131
        found = self.get_parent_map(revision_ids)
419
423
        An ancestor may sort after a descendant if the relationship is not
420
424
        visible in the supplied list of revisions.
421
425
        """
422
 
        sorter = tsort.TopoSorter(zip(revisions, self.get_parents(revisions)))
 
426
        sorter = tsort.TopoSorter(self.get_parent_map(revisions))
423
427
        return sorter.iter_topo_order()
424
428
 
425
429
    def is_ancestor(self, candidate_ancestor, candidate_descendant):
517
521
            self._search_revisions = self._start
518
522
        else:
519
523
            new_search_revisions = set()
520
 
            for parents in self._parents_provider.get_parents(
521
 
                self._search_revisions):
522
 
                if parents is None:
523
 
                    continue
 
524
            parent_map = self._parents_provider.get_parent_map(
 
525
                            self._search_revisions)
 
526
            for parents in parent_map.itervalues():
524
527
                new_search_revisions.update(p for p in parents if
525
528
                                            p not in self.seen)
526
529
            self._search_revisions = new_search_revisions