[PATCH 4 of 6 bid merge v2] merge: keep track of all ancestors in update, select one in calculateupdates

Mads Kiilerich mads at kiilerich.com
Sun Apr 6 19:19:00 CDT 2014


# HG changeset patch
# User Mads Kiilerich <madski at unity3d.com>
# Date 1393552352 -3600
#      Fri Feb 28 02:52:32 2014 +0100
# Node ID 1cd8e01c37a5fff8a64898f6dc52df5dd332d5ac
# Parent  a3b154b7e80263a39e34812939fa7eacc87836da
merge: keep track of all ancestors in update, select one in calculateupdates

The update function will now use the full list of common ancestor heads from
changelog.commonancestors instead of ctx.ancestor .

This will be the only case where more than one ancestor can be passed to
calculateupdates. If calculateupdates finds more than one ancestor, it will for
now just pick one using the old ctx.ancestor method. Later changes will make it
more clever.

diff --git a/mercurial/merge.py b/mercurial/merge.py
--- a/mercurial/merge.py
+++ b/mercurial/merge.py
@@ -724,6 +724,9 @@ def calculateupdates(repo, wctx, mctx, a
     "Calculate the actions needed to merge mctx into wctx using ancestors"
 
     ancestor = ancestors[0]
+    if len(ancestors) > 1:
+        ancestor = wctx.ancestor(mctx)
+        assert ancestor in ancestors
 
     actions = manifestmerge(repo, wctx, mctx,
                              ancestor,
@@ -924,7 +927,8 @@ def update(repo, node, branchmerge, forc
 
         p2 = repo[node]
         if pas[0] is None:
-            pas = [p1.ancestor(p2)]
+            ancs = repo.changelog.commonancestors(p1.node(), p2.node())
+            pas = [repo[anc] for anc in (sorted(ancs) or [nullid])]
 
         fp1, fp2, xp1, xp2 = p1.node(), p2.node(), str(p1), str(p2)
 


More information about the Mercurial-devel mailing list