Mercurial > hg-stable
changeset 38668:21846c94e605
revlog: delete isdescendantrev() in favor of isancestorrev()
As agreed on by Boris, Yuya, and me on D3929.
Differential Revision: https://phab.mercurial-scm.org/D3934
author | Martin von Zweigbergk <martinvonz@google.com> |
---|---|
date | Thu, 12 Jul 2018 08:14:21 -0700 |
parents | 572dff5c946e |
children | b5891bf8ab13 |
files | mercurial/context.py mercurial/revlog.py |
diffstat | 2 files changed, 12 insertions(+), 18 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/context.py Sat Jun 30 12:42:49 2018 +0530 +++ b/mercurial/context.py Thu Jul 12 08:14:21 2018 -0700 @@ -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.'''
--- a/mercurial/revlog.py Sat Jun 30 12:42:49 2018 +0530 +++ b/mercurial/revlog.py Thu Jul 12 08:14:21 2018 -0700 @@ -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"""