# HG changeset patch # User Jun Wu <qu...@fb.com> # Date 1477987839 0 # Tue Nov 01 08:10:39 2016 +0000 # Node ID ac063914b3a3c01f1d7ed253c73113903fccb7a9 # Parent 264f00b3e5f045ac5b58d79e2a3976585f4e7739 # Available At https://bitbucket.org/quark-zju/hg-draft # hg pull https://bitbucket.org/quark-zju/hg-draft -r ac063914b3a3 revlog: make commonancestorsheads accept revision numbers
This avoids overhead converting arguments between revision numbers and nodes in the following patches. diff --git a/mercurial/revlog.py b/mercurial/revlog.py --- a/mercurial/revlog.py +++ b/mercurial/revlog.py @@ -885,14 +885,24 @@ class revlog(object): 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) + """calculate all the heads of the common ancestors of a and b + + a and b can be both revision numbers, or nodes. The return value will + be the same type. + """ + isnode = not (isinstance(a, int) and isinstance(b, int)) + if isnode: + a, b = self.rev(a), self.rev(b) try: ancs = self.index.commonancestorsheads(a, b) except (AttributeError, OverflowError): # C implementation failed ancs = ancestor.commonancestorsheads(self.parentrevs, a, b) - return map(self.node, ancs) + if isnode: + ancs = map(self.node, ancs) + return ancs def isancestor(self, a, b): - """return True if node a is an ancestor of node b + """return True if a is an ancestor of b + + a and b can be both revision numbers, or nodes. The implementation of this is trivial but the use of _______________________________________________ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel