changeset 21080:04540a8499a3

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.
author Mads Kiilerich <madski@unity3d.com>
date Sun, 06 Apr 2014 13:39:51 +0200
parents b02ab6486a78
children ffd7b6ce46ff
files hgext/largefiles/overrides.py mercurial/merge.py
diffstat 2 files changed, 23 insertions(+), 24 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/largefiles/overrides.py	Thu Oct 03 18:01:21 2013 +0200
+++ b/hgext/largefiles/overrides.py	Sun Apr 06 13:39:51 2014 +0200
@@ -366,10 +366,10 @@
 # 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
--- a/mercurial/merge.py	Thu Oct 03 18:01:21 2013 +0200
+++ b/mercurial/merge.py	Sun Apr 06 13:39:51 2014 +0200
@@ -376,7 +376,7 @@
         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 @@
     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 @@
 
     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 @@
                 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 @@
                     # 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