mirror of
https://github.com/facebook/sapling.git
synced 2024-10-07 15:27:13 +03:00
revlog: introduce isancestor method for efficiently determining node lineage
Hide the not so obvious use of commonancestorsheads.
This commit is contained in:
parent
54df1661c3
commit
b46e11faa6
@ -454,7 +454,7 @@ def backout(ui, repo, node=None, rev=None, **opts):
|
||||
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)
|
||||
|
@ -745,6 +745,13 @@ class revlog(object):
|
||||
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"""
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user