##// END OF EJS Templates
dagop: extract headsetofconnecteds() from dagutil...
Gregory Szorc -
r39215:1c3184d7 default
parent child Browse files
Show More
@@ -715,3 +715,26 b' def toposort(revs, parentsfunc, firstbra'
715 715 for g in groups:
716 716 for r in g[0]:
717 717 yield r
718
719 def headrevs(revs, parentsfn):
720 """Resolve the set of heads from a set of revisions.
721
722 Receives an iterable of revision numbers and a callbable that receives a
723 revision number and returns an iterable of parent revision numbers, possibly
724 including nullrev.
725
726 Returns a set of revision numbers that are DAG heads within the passed
727 subset.
728
729 ``nullrev`` is never included in the returned set, even if it is provided in
730 the input set.
731 """
732 headrevs = set(revs)
733
734 for rev in revs:
735 for prev in parentsfn(rev):
736 headrevs.discard(prev)
737
738 headrevs.discard(node.nullrev)
739
740 return headrevs
@@ -10,6 +10,10 b' from __future__ import absolute_import'
10 10
11 11 from .node import nullrev
12 12
13 from . import (
14 dagop,
15 )
16
13 17 class revlogdag(object):
14 18 '''dag interface to a revlog'''
15 19
@@ -31,21 +35,6 b' class revlogdag(object):'
31 35 return [prev2]
32 36 return []
33 37
34 def headsetofconnecteds(self, ixs):
35 if not ixs:
36 return set()
37 rlog = self._revlog
38 idx = rlog.index
39 headrevs = set(ixs)
40 for rev in ixs:
41 revdata = idx[rev]
42 for i in [5, 6]:
43 prev = revdata[i]
44 if prev != nullrev:
45 headrevs.discard(prev)
46 assert headrevs
47 return headrevs
48
49 38 def linearize(self, ixs):
50 39 '''linearize and topologically sort a list of revisions
51 40
@@ -56,7 +45,7 b' class revlogdag(object):'
56 45 parent, then adding the rev itself to the output list.
57 46 '''
58 47 sorted = []
59 visit = list(self.headsetofconnecteds(ixs))
48 visit = list(dagop.headrevs(ixs, self.parents))
60 49 visit.sort(reverse=True)
61 50 finished = set()
62 51
General Comments 0
You need to be logged in to leave comments. Login now