Mercurial > hg
changeset 22381:392ae5cb8d62
revlog: introduce isancestor method for efficiently determining node lineage
Hide the not so obvious use of commonancestorsheads.
author | Mads Kiilerich <madski@unity3d.com> |
---|---|
date | Tue, 19 Aug 2014 01:13:10 +0200 |
parents | 82b2ba904e3e |
children | d5b04ee8ecf7 |
files | mercurial/commands.py mercurial/revlog.py |
diffstat | 2 files changed, 8 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/commands.py Tue Sep 09 17:16:24 2014 -0400 +++ b/mercurial/commands.py Tue Aug 19 01:13:10 2014 +0200 @@ -454,7 +454,7 @@ node = scmutil.revsingle(repo, rev).node() op1, op2 = repo.dirstate.parents() - if node not in repo.changelog.commonancestorsheads(op1, node): + if not repo.changelog.isancestor(node, op1): raise util.Abort(_('cannot backout change that is not an ancestor')) p1, p2 = repo.changelog.parents(node)
--- a/mercurial/revlog.py Tue Sep 09 17:16:24 2014 -0400 +++ b/mercurial/revlog.py Tue Aug 19 01:13:10 2014 +0200 @@ -745,6 +745,13 @@ ancs = ancestor.commonancestorsheads(self.parentrevs, a, b) return map(self.node, ancs) + def isancestor(self, a, b): + """return True if node a is an ancestor of node b + + The implementation of this is trivial but the use of + commonancestorsheads is not.""" + return a in self.commonancestorsheads(a, b) + def ancestor(self, a, b): """calculate the least common ancestor of nodes a and b"""