D3931: revlog: introduce a isancestorrev() and use it in rebase

martinvonz (Martin von Zweigbergk) phabricator at mercurial-scm.org
Thu Jul 12 00:10:05 UTC 2018


martinvonz created this revision.
Herald added a reviewer: indygreg.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D3931

AFFECTED FILES
  hgext/rebase.py
  mercurial/revlog.py

CHANGE DETAILS

diff --git a/mercurial/revlog.py b/mercurial/revlog.py
--- a/mercurial/revlog.py
+++ b/mercurial/revlog.py
@@ -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):
diff --git a/hgext/rebase.py b/hgext/rebase.py
--- a/hgext/rebase.py
+++ b/hgext/rebase.py
@@ -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



To: martinvonz, indygreg, #hg-reviewers
Cc: mercurial-devel


More information about the Mercurial-devel mailing list