comparison mercurial/revlog.py @ 18987:3605d4e7e618

revlog: choose a consistent ancestor when there's a tie Previously, we chose a rev based on numeric ordering, which could cause "the same merge" in topologically identical but numerically different repos to choose different merge bases. We now choose the lexically least node; this is stable across different revlog orderings.
author Bryan O'Sullivan <bryano@fb.com>
date Tue, 16 Apr 2013 10:08:19 -0700
parents 2f7186400a07
children 5bae936764bb
comparison
equal deleted inserted replaced
18986:2f7186400a07 18987:3605d4e7e618
703 return False 703 return False
704 704
705 def ancestor(self, a, b): 705 def ancestor(self, a, b):
706 """calculate the least common ancestor of nodes a and b""" 706 """calculate the least common ancestor of nodes a and b"""
707 707
708 # fast path, check if it is a descendant
709 a, b = self.rev(a), self.rev(b) 708 a, b = self.rev(a), self.rev(b)
710 start, end = sorted((a, b)) 709 ancs = ancestor.ancestors(self.parentrevs, a, b)
711 if self.descendant(start, end): 710 if ancs:
712 return self.node(start) 711 # choose a consistent winner when there's a tie
713 712 return min(map(self.node, ancs))
714 c = ancestor.ancestor(a, b, self.parentrevs) 713 return nullid
715 if c is None:
716 return nullid
717
718 return self.node(c)
719 714
720 def _match(self, id): 715 def _match(self, id):
721 if isinstance(id, int): 716 if isinstance(id, int):
722 # rev 717 # rev
723 return self.node(id) 718 return self.node(id)