changeset 23475:67f1d68861fb

merge: don't ignore conflicting file in remote renamed directory When the remote side has renamed a directory from a/ to b/ and added a file b/c in it, and the local side has added a file a/c, we end up moving a/c to b/c without considering the remote version of b/c. Add a check for this case and use the merge ('m') action in this case instead of the directory rename ('dm') action.
author Martin von Zweigbergk <martinvonz@google.com>
date Wed, 03 Dec 2014 10:56:07 -0800
parents 9f4ac44a7273
children 39a12719ec65
files mercurial/merge.py tests/test-rename-dir-merge.t
diffstat 2 files changed, 18 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/merge.py	Sun Nov 23 15:08:50 2014 -0800
+++ b/mercurial/merge.py	Wed Dec 03 10:56:07 2014 -0800
@@ -446,8 +446,12 @@
                 pass # we'll deal with it on m2 side
             elif f in movewithdir: # directory rename, move local
                 f2 = movewithdir[f]
-                actions['dm'].append((f2, (f, fl1),
-                                "remote directory rename - move from " + f))
+                if f2 in m2:
+                    actions['m'].append((f2, (f, f2, None, True, pa.node()),
+                                   "remote directory rename, both created"))
+                else:
+                    actions['dm'].append((f2, (f, fl1),
+                                  "remote directory rename - move from " + f))
             elif f in copy:
                 f2 = copy[f]
                 actions['m'].append((f, (f, f2, f2, False, pa.node()),
--- a/tests/test-rename-dir-merge.t	Sun Nov 23 15:08:50 2014 -0800
+++ b/tests/test-rename-dir-merge.t	Wed Dec 03 10:56:07 2014 -0800
@@ -148,8 +148,6 @@
 Remote directory rename with conflicting file added in remote target directory
 and committed in local source directory.
 
-BROKEN: the remote is ignored; it should be merged
-
   $ hg co -qC 2
   $ rm b/c
   $ hg st -A
@@ -158,19 +156,28 @@
   C a/b
   C a/c
   $ hg merge 5
-  3 files updated, 0 files merged, 2 files removed, 0 files unresolved
-  (branch merge, don't forget to commit)
+  merging a/c and b/c to b/c
+  warning: conflicts during merge.
+  merging b/c incomplete! (edit conflicts, then use 'hg resolve --mark')
+  2 files updated, 0 files merged, 2 files removed, 1 files unresolved
+  use 'hg resolve' to retry unresolved file merges or 'hg update -C .' to abandon
+  [1]
   $ hg st -A
   M b/a
   M b/b
-  A b/c
+  M b/c
     a/c
   R a/a
   R a/b
   R a/c
   ? a/d
+  ? b/c.orig
   $ cat b/c
+  <<<<<<< local: ce36d17b18fb  - test: 2 add a/c
   baz
+  =======
+  target
+  >>>>>>> other: f1c50ca4f127 - test: new file in target directory
 
 Second scenario with two repos: