Patchwork [1,of,6] merge: delay prompts a bit and show them in (extra) sorted order

login
register
mail settings
Submitter Mads Kiilerich
Date Jan. 20, 2013, 1:18 p.m.
Message ID <8bf1218094bea9c7c0fd.1358687884@localhost6.localdomain6>
Download mbox | patch
Permalink /patch/687/
State Superseded
Commit 26627c30735a610f59979a36885b327b25d8dbff
Headers show

Comments

Mads Kiilerich - Jan. 20, 2013, 1:18 p.m.
# HG changeset patch
# User Mads Kiilerich <mads@kiilerich.com>
# Date 1358687872 -3600
# Branch stable
# Node ID 8bf1218094bea9c7c0fd8f4d1187db131ad04cb4
# Parent  28aaa24dc36b10568d114fa2faa5a3bcdd9f0aa3
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.

Patch

diff --git a/mercurial/merge.py b/mercurial/merge.py
--- a/mercurial/merge.py
+++ b/mercurial/merge.py
@@ -227,6 +227,7 @@  def manifestmerge(repo, p1, p2, pa, over
                 m1['.hgsubstate'] += "+"
                 break
 
+    prompts = []
     # Compare manifests
     for f, n in sorted(m1.iteritems()):
         if partial and not partial(f):
@@ -262,13 +263,7 @@  def manifestmerge(repo, p1, p2, pa, over
             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:
@@ -299,12 +294,24 @@  def manifestmerge(repo, p1, p2, pa, over
             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):
diff --git a/tests/test-rename-merge2.t b/tests/test-rename-merge2.t
--- a/tests/test-rename-merge2.t
+++ b/tests/test-rename-merge2.t
@@ -617,11 +617,11 @@  m "um a c" "um x c" "      " "10 do merg
   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%)