Patchwork [6,of,8] merge: create 'cm' action for 'get or merge' case

login
register
mail settings
Submitter Martin von Zweigbergk
Date Dec. 23, 2014, 12:33 a.m.
Message ID <a194174c25fd329be8a7.1419294820@martinvonz.mtv.corp.google.com>
Download mbox | patch
Permalink /patch/7207/
State Accepted
Commit 9d56be47b5d6a07d3c63f1f7d35621c0fa0eeb75
Headers show

Comments

Martin von Zweigbergk - Dec. 23, 2014, 12:33 a.m.
# HG changeset patch
# User Martin von Zweigbergk <martinvonz@google.com>
# Date 1418690719 28800
#      Mon Dec 15 16:45:19 2014 -0800
# Node ID a194174c25fd329be8a74f5b10586187c414f85d
# Parent  d32c1035354d1317dced8a8263673ad590aaa6aa
merge: create 'cm' action for 'get or merge' case

We still have one case of a call to _checkunknownfile() in
manifestmerge(): when force=True and branchmerge=True and the remote
side has a file that the local side doesn't. This combination of
arguments is used by 'hg merge --force', but also by rebase and
unshelve. In this scenario, we try to create the file from the
contents from the remote, but if there is already a local untracked
file in place, we merge it instead.

Patch

diff --git a/mercurial/merge.py b/mercurial/merge.py
--- a/mercurial/merge.py
+++ b/mercurial/merge.py
@@ -501,12 +501,8 @@ 
                 elif not branchmerge:
                     actions[f] = ('c', (fl2,), "remote created")
                 else:
-                    different = _checkunknownfile(repo, wctx, p2, f)
-                    if different:
-                        actions[f] = ('m', (f, f, None, False, pa.node()),
-                                      "remote differs from untracked local")
-                    else:
-                        actions[f] = ('g', (fl2,), "remote created")
+                    actions[f] = ('cm', (fl2, pa.node()),
+                                  "remote created, get or merge")
             elif n2 != ma[f]:
                 if acceptremote:
                     actions[f] = ('c', (fl2,), "remote recreating")
@@ -532,6 +528,14 @@ 
     for f, (m, args, msg) in actions.iteritems():
         if m == 'c':
             actions[f] = ('g', args, msg)
+        elif m == 'cm':
+            fl2, anc = args
+            different = _checkunknownfile(repo, wctx, p2, f)
+            if different:
+                actions[f] = ('m', (f, f, None, False, anc),
+                              "remote differs from untracked local")
+            else:
+                actions[f] = ('g', (fl2,), "remote created")
 
     return actions, diverge, renamedelete