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

login
register
mail settings
Submitter phabricator
Date July 12, 2018, 1:12 p.m.
Message ID <021a6240ed0a2f2c1aebacb3d4da980e@localhost.localdomain>
Download mbox | patch
Permalink /patch/32811/
State Not Applicable
Headers show

Comments

phabricator - July 12, 2018, 1:12 p.m.
This revision was automatically updated to reflect the committed changes.
Closed by commit rHGa06b2b032557: revlog: introduce a isancestorrev() and use it in rebase (authored by martinvonz, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D3931?vs=9561&id=9567

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

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

CHANGE DETAILS




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

Patch

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