changeset 20421:98eadbfffa0e

merge with stable
author Matt Mackall <mpm@selenic.com>
date Sun, 09 Feb 2014 18:36:37 -0600
parents 62153c5d1ce2 (current diff) e4d7cbc94219 (diff)
children ada289dfceb0
files
diffstat 2 files changed, 33 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/merge.py	Fri Feb 07 17:29:37 2014 +0100
+++ b/mercurial/merge.py	Sun Feb 09 18:36:37 2014 -0600
@@ -343,7 +343,12 @@
                 else:
                     actions.append((f, "g", (fl2,), "remote created"))
         elif n2 and n2 != ma[f]:
-            prompts.append((f, "dc")) # prompt deleted/changed
+            different = _checkunknownfile(repo, wctx, p2, f)
+            if not force and different:
+                aborts.append((f, "ud"))
+            else:
+                # if different: old untracked f may be overwritten and lost
+                prompts.append((f, "dc")) # prompt deleted/changed
 
     for f, m in sorted(aborts):
         if m == "ud":
--- a/tests/test-merge-remove.t	Fri Feb 07 17:29:37 2014 +0100
+++ b/tests/test-merge-remove.t	Sun Feb 09 18:36:37 2014 -0600
@@ -85,3 +85,30 @@
 
   $ hg diff
 
+Merge should not overwrite local file that is untracked after remove
+
+  $ rm *
+  $ hg up -qC
+  $ hg rm bar
+  $ hg ci -m 'remove bar'
+  $ echo 'memories of buried pirate treasure' > bar
+  $ hg merge
+  bar: untracked file differs
+  abort: untracked files in working directory differ from files in requested revision
+  [255]
+  $ cat bar
+  memories of buried pirate treasure
+
+Those who use force will lose
+
+  $ hg merge -f
+  remote changed bar which local deleted
+  use (c)hanged version or leave (d)eleted? c
+  merging foo1 and foo to foo1
+  1 files updated, 1 files merged, 0 files removed, 0 files unresolved
+  (branch merge, don't forget to commit)
+  $ cat bar
+  bleh
+  $ hg st
+  M bar
+  M foo1