Patchwork merge: demonstrate that directory renames can lose local file content

login
register
mail settings
Submitter Martin von Zweigbergk
Date Dec. 2, 2014, 9:42 p.m.
Message ID <4e23f3d47f4288b78d47.1417556561@martinvonz.mtv.corp.google.com>
Download mbox | patch
Permalink /patch/6964/
State Accepted
Headers show

Comments

Martin von Zweigbergk - Dec. 2, 2014, 9:42 p.m.
# HG changeset patch
# User Martin von Zweigbergk <martinvonz@google.com>
# Date 1417555687 28800
#      Tue Dec 02 13:28:07 2014 -0800
# Node ID 4e23f3d47f4288b78d4714db32457ed8759844be
# Parent  19ebd2f88fc77282efe724b30de8750f79771e8f
merge: demonstrate that directory renames can lose local file content

When a directory has been renamed on the local branch and a file has
been added in the old location on a remote branch, we move that new
file to the new location. Unfortunately, if there is already a file
there, we overwrite it with the contents from the remote branch. For
untracked local files, we should probably abort, and for tracked local
files, we should merge the contents. To start with, let's add a test
to demonstrate the breakage. Also note that while files merged in from
a remote branch are normally (and unintuitively) reported as modified,
these files are reported as added.
Pierre-Yves David - Dec. 2, 2014, 10:53 p.m.
On 12/02/2014 01:42 PM, Martin von Zweigbergk wrote:
> # HG changeset patch
> # User Martin von Zweigbergk <martinvonz@google.com>
> # Date 1417555687 28800
> #      Tue Dec 02 13:28:07 2014 -0800
> # Node ID 4e23f3d47f4288b78d4714db32457ed8759844be
> # Parent  19ebd2f88fc77282efe724b30de8750f79771e8f
> merge: demonstrate that directory renames can lose local file content

Pushed to the clowncopter, thanks.

Patch

diff --git a/tests/test-rename-dir-merge.t b/tests/test-rename-dir-merge.t
--- a/tests/test-rename-dir-merge.t
+++ b/tests/test-rename-dir-merge.t
@@ -105,6 +105,41 @@ 
   $ hg debugrename b/c
   b/c renamed from a/c:354ae8da6e890359ef49ade27b68bbc361f3ca88 (glob)
 
+Local directory rename with conflicting file added in remote source directory
+and untracked in local target directory.
+
+BROKEN: the uncommitted file is overwritten; we should abort
+
+  $ hg co -qC 1
+  $ echo local > b/c
+  $ hg merge 2
+  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  (branch merge, don't forget to commit)
+  $ hg st -C
+  A b/c
+    a/c
+  ? a/d
+  $ cat b/c
+  baz
+
+Local directory rename with conflicting file added in remote source directory
+and committed in local target directory.
+
+BROKEN: the local file is overwritten; it should be merged
+
+  $ hg co -qC 1
+  $ echo local > b/c
+  $ hg add b/c
+  $ hg commit -qm 'new file in target directory'
+  $ hg merge 2
+  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  (branch merge, don't forget to commit)
+  $ hg st -C
+  A b/c
+    a/c
+  ? a/d
+  $ cat b/c
+  baz
 
 Second scenario with two repos: