Mercurial > hg-stable
diff 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 |
line wrap: on
line diff
--- a/mercurial/revlog.py Tue Apr 16 10:08:18 2013 -0700 +++ b/mercurial/revlog.py Tue Apr 16 10:08:19 2013 -0700 @@ -705,17 +705,12 @@ def ancestor(self, a, b): """calculate the least common ancestor of nodes a and b""" - # fast path, check if it is a descendant a, b = self.rev(a), self.rev(b) - start, end = sorted((a, b)) - if self.descendant(start, end): - return self.node(start) - - c = ancestor.ancestor(a, b, self.parentrevs) - if c is None: - return nullid - - return self.node(c) + ancs = ancestor.ancestors(self.parentrevs, a, b) + if ancs: + # choose a consistent winner when there's a tie + return min(map(self.node, ancs)) + return nullid def _match(self, id): if isinstance(id, int):