revlog: replace descendant(b, a) by isdescendantrev(a, b) (API)
authorMartin von Zweigbergk <martinvonz@google.com>
Wed, 11 Jul 2018 16:21:41 -0700
changeset 38664 160da69ba1bf
parent 38663 93d9690ff2b0
child 38665 6afa928033bd
revlog: replace descendant(b, a) by isdescendantrev(a, b) (API) The "is" is to match "isancestor" and to make it clear that it doesn't return a descendant. The "rev" is to make it clear that it's not about nodeids (unlike e.g. isancestor()). The argument order change is just seems more natural (and makes isancestor() less confusing). Differential Revision: https://phab.mercurial-scm.org/D3929
mercurial/context.py
mercurial/revlog.py
--- a/mercurial/context.py	Wed Jul 11 16:27:40 2018 -0700
+++ b/mercurial/context.py	Wed Jul 11 16:21:41 2018 -0700
@@ -591,7 +591,7 @@
 
     def descendant(self, other):
         """True if other is descendant of this changeset"""
-        return self._repo.changelog.descendant(self._rev, other._rev)
+        return self._repo.changelog.isdescendantrev(other._rev, self._rev)
 
     def walk(self, match):
         '''Generates matching file names.'''
--- a/mercurial/revlog.py	Wed Jul 11 16:27:40 2018 -0700
+++ b/mercurial/revlog.py	Wed Jul 11 16:21:41 2018 -0700
@@ -1645,18 +1645,18 @@
                 c.append(self.node(r))
         return c
 
-    def descendant(self, start, end):
-        """True if revision 'end' is an descendant of revision 'start'
-
-        A revision is considered as a descendant of itself.
+    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 start == nullrev:
+        if b == nullrev:
             return True
-        elif start == end:
+        elif a == b:
             return True
-        return start in self._commonancestorsheads(start, end)
+        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"""
@@ -1673,9 +1673,11 @@
         return ancs
 
     def isancestor(self, a, b):
-        """return True if node a is an ancestor of node b"""
+        """return True if node a is an ancestor of node b
+
+        A revision is considered an ancestor of itself."""
         a, b = self.rev(a), self.rev(b)
-        return self.descendant(a, b)
+        return self.isdescendantrev(b, a)
 
     def ancestor(self, a, b):
         """calculate the "best" common ancestor of nodes a and b"""