comparison mercurial/revlog.py @ 38518:cc3543c87de5

revlog: reuse 'descendant' implemention in 'isancestor' The two functions do the same thing, but one takes nodes while the other takes revs. Using one to implement the other make sense. We should probably cleanup the API at some point to avoid having so many similar functions. However, we focus on an efficient implementation for now.
author Boris Feld <boris.feld@octobus.net>
date Fri, 22 Jun 2018 00:07:22 +0100
parents 6db38c9d7e00
children 44f5acfb9ad2
comparison
equal deleted inserted replaced
38517:6db38c9d7e00 38518:cc3543c87de5
1402 def isancestor(self, a, b): 1402 def isancestor(self, a, b):
1403 """return True if node a is an ancestor of node b 1403 """return True if node a is an ancestor of node b
1404 1404
1405 The implementation of this is trivial but the use of 1405 The implementation of this is trivial but the use of
1406 commonancestorsheads is not.""" 1406 commonancestorsheads is not."""
1407 return a in self.commonancestorsheads(a, b) 1407 a, b = self.rev(a), self.rev(b)
1408 return self.descendant(a, b)
1408 1409
1409 def ancestor(self, a, b): 1410 def ancestor(self, a, b):
1410 """calculate the "best" common ancestor of nodes a and b""" 1411 """calculate the "best" common ancestor of nodes a and b"""
1411 1412
1412 a, b = self.rev(a), self.rev(b) 1413 a, b = self.rev(a), self.rev(b)