Patchwork [13,of,16] merge: move ancestor selection tweaking to update function

login
register
mail settings
Submitter Mads Kiilerich
Date March 2, 2014, 7:15 p.m.
Message ID <b9fc8516a99c48202c0c.1393787746@localhost.localdomain>
Download mbox | patch
Permalink /patch/3825/
State Deferred
Headers show

Comments

Mads Kiilerich - March 2, 2014, 7:15 p.m.
# HG changeset patch
# User Mads Kiilerich <madski@unity3d.com>
# Date 1393783057 -3600
#      Sun Mar 02 18:57:37 2014 +0100
# Node ID b9fc8516a99c48202c0cbd52798d3da206aa65ca
# Parent  9676d2ab8613a58f1b9e29d04c9b47ce3d3700e4
merge: move ancestor selection tweaking to update function

- passing through calculateupdates.

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
@@ -316,7 +316,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
 
@@ -325,19 +325,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())]
@@ -674,14 +663,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 = [], []
@@ -709,8 +698,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
 
@@ -934,9 +923,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