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

login
register
mail settings
Submitter Mads Kiilerich
Date April 7, 2014, 12:19 a.m.
Message ID <1cd8e01c37a5fff8a648.1396829940@localhost.localdomain>
Download mbox | patch
Permalink /patch/4239/
State Accepted
Headers show

Comments

Mads Kiilerich - April 7, 2014, 12:19 a.m.
# HG changeset patch
# User Mads Kiilerich <madski@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.

Patch

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)