diff mercurial/revlog.py @ 46792:49fd21f32695

revlog: guarantee that p1 != null if a non-null parent exists This change does not affect the hashing (which already did this transformation), but can change the log output in the rare case where this behavior was observed in repositories. The change can simplify iteration code where regular changesets and merges are distinct branches. Differential Revision: https://phab.mercurial-scm.org/D10150
author Joerg Sonnenberger <joerg@bec.de>
date Wed, 10 Mar 2021 18:09:21 +0100
parents ba8e508a8e69
children 6266d19556ad
line wrap: on
line diff
--- a/mercurial/revlog.py	Wed Mar 10 05:50:20 2021 +0100
+++ b/mercurial/revlog.py	Wed Mar 10 18:09:21 2021 +0100
@@ -908,8 +908,10 @@
             if rev == wdirrev:
                 raise error.WdirUnsupported
             raise
-
-        return entry[5], entry[6]
+        if entry[5] == nullrev:
+            return entry[6], entry[5]
+        else:
+            return entry[5], entry[6]
 
     # fast parentrevs(rev) where rev isn't filtered
     _uncheckedparentrevs = parentrevs
@@ -930,7 +932,11 @@
     def parents(self, node):
         i = self.index
         d = i[self.rev(node)]
-        return i[d[5]][7], i[d[6]][7]  # map revisions to nodes inline
+        # inline node() to avoid function call overhead
+        if d[5] == nullid:
+            return i[d[6]][7], i[d[5]][7]
+        else:
+            return i[d[5]][7], i[d[6]][7]
 
     def chainlen(self, rev):
         return self._chaininfo(rev)[0]