changeset 39180:8de526995844

dagutil: use revlog.parentrevs() for resolving parent revisions And remove parents() since it is no longer used. revlog.parentrevs() is almost the same as parents(). The main difference is that parentrevs() can return nullrev. dagop.headrevs() already handles nullrev. We add an inline check for nullrev in the other call site to account for the difference. .. api:: parents() removed from dagutil classes Use parentrevs() on the storage object instead. Differential Revision: https://phab.mercurial-scm.org/D4328
author Gregory Szorc <gregory.szorc@gmail.com>
date Fri, 17 Aug 2018 19:48:52 +0000
parents 1c3184d7e882
children 0a934ee94f09
files mercurial/dagutil.py
diffstat 1 files changed, 3 insertions(+), 18 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/dagutil.py	Fri Aug 17 19:45:13 2018 +0000
+++ b/mercurial/dagutil.py	Fri Aug 17 19:48:52 2018 +0000
@@ -20,21 +20,6 @@
     def __init__(self, revlog):
         self._revlog = revlog
 
-    def parents(self, ix):
-        rlog = self._revlog
-        idx = rlog.index
-        revdata = idx[ix]
-        prev = revdata[5]
-        if prev != nullrev:
-            prev2 = revdata[6]
-            if prev2 == nullrev:
-                return [prev]
-            return [prev, prev2]
-        prev2 = revdata[6]
-        if prev2 != nullrev:
-            return [prev2]
-        return []
-
     def linearize(self, ixs):
         '''linearize and topologically sort a list of revisions
 
@@ -45,7 +30,7 @@
         parent, then adding the rev itself to the output list.
         '''
         sorted = []
-        visit = list(dagop.headrevs(ixs, self.parents))
+        visit = list(dagop.headrevs(ixs, self._revlog.parentrevs))
         visit.sort(reverse=True)
         finished = set()
 
@@ -58,7 +43,7 @@
                     finished.add(cur)
             else:
                 visit.append(-cur - 1)
-                visit += [p for p in self.parents(cur)
-                          if p in ixs and p not in finished]
+                visit += [p for p in self._revlog.parentrevs(cur)
+                          if p != nullrev and p in ixs and p not in finished]
         assert len(sorted) == len(ixs)
         return sorted