Patchwork [4,of,6] merge: create at most one 'rm' action per file

login
register
mail settings
Submitter Martin von Zweigbergk
Date Dec. 3, 2014, 5:17 p.m.
Message ID <4491dd19d9566ad6b64d.1417627034@martinvonz.mtv.corp.google.com>
Download mbox | patch
Permalink /patch/6980/
State Superseded
Headers show

Comments

Martin von Zweigbergk - Dec. 3, 2014, 5:17 p.m.
# HG changeset patch
# User Martin von Zweigbergk <martinvonz@google.com>
# Date 1416807679 28800
#      Sun Nov 23 21:41:19 2014 -0800
# Node ID 4491dd19d9566ad6b64ddb50312b1e6d57a24e27
# Parent  d7c59ced01f5bc3ddc34c3b597b8915740ed79c0
merge: create at most one 'rm' action per file

Copying one file to several places and removing its source results in
multiple 'rm' actions being created. This is harmless since we check
whether the file exists before we try to remove it. Still, it seems
better to not even create multiple 'rm' actions. By creating the
action on the source side instead of the destination side, we make
sure only one action is created for each file.

Patch

diff --git a/mercurial/merge.py b/mercurial/merge.py
--- a/mercurial/merge.py
+++ b/mercurial/merge.py
@@ -442,7 +442,7 @@ 
                                    "versions differ"))
         elif n1: # file exists only on local side
             if f in copied:
-                pass # we'll deal with it on m2 side
+                actions['rm'].append((f, None, "remote moved away"))
             elif f in movewithdir: # directory rename, move local
                 f2 = movewithdir[f]
                 actions['dm'].append((f2, (f, fl1),
@@ -478,8 +478,6 @@ 
                     actions['m'].append((f, (f2, f, f2, pa.node()),
                                     "remote copied from " + f2))
                 else:
-                    actions['rm'].append((f2, None,
-                                    "remote moved to " + f))
                     actions['m'].append((f, (f2, f, f2, pa.node()),
                                     "remote moved from " + f2))
             elif f not in ma: