merge: allow merging going backwards
authorMatt Mackall <mpm@selenic.com>
Mon, 08 Jun 2009 18:14:44 -0500
changeset 8742 a964ab624385
parent 8741 e592180ba435
child 8743 a8d5af707656
merge: allow merging going backwards New behavior is generally superior and more correct, except possibly with regards to missing files. hg up . is now effectively a no-op, which is probably the desired behavior for people expecting to move to tip, but may surprise people who were expecting deleted files to reappear. case 1: update to . a-w -> a-w classic: ancestor a missing recreated right? rmed recreated WRONG added forgotten WRONG changed preserved RIGHT conflicted can't happen backward merge: ancestor a (NO EFFECT) missing missing wrong? rm'ed rm'ed RIGHT added preserved RIGHT changed preserved RIGHT conflicted can't happen case 2: update to ancestor of . a-b-w -> b-w \ a classic: ancestor a missing recreated right? rmed recreated wrong? added forgotten wrong? changed preserved RIGHT conflicted preserved wrong? backwards merge: ancestor b missing missing or conflict right? rm'ed missing or conflict right? changed preserved RIGHT conflicted merge RIGHT added preserved right?
mercurial/merge.py
tests/test-custom-filters
tests/test-encode
tests/test-execute-bit.out
tests/test-keyword
tests/test-merge-local.out
tests/test-up-local-change.out
tests/test-win32text
tests/test-win32text.out
--- a/mercurial/merge.py	Mon Jun 08 18:14:44 2009 -0500
+++ b/mercurial/merge.py	Mon Jun 08 18:14:44 2009 -0500
@@ -131,11 +131,14 @@
 
     m1 = p1.manifest()
     m2 = p2.manifest()
-    ma = pa.manifest()
     backwards = (pa == p2)
 
-    if backwards or overwrite:
+    if overwrite:
         ma = m1
+    elif backwards:
+        ma = p1.p1().manifest()
+    else:
+        ma = pa.manifest()
 
     action = []
     copy, copied, diverge = {}, {}, {}
--- a/tests/test-custom-filters	Mon Jun 08 18:14:44 2009 -0500
+++ b/tests/test-custom-filters	Mon Jun 08 18:14:44 2009 -0500
@@ -43,7 +43,7 @@
 
 echo '% Fresh checkout:'
 rm stuff.txt
-hg up
+hg up -C
 cat stuff.txt
 echo >> stuff.txt <<EOF
 Very very carefully.
--- a/tests/test-encode	Mon Jun 08 18:14:44 2009 -0500
+++ b/tests/test-encode	Mon Jun 08 18:14:44 2009 -0500
@@ -28,7 +28,7 @@
 gunzip < a.gz
 
 rm a.gz
-hg co
+hg co -C
 
 echo %% uncompress our new working dir copy
 gunzip < a.gz
--- a/tests/test-execute-bit.out	Mon Jun 08 18:14:44 2009 -0500
+++ b/tests/test-execute-bit.out	Mon Jun 08 18:14:44 2009 -0500
@@ -3,6 +3,6 @@
 % make sure we notice the change of mode if the cached size == -1
 n   0         -1 unset               a
 M a
-1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+0 files updated, 0 files merged, 0 files removed, 0 files unresolved
 d69afc33ff8a
 not executable -- whew
--- a/tests/test-keyword	Mon Jun 08 18:14:44 2009 -0500
+++ b/tests/test-keyword	Mon Jun 08 18:14:44 2009 -0500
@@ -117,7 +117,7 @@
 
 rm sym a b
 echo % update
-hg update
+hg update -C
 echo % cat
 cat a b
 
--- a/tests/test-merge-local.out	Mon Jun 08 18:14:44 2009 -0500
+++ b/tests/test-merge-local.out	Mon Jun 08 18:14:44 2009 -0500
@@ -22,7 +22,9 @@
 merging zzz2_merge_bad failed!
 3 files updated, 1 files merged, 2 files removed, 1 files unresolved
 use 'hg resolve' to retry unresolved file merges
