mercurial/commands.py
changeset 26621 36383507a6f8
parent 26617 dfd9811c5c9b
child 26628 45b86dbabbda
--- 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: