changeset 26621:36383507a6f8

resolve: perform all premerges before performing any file merges (BC) Just like the BC to merge before it, this allows for a maximally consistent state before providing any prompts to the user.
author Siddharth Agarwal <sid0@fb.com>
date Sun, 11 Oct 2015 23:58:07 -0700
parents 7955127efbcb
children 9e15286609ae
files mercurial/commands.py tests/test-resolve.t
diffstat 2 files changed, 19 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/commands.py	Sun Oct 11 23:56:44 2015 -0700
+++ b/mercurial/commands.py	Sun Oct 11 23:58:07 2015 -0700
@@ -5568,6 +5568,7 @@
         ret = 0
         didwork = False
 
+        tocomplete = []
         for f in ms:
             if not m(f):
                 continue
@@ -5586,21 +5587,35 @@
                 util.copyfile(a, a + ".resolve")
 
                 try:
-                    # resolve file
+                    # preresolve file
                     ui.setconfig('ui', 'forcemerge', opts.get('tool', ''),
                                  'resolve')
                     complete, r = ms.preresolve(f, wctx)
                     if not complete:
-                        r = ms.resolve(f, wctx)
-                    if r:
+                        tocomplete.append(f)
+                    elif r:
                         ret = 1
                 finally:
                     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")
 
+        for f in tocomplete:
+            try:
+                # resolve file
+                ui.setconfig('ui', 'forcemerge', opts.get('tool', ''),
+                             'resolve')
+                r = ms.resolve(f, wctx)
+                if r:
+                    ret = 1
+            finally:
+                ui.setconfig('ui', 'forcemerge', '', 'resolve')
+                ms.commit()
+
         ms.commit()
 
         if not didwork and pats:
--- a/tests/test-resolve.t	Sun Oct 11 23:56:44 2015 -0700
+++ b/tests/test-resolve.t	Sun Oct 11 23:58:07 2015 -0700
@@ -135,8 +135,8 @@
 resolve --all should re-merge all unresolved files
   $ hg resolve --all
   merging file1
+  merging file2
   warning: conflicts while merging file1! (edit, then use 'hg resolve --mark')
-  merging file2
   warning: conflicts while merging file2! (edit, then use 'hg resolve --mark')
   [1]
   $ cat file1.orig