-2 files updated, 0 files merged, 3 files removed, 0 files unresolved
+merging zzz1_merge_ok
+merging zzz2_merge_bad
+2 files updated, 2 files merged, 3 files removed, 0 files unresolved
 --- a/zzz1_merge_ok
 +++ b/zzz1_merge_ok
 +new first line
@@ -32,7 +34,6 @@
 +another last line
 M zzz1_merge_ok
 M zzz2_merge_bad
-? zzz2_merge_bad.orig
 # local merge with conflicts
 merging zzz1_merge_ok
 merging zzz2_merge_bad
@@ -40,7 +41,9 @@
 merging zzz2_merge_bad failed!
 3 files updated, 1 files merged, 2 files removed, 1 files unresolved
 use 'hg resolve' to retry unresolved file merges
-2 files updated, 0 files merged, 3 files removed, 0 files unresolved
+merging zzz1_merge_ok
+merging zzz2_merge_bad
+2 files updated, 2 files merged, 3 files removed, 0 files unresolved
 --- a/zzz1_merge_ok
 +++ b/zzz1_merge_ok
 +new first line
@@ -52,7 +55,6 @@
 +new last line
 M zzz1_merge_ok
 M zzz2_merge_bad
-? zzz2_merge_bad.orig
 # local merge without conflicts
 merging zzz1_merge_ok
 4 files updated, 1 files merged, 2 files removed, 0 files unresolved
--- a/tests/test-up-local-change.out	Mon Jun 08 18:14:44 2009 -0500
+++ b/tests/test-up-local-change.out	Mon Jun 08 18:14:44 2009 -0500
@@ -38,9 +38,15 @@
 resolving manifests
  overwrite False partial False
  ancestor 33aaa84a386b local 802f095af299+ remote 33aaa84a386b
+ a: versions differ -> m
  b: other deleted -> r
+preserving a for resolve of a
 removing b
-0 files updated, 0 files merged, 1 files removed, 0 files unresolved
+picked tool 'true' for a (binary False symlink False)
+merging a
+my a@802f095af299+ other a@33aaa84a386b ancestor a@33aaa84a386b
+ premerge successful
+0 files updated, 1 files merged, 1 files removed, 0 files unresolved
 changeset:   0:33aaa84a386b
 user:        test
 date:        Mon Jan 12 13:46:40 1970 +0000
--- a/tests/test-win32text	Mon Jun 08 18:14:44 2009 -0500
+++ b/tests/test-win32text	Mon Jun 08 18:14:44 2009 -0500
@@ -117,7 +117,7 @@
 echo
 
 rm f3 f4.bat bin
-hg co 2>&1 | python -c 'import sys, os; sys.stdout.write(sys.stdin.read().replace(os.getcwd(), "...."))'
+hg co -C 2>&1 | python -c 'import sys, os; sys.stdout.write(sys.stdin.read().replace(os.getcwd(), "...."))'
 python print.py < bin
 python print.py < f3
 python print.py < f4.bat
@@ -152,7 +152,7 @@
 echo
 
 rm f3 f4.bat bin
-hg co 2>&1 | python -c 'import sys, os; sys.stdout.write(sys.stdin.read().replace(os.getcwd(), "...."))'
+hg co -C 2>&1 | python -c 'import sys, os; sys.stdout.write(sys.stdin.read().replace(os.getcwd(), "...."))'
 python print.py < bin
 python print.py < f3
 python print.py < f4.bat
--- a/tests/test-win32text.out	Mon Jun 08 18:14:44 2009 -0500
+++ b/tests/test-win32text.out	Mon Jun 08 18:14:44 2009 -0500
@@ -314,7 +314,7 @@
 [encode]
 ** = !
 
-3 files updated, 0 files merged, 0 files removed, 0 files unresolved
+4 files updated, 0 files merged, 0 files removed, 0 files unresolved
 hello<NUL><CR><LF>
 some<LF>text<LF>
 rem empty<LF>