changeset 26959:ed5f20f9c22e stable

resolve: restore .orig only after merge is fully complete (issue4952) Previously, we'd restore the .orig file after the premerge is complete but before the merge was complete. This would lead to the .orig file potentially containing merge conflict markers in it, as a leftover from the last merge attempt.
author Siddharth Agarwal <sid0@fb.com>
date Fri, 13 Nov 2015 15:56:02 -0800
parents 8a256cee72c8
children 6979fe2a6d75
files mercurial/commands.py tests/test-resolve.t
diffstat 2 files changed, 32 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/commands.py	Thu Nov 12 13:16:04 2015 -0800
+++ b/mercurial/commands.py	Fri Nov 13 15:56:02 2015 -0800
@@ -5670,10 +5670,10 @@
                     ui.setconfig('ui', 'forcemerge', '', 'resolve')
                     ms.commit()
 
-                # replace filemerge's .orig file with our resolve file
-                # for files in tocomplete, ms.resolve will not overwrite
-                # .orig -- only preresolve does
-                util.rename(a + ".resolve", a + ".orig")
+                # replace filemerge's .orig file with our resolve file, but only
+                # for merges that are complete
+                if complete:
+                    util.rename(a + ".resolve", a + ".orig")
 
         for f in tocomplete:
             try:
@@ -5687,6 +5687,10 @@
                 ui.setconfig('ui', 'forcemerge', '', 'resolve')
                 ms.commit()
 
+            # replace filemerge's .orig file with our resolve file
+            a = repo.wjoin(f)
+            util.rename(a + ".resolve", a + ".orig")
+
         ms.commit()
 
         if not didwork and pats:
--- a/tests/test-resolve.t	Thu Nov 12 13:16:04 2015 -0800
+++ b/tests/test-resolve.t	Fri Nov 13 15:56:02 2015 -0800
@@ -207,6 +207,30 @@
   [1]
   $ grep '<<<' file1 > /dev/null
 
+test .orig behavior with resolve
+
+  $ echo resolve > file
+  $ hg resolve -q file1 --tool 'f --dump $TESTTMP/repo/file1.orig'
+  */file1~base*: (glob)
+  >>>
+  foo
+  <<<
+  */file1~other*: (glob)
+  >>>
+  foo
+  bar
+  <<<
+  $TESTTMP/repo/file1: (glob)
+  >>>
+  foo
+  baz
+  <<<
+  $TESTTMP/repo/file1.orig: (glob)
+  >>>
+  foo
+  baz
+  <<<
+
 resolve <file> should do nothing if 'file' was marked resolved
   $ echo resolved > file1
   $ hg resolve -m file1