From patchwork Sun Jul 1 06:38:42 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [4,of,4] revlog: reuse 'descendant' implemention in 'isancestor' From: Paul Morelle X-Patchwork-Id: 32539 Message-Id: <6bfe8fc36b4e20fcdf6c.1530427122@belenos.localdomain> To: mercurial-devel@mercurial-scm.org Date: Sun, 01 Jul 2018 08:38:42 +0200 # HG changeset patch # User Boris Feld # Date 1529622442 -3600 # Fri Jun 22 00:07:22 2018 +0100 # Node ID 6bfe8fc36b4e20fcdf6cc49fe9ddb6e79bcf213f # Parent 5ea9c5d20ecc1aac2aecdd4c0902b3cd470b04d5 # EXP-Topic descendant # Available At https://bitbucket.org/octobus/mercurial-devel/ # hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 6bfe8fc36b4e revlog: reuse 'descendant' implemention in 'isancestor' The two functions do the same thing, but one takes nodes while the other takes revs. Using one to implement the other make sense. We should probably cleanup the API at some point to avoid having so many similar functions. However, we focus on an efficient implementation for now. diff -r 5ea9c5d20ecc -r 6bfe8fc36b4e mercurial/revlog.py --- a/mercurial/revlog.py Fri Jun 22 00:05:20 2018 +0100 +++ b/mercurial/revlog.py Fri Jun 22 00:07:22 2018 +0100 @@ -1404,7 +1404,8 @@ The implementation of this is trivial but the use of commonancestorsheads is not.""" - return a in self.commonancestorsheads(a, b) + a, b = self.rev(a), self.rev(b) + return self.descendant(a, b) def ancestor(self, a, b): """calculate the "best" common ancestor of nodes a and b"""