merge: delay prompts a bit and show them in (extra) sorted order
authorMads Kiilerich <madski@unity3d.com>
Thu, 24 Jan 2013 23:57:44 +0100
changeset 18539 cf25e4efd685
parent 18538 94317c2d53b8
child 18540 139529b0a191
merge: delay prompts a bit and show them in (extra) sorted order Preparing for backout of 760c0d67ce5e. The number of prompts will for all relevant cases be significantly smaller than the total number of files in the manifests. We can thus afford to sort the prompts more than we can afford to sort the manifests.
mercurial/merge.py
tests/test-rename-merge2.t
--- a/mercurial/merge.py	Sat Feb 02 15:37:17 2013 -0200
+++ b/mercurial/merge.py	Thu Jan 24 23:57:44 2013 +0100
@@ -227,6 +227,7 @@
                 m1['.hgsubstate'] += "+"
                 break
 
+    prompts = []
     # Compare manifests
     visit = m1.iteritems()
     if repo.ui.debugflag:
@@ -265,13 +266,7 @@
             act("local copied/moved to " + f2, "m", f, f2, f, False)
         elif f in ma: # clean, a different, no remote
             if n != ma[f]:
-                if repo.ui.promptchoice(
-                    _(" local changed %s which remote deleted\n"
-                      "use (c)hanged version or (d)elete?") % f,
-                    (_("&Changed"), _("&Delete")), 0):
-                    act("prompt delete", "r", f)
-                else:
-                    act("prompt keep", "a", f)
+                prompts.append((f, "cd")) # prompt changed/deleted
             elif n[20:] == "a": # added, no remote
                 act("remote deleted", "f", f)
             else:
@@ -305,12 +300,24 @@
             else:
                 act("remote created", "g", f, m2.flags(f))
         elif n != ma[f]:
+            prompts.append((f, "dc")) # prompt deleted/changed
+
+    for f, m in sorted(prompts):
+        if m == "cd":
+            if repo.ui.promptchoice(
+                _(" local changed %s which remote deleted\n"
+                  "use (c)hanged version or (d)elete?") % f,
+                (_("&Changed"), _("&Delete")), 0):
+                act("prompt delete", "r", f)
+            else:
+                act("prompt keep", "a", f)
+        elif m == "dc":
             if repo.ui.promptchoice(
                 _("remote changed %s which local deleted\n"
                   "use (c)hanged version or leave (d)eleted?") % f,
                 (_("&Changed"), _("&Deleted")), 0) == 0:
                 act("prompt recreating", "g", f, m2.flags(f))
-
+        else: assert False, m
     return actions
 
 def actionkey(a):
--- a/tests/test-rename-merge2.t	Sat Feb 02 15:37:17 2013 -0200
+++ b/tests/test-rename-merge2.t	Thu Jan 24 23:57:44 2013 +0100
@@ -617,11 +617,11 @@
   resolving manifests
    overwrite: False, partial: False
    ancestor: 924404dff337, local: 0b76e65c8289+, remote: bdb19105162a
+   b: versions differ -> m
+   rev: versions differ -> m
    local changed a which remote deleted
   use (c)hanged version or (d)elete? c
    a: prompt keep -> a
-   b: versions differ -> m
-   rev: versions differ -> m
   preserving b for resolve of b
   preserving rev for resolve of rev
   updating: a 1/3 files (33.33%)