Patchwork D3934: revlog: delete isdescendantrev() in favor of isancestorrev()

login
register
mail settings
Submitter phabricator
Date July 13, 2018, 12:23 p.m.
Message ID <16634b496b4ece6daeeb690ab0037958@localhost.localdomain>
Download mbox | patch
Permalink /patch/32831/
State Not Applicable
Headers show

Comments

phabricator - July 13, 2018, 12:23 p.m.
This revision was automatically updated to reflect the committed changes.
Closed by commit rHG21846c94e605: revlog: delete isdescendantrev() in favor of isancestorrev() (authored by martinvonz, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D3934?vs=9570&id=9580

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

AFFECTED FILES
  mercurial/context.py
  mercurial/revlog.py

CHANGE DETAILS




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

Patch

diff --git a/mercurial/revlog.py b/mercurial/revlog.py
--- a/mercurial/revlog.py
+++ b/mercurial/revlog.py
@@ -1645,21 +1645,6 @@ 
                 c.append(self.node(r))
         return c
 
-    def isdescendantrev(self, a, b):
-        """True if revision a is a descendant of revision b
-
-        A revision is considered a descendant of itself.
-
-        The implementation of this is trivial but the use of
-        commonancestorsheads is not."""
-        if b == nullrev:
-            return True
-        elif a == b:
-            return True
-        elif a < b:
-            return False
-        return b in self._commonancestorsheads(a, b)
-
     def commonancestorsheads(self, a, b):
         """calculate all the heads of the common ancestors of nodes a and b"""
         a, b = self.rev(a), self.rev(b)
@@ -1684,8 +1669,17 @@ 
     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)
+        A revision is considered an ancestor of itself.
+
+        The implementation of this is trivial but the use of
+        commonancestorsheads is not."""
+        if a == nullrev:
+            return True
+        elif a == b:
+            return True
+        elif a > b:
+            return False
+        return a in self._commonancestorsheads(a, b)
 
     def ancestor(self, a, b):
         """calculate the "best" common ancestor of nodes a and b"""
diff --git a/mercurial/context.py b/mercurial/context.py
--- a/mercurial/context.py
+++ b/mercurial/context.py
@@ -591,7 +591,7 @@ 
 
     def descendant(self, other):
         """True if other is descendant of this changeset"""
-        return self._repo.changelog.isdescendantrev(other._rev, self._rev)
+        return self._repo.changelog.isancestorrev(self._rev, other._rev)
 
     def walk(self, match):
         '''Generates matching file names.'''