comparison mercurial/revlog.py @ 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 4092d12ba18a
children 94f77624dbb5
comparison
equal deleted inserted replaced
22380:82b2ba904e3e 22381:392ae5cb8d62
743 ancs = self.index.commonancestorsheads(a, b) 743 ancs = self.index.commonancestorsheads(a, b)
744 except (AttributeError, OverflowError): # C implementation failed 744 except (AttributeError, OverflowError): # C implementation failed
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
751 a, b = self.rev(a), self.rev(b) 758 a, b = self.rev(a), self.rev(b)
752 try: 759 try: