mercurial/context.py
changeset 21125 e94e90a4526e
parent 21114 a63958bcf63a
child 21126 99b5eaf372a7
--- a/mercurial/context.py	Thu Apr 17 09:36:09 2014 +0900
+++ b/mercurial/context.py	Thu Apr 17 17:32:04 2014 +0200
@@ -402,8 +402,17 @@
         n2 = c2._node
         if n2 is None:
             n2 = c2._parents[0]._node
-        n = self._repo.changelog.ancestor(self._node, n2)
-        return changectx(self._repo, n)
+        cahs = self._repo.changelog.commonancestorsheads(self._node, n2)
+        if not cahs:
+            anc = nullid
+        elif len(cahs) == 1:
+            anc = cahs[0]
+        else:
+            anc = self._repo.changelog.ancestor(self._node, n2)
+            self._repo.ui.status(
+                (_("note: using %s as ancestor of %s and %s\n") %
+                 (short(anc), short(self._node), short(n2))))
+        return changectx(self._repo, anc)
 
     def descendant(self, other):
         """True if other is descendant of this changeset"""