Patchwork [2,of,6,bid,merge,v2] merge: move ancestor selection tweaking from manifestmerge to update function

login
register
mail settings
Submitter Mads Kiilerich
Date April 7, 2014, 12:18 a.m.
Message ID <6d728c9150aa1879c475.1396829938@localhost.localdomain>
Download mbox | patch
Permalink /patch/4237/
State Accepted
Commit 04540a8499a3bfb23695b590e6a3d637280f2372
Headers show

Comments

Mads Kiilerich - April 7, 2014, 12:18 a.m.
# HG changeset patch
# User Mads Kiilerich <madski@unity3d.com>
# Date 1396784391 -7200
#      Sun Apr 06 13:39:51 2014 +0200
# Node ID 6d728c9150aa1879c475ad6db8c03d12d08b0aac
# Parent  6ab1d2340403e890b0719b6b8c6771171cf55204
merge: move ancestor selection tweaking from manifestmerge to update function

- passing it through calculateupdates.

This will make sure manifestmerge actually use the ancestor it is given.

Patch

diff --git a/hgext/largefiles/overrides.py b/hgext/largefiles/overrides.py
--- a/hgext/largefiles/overrides.py
+++ b/hgext/largefiles/overrides.py
@@ -366,10 +366,10 @@  def overridecheckunknownfile(origfn, rep
 # writing the files into the working copy and lfcommands.updatelfiles
 # will update the largefiles.
 def overridecalculateupdates(origfn, repo, p1, p2, pa, branchmerge, force,
-                             partial, acceptremote=False):
+                             partial, acceptremote, followcopies):
     overwrite = force and not branchmerge
     actions = origfn(repo, p1, p2, pa, branchmerge, force, partial,
-                     acceptremote)
+                     acceptremote, followcopies)
 
     if overwrite:
         return actions
diff --git a/mercurial/merge.py b/mercurial/merge.py
--- a/mercurial/merge.py
+++ b/mercurial/merge.py
@@ -376,7 +376,7 @@  def _checkcollision(repo, wmf, actions):
         foldmap[fold] = f
 
 def manifestmerge(repo, wctx, p2, pa, branchmerge, force, partial,
-                  acceptremote=False):
+                  acceptremote, followcopies):
     """
     Merge p1 and p2 with ancestor pa and generate merge action list
 
@@ -385,19 +385,8 @@  def manifestmerge(repo, wctx, p2, pa, br
     acceptremote = accept the incoming changes without prompting
     """
 
-    overwrite = force and not branchmerge
     actions, copy, movewithdir = [], {}, {}
 
-    followcopies = False
-    if overwrite:
-        pa = wctx
-    elif pa == p2: # backwards
-        pa = wctx.p1()
-    elif not branchmerge and not wctx.dirty(missing=True):
-        pass
-    elif pa and repo.ui.configbool("merge", "followcopies", True):
-        followcopies = True
-
     # manifests fetched in order are going to be faster, so prime the caches
     [x.manifest() for x in
      sorted(wctx.parents() + [p2, pa], key=lambda x: x.rev())]
@@ -730,14 +719,14 @@  def applyupdates(repo, actions, wctx, mc
 
     return updated, merged, removed, unresolved
 
-def calculateupdates(repo, tctx, mctx, ancestor, branchmerge, force, partial,
-                     acceptremote=False):
-    "Calculate the actions needed to merge mctx into tctx"
-    actions = []
-    actions += manifestmerge(repo, tctx, mctx,
+def calculateupdates(repo, wctx, mctx, ancestor, branchmerge, force, partial,
+                     acceptremote, followcopies):
+    "Calculate the actions needed to merge mctx into wctx using ancestor"
+
+    actions = manifestmerge(repo, wctx, mctx,
                              ancestor,
                              branchmerge, force,
-                             partial, acceptremote)
+                             partial, acceptremote, followcopies)
 
     # Filter out prompts.
     newactions, prompts = [], []
@@ -765,8 +754,8 @@  def calculateupdates(repo, tctx, mctx, a
                 newactions.append((f, "g", (flags,), "prompt recreating"))
         else: assert False, m
 
-    if tctx.rev() is None:
-        newactions += _forgetremoved(tctx, mctx, branchmerge)
+    if wctx.rev() is None:
+        newactions += _forgetremoved(wctx, mctx, branchmerge)
 
     return newactions
 
@@ -990,9 +979,19 @@  def update(repo, node, branchmerge, forc
                     # Allow jumping branches if clean and specific rev given
                     pa = p1
 
+        followcopies = False
+        if overwrite:
+            pa = wc
+        elif pa == p2: # backwards
+            pa = wc.p1()
+        elif not branchmerge and not wc.dirty(missing=True):
+            pass
+        elif pa and repo.ui.configbool("merge", "followcopies", True):
+            followcopies = True
+
         ### calculate phase
-        actions = calculateupdates(repo, wc, p2, pa,
-                                   branchmerge, force, partial, mergeancestor)
+        actions = calculateupdates(repo, wc, p2, pa, branchmerge, force,
+                                   partial, mergeancestor, followcopies)
 
         ### apply phase
         if not branchmerge: # just jump to the new rev