diff mercurial/dagutil.py @ 39179:1c3184d7e882

dagop: extract headsetofconnecteds() from dagutil The functionality for resolving the set of DAG heads from a subset simply requires a function to resolve parent revisions. Let's establish a function in the dagop module to do this, which seems to be where generic DAG functionality goes these days. Differential Revision: https://phab.mercurial-scm.org/D4327
author Gregory Szorc <gregory.szorc@gmail.com>
date Fri, 17 Aug 2018 19:45:13 +0000
parents 4cf3f54cc8e7
children 8de526995844
line wrap: on
line diff
--- a/mercurial/dagutil.py	Fri Aug 17 19:35:24 2018 +0000
+++ b/mercurial/dagutil.py	Fri Aug 17 19:45:13 2018 +0000
@@ -10,6 +10,10 @@
 
 from .node import nullrev
 
+from . import (
+    dagop,
+)
+
 class revlogdag(object):
     '''dag interface to a revlog'''
 
@@ -31,21 +35,6 @@
             return [prev2]
         return []
 
-    def headsetofconnecteds(self, ixs):
-        if not ixs:
-            return set()
-        rlog = self._revlog
-        idx = rlog.index
-        headrevs = set(ixs)
-        for rev in ixs:
-            revdata = idx[rev]
-            for i in [5, 6]:
-                prev = revdata[i]
-                if prev != nullrev:
-                    headrevs.discard(prev)
-        assert headrevs
-        return headrevs
-
     def linearize(self, ixs):
         '''linearize and topologically sort a list of revisions
 
@@ -56,7 +45,7 @@
         parent, then adding the rev itself to the output list.
         '''
         sorted = []
-        visit = list(self.headsetofconnecteds(ixs))
+        visit = list(dagop.headrevs(ixs, self.parents))
         visit.sort(reverse=True)
         finished = set()