##// END OF EJS Templates
revlog: introduce isancestor method for efficiently determining node lineage...
Mads Kiilerich -
r22381:392ae5cb default
parent child Browse files
Show More
@@ -454,7 +454,7 b' def backout(ui, repo, node=None, rev=Non'
454 node = scmutil.revsingle(repo, rev).node()
454 node = scmutil.revsingle(repo, rev).node()
455
455
456 op1, op2 = repo.dirstate.parents()
456 op1, op2 = repo.dirstate.parents()
457 if node not in repo.changelog.commonancestorsheads(op1, node):
457 if not repo.changelog.isancestor(node, op1):
458 raise util.Abort(_('cannot backout change that is not an ancestor'))
458 raise util.Abort(_('cannot backout change that is not an ancestor'))
459
459
460 p1, p2 = repo.changelog.parents(node)
460 p1, p2 = repo.changelog.parents(node)
@@ -745,6 +745,13 b' class revlog(object):'
745 ancs = ancestor.commonancestorsheads(self.parentrevs, a, b)
745 ancs = ancestor.commonancestorsheads(self.parentrevs, a, b)
746 return map(self.node, ancs)
746 return map(self.node, ancs)
747
747
748 def isancestor(self, a, b):
749 """return True if node a is an ancestor of node b
750
751 The implementation of this is trivial but the use of
752 commonancestorsheads is not."""
753 return a in self.commonancestorsheads(a, b)
754
748 def ancestor(self, a, b):
755 def ancestor(self, a, b):
749 """calculate the least common ancestor of nodes a and b"""
756 """calculate the least common ancestor of nodes a and b"""
750
757
General Comments 0
You need to be logged in to leave comments. Login now