revlog: introduce a isancestorrev() and use it in rebase
authorMartin von Zweigbergk <martinvonz@google.com>
Wed, 11 Jul 2018 16:29:23 -0700
changeset 38666 a06b2b032557
parent 38665 6afa928033bd
child 38667 572dff5c946e
revlog: introduce a isancestorrev() and use it in rebase Differential Revision: https://phab.mercurial-scm.org/D3931
hgext/rebase.py
mercurial/revlog.py
--- a/hgext/rebase.py	Wed Jul 11 16:37:30 2018 -0700
+++ b/hgext/rebase.py	Wed Jul 11 16:29:23 2018 -0700
@@ -1291,13 +1291,7 @@
     # use unfiltered changelog since successorrevs may return filtered nodes
     assert repo.filtername is None
     cl = repo.changelog
-    def isancestor(a, b):
-        # take revision numbers instead of nodes
-        if a == b:
-            return True
-        elif a > b:
-            return False
-        return cl.isancestor(cl.node(a), cl.node(b))
+    isancestor = cl.isancestorrev
 
     dest = destmap[rev]
     oldps = repo.changelog.parentrevs(rev) # old parents
--- a/mercurial/revlog.py	Wed Jul 11 16:37:30 2018 -0700
+++ b/mercurial/revlog.py	Wed Jul 11 16:29:23 2018 -0700
@@ -1679,6 +1679,12 @@
 
         A revision is considered an ancestor of itself."""
         a, b = self.rev(a), self.rev(b)
+        return self.isancestorrev(a, b)
+
+    def isancestorrev(self, a, b):
+        """return True if revision a is an ancestor of revision b
+
+        A revision is considered an ancestor of itself."""
         return self.isdescendantrev(b, a)
 
     def ancestor(self, a, b):