Add instructions how to redo/finish failed merge with local working directory.
authorThomas Arendsen Hein <thomas@intevation.de>
Mon, 11 Dec 2006 18:09:52 +0100
changeset 3869 ad6f34c83c3d
parent 3868 6033d9f28052
child 3870 22d18051f9e5
Add instructions how to redo/finish failed merge with local working directory. b2ae81a7df29 already implemented this for branch merges.
mercurial/hg.py
tests/test-merge-local
tests/test-merge-local.out
tests/test-merge-revert2.out
--- a/mercurial/hg.py	Mon Dec 11 14:30:50 2006 +0100
+++ b/mercurial/hg.py	Mon Dec 11 18:09:52 2006 +0100
@@ -234,11 +234,19 @@
 
 def update(repo, node):
     """update the working directory to node, merging linear changes"""
+    pl = repo.parents()
     stats = _merge.update(repo, node, False, False, None, None)
     _showstats(repo, stats)
     if stats[3]:
         repo.ui.status(_("There are unresolved merges with"
                          " locally modified files.\n"))
+        if stats[1]:
+            repo.ui.status(_("You can finish the partial merge using:\n"))
+        else:
+            repo.ui.status(_("You can redo the full merge using:\n"))
+        # len(pl)==1, otherwise _merge.update() would have raised util.Abort:
+        repo.ui.status(_("  hg update %s\n  hg update %s\n")
+                       % (pl[0].rev(), repo.changectx(node).rev()))
     return stats[3]
 
 def clean(repo, node, wlock=None, show_stats=True):
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/test-merge-local	Mon Dec 11 18:09:52 2006 +0100
@@ -0,0 +1,50 @@
+#!/bin/sh
+
+hg init
+
+echo "# revision 0"
+echo "unchanged" > unchanged
+echo "remove me" > remove
+echo "copy me" > copy
+echo "move me" > move
+for i in 1 2 3 4 5 6 7 8 9; do
+    echo "merge ok $i" >> zzz1_merge_ok
+done
+echo "merge bad" > zzz2_merge_bad
+hg ci -Am "revision 0" -d "1000000 0"
+
+echo "# revision 1"
+hg rm remove
+hg mv move moved
+hg cp copy copied
+echo "added" > added
+hg add added
+echo "new first line" > zzz1_merge_ok
+hg cat zzz1_merge_ok >> zzz1_merge_ok
+echo "new last line" >> zzz2_merge_bad
+hg ci -m "revision 1" -d "1000000 0"
+
+echo "# local changes to revision 0"
+hg co 0
+echo "new last line" >> zzz1_merge_ok
+echo "another last line" >> zzz2_merge_bad
+hg diff --nodates | grep "^[+-][^<>]"
+hg st
+
+echo "# local merge with bad merge tool"
+HGMERGE=false hg co
+hg co 0
+hg diff --nodates | grep "^[+-][^<>]"
+hg st
+
+echo "# local merge with conflicts"
+HGMERGE=merge hg co
+hg co 0
+hg diff --nodates | grep "^[+-][^<>]"
+hg st
+
+echo "# local merge without conflicts"
+hg revert zzz2_merge_bad
+HGMERGE=merge hg co
+hg diff --nodates | grep "^[+-][^<>]"
+hg st
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/test-merge-local.out	Mon Dec 11 18:09:52 2006 +0100
@@ -0,0 +1,67 @@
+# revision 0
+adding copy
+adding move
+adding remove
+adding unchanged
+adding zzz1_merge_ok
+adding zzz2_merge_bad
+# revision 1
+# local changes to revision 0
+4 files updated, 0 files merged, 3 files removed, 0 files unresolved
+--- a/zzz1_merge_ok
++++ b/zzz1_merge_ok
++new last line
+--- a/zzz2_merge_bad
++++ b/zzz2_merge_bad
++another last line
+M zzz1_merge_ok
+M zzz2_merge_bad
+# local merge with bad merge tool
+merging zzz1_merge_ok
+merging zzz1_merge_ok failed!
+merging zzz2_merge_bad
+merging zzz2_merge_bad failed!
+3 files updated, 0 files merged, 2 files removed, 2 files unresolved
+There are unresolved merges with locally modified files.
+You can redo the full merge using:
+  hg update 0
+  hg update 1
+2 files updated, 0 files merged, 3 files removed, 0 files unresolved
+--- a/zzz1_merge_ok
++++ b/zzz1_merge_ok
++new last line
+--- a/zzz2_merge_bad
++++ b/zzz2_merge_bad
++another last line
+M zzz1_merge_ok
+M zzz2_merge_bad
+# local merge with conflicts
+merge: warning: conflicts during merge
+merging zzz1_merge_ok
+merging zzz2_merge_bad
+merging zzz2_merge_bad failed!
+3 files updated, 1 files merged, 2 files removed, 1 files unresolved
+There are unresolved merges with locally modified files.
+You can finish the partial merge using:
+  hg update 0
+  hg update 1
+2 files updated, 0 files merged, 3 files removed, 0 files unresolved
+--- a/zzz1_merge_ok
++++ b/zzz1_merge_ok
++new first line
++new last line
+--- a/zzz2_merge_bad
++++ b/zzz2_merge_bad
++another last line
++=======
++new last line
+M zzz1_merge_ok
+M zzz2_merge_bad
+# local merge without conflicts
+merging zzz1_merge_ok
+4 files updated, 1 files merged, 2 files removed, 0 files unresolved
+--- a/zzz1_merge_ok
++++ b/zzz1_merge_ok
++new last line
+M zzz1_merge_ok
+? zzz2_merge_bad.orig
--- a/tests/test-merge-revert2.out	Mon Dec 11 14:30:50 2006 +0100
+++ b/tests/test-merge-revert2.out	Mon Dec 11 18:09:52 2006 +0100
@@ -14,6 +14,9 @@
 merging file1 failed!
 0 files updated, 0 files merged, 0 files removed, 1 files unresolved
 There are unresolved merges with locally modified files.
+You can redo the full merge using:
+  hg update 0
+  hg update 1
 diff -r f248da0d4c3e file1
 --- a/file1
 +++ b/file1