changeset 38666:a06b2b032557

revlog: introduce a isancestorrev() and use it in rebase Differential Revision: https://phab.mercurial-scm.org/D3931
author Martin von Zweigbergk <martinvonz@google.com>
date Wed, 11 Jul 2018 16:29:23 -0700
parents 6afa928033bd
children 572dff5c946e
files hgext/rebase.py mercurial/revlog.py
diffstat 2 files changed, 7 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- 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):