Patchwork [2,of,4,mergedriver] filemerge: add a 'leave unresolved' option to regular prompts

login
register
mail settings
Submitter Siddharth Agarwal
Date Dec. 1, 2015, 5:57 p.m.
Message ID <2d05f064d2e6fb76f91b.1448992663@dev666.prn1.facebook.com>
Download mbox | patch
Permalink /patch/11712/
State Accepted
Headers show

Comments

Siddharth Agarwal - Dec. 1, 2015, 5:57 p.m.
# HG changeset patch
# User Siddharth Agarwal <sid0@fb.com>
# Date 1448911038 28800
#      Mon Nov 30 11:17:18 2015 -0800
# Node ID 2d05f064d2e6fb76f91b4efef37eab7cb3e08d3b
# Parent  7cdbfb26cf01159866d692adc0f391e93511d1e7
# Available At http://42.netv6.net/sid0-wip/hg/
#              hg pull http://42.netv6.net/sid0-wip/hg/ -r 2d05f064d2e6
filemerge: add a 'leave unresolved' option to regular prompts

'Regular' here means anything that isn't a change/delete prompt. We'll add this
option to change/delete prompts in a subsequent patch.

Patch

diff --git a/mercurial/filemerge.py b/mercurial/filemerge.py
--- a/mercurial/filemerge.py
+++ b/mercurial/filemerge.py
@@ -249,15 +249,18 @@  def _iprompt(repo, mynode, orig, fcd, fc
                   "$$ &Changed $$ &Deleted") % fd, 0)
             choice = ['other', 'local'][index]
         else:
-            index = ui.promptchoice(_("no tool found to merge %s\n"
-                                      "keep (l)ocal or take (o)ther?"
-                                      "$$ &Local $$ &Other") % fd, 0)
-            choice = ['local', 'other'][index]
+            index = ui.promptchoice(
+                _("no tool found to merge %s\n"
+                  "keep (l)ocal, take (o)ther, or leave (u)nresolved?"
+                  "$$ &Local $$ &Other $$ &Unresolved") % fd, 0)
+            choice = ['local', 'other', 'unresolved'][index]
 
         if choice == 'other':
             return _iother(repo, mynode, orig, fcd, fco, fca, toolconf)
-        else:
+        elif choice == 'local':
             return _ilocal(repo, mynode, orig, fcd, fco, fca, toolconf)
+        elif choice == 'unresolved':
+            return _ifail(repo, mynode, orig, fcd, fco, fca, toolconf)
     except error.ResponseExpected:
         ui.write("\n")
         return _ifail(repo, mynode, orig, fcd, fco, fca, toolconf)
diff --git a/tests/test-merge-changedelete.t b/tests/test-merge-changedelete.t
--- a/tests/test-merge-changedelete.t
+++ b/tests/test-merge-changedelete.t
@@ -422,7 +422,7 @@  Force prompts with no input (should be s
   remote changed file2 which local deleted
   use (c)hanged version or leave (d)eleted? 
   no tool found to merge file3
-  keep (l)ocal or take (o)ther? 
+  keep (l)ocal, take (o)ther, or leave (u)nresolved? 
   0 files updated, 0 files merged, 0 files removed, 3 files unresolved
   use 'hg resolve' to retry unresolved file merges or 'hg update -C .' to abandon
   [1]
@@ -474,7 +474,7 @@  Force prompts
   remote changed file2 which local deleted
   use (c)hanged version or leave (d)eleted? c
   no tool found to merge file3
-  keep (l)ocal or take (o)ther? l
+  keep (l)ocal, take (o)ther, or leave (u)nresolved? l
   0 files updated, 3 files merged, 0 files removed, 0 files unresolved
   (branch merge, don't forget to commit)
   $ status
@@ -607,7 +607,7 @@  invocations.)
   remote changed file2 which local deleted
   use (c)hanged version or leave (d)eleted? 
   no tool found to merge file3
-  keep (l)ocal or take (o)ther? 
+  keep (l)ocal, take (o)ther, or leave (u)nresolved? 
   --- diff of status ---
   (status identical)
   
@@ -636,7 +636,7 @@  invocations.)
   remote changed file2 which local deleted
   use (c)hanged version or leave (d)eleted? 
   no tool found to merge file3
-  keep (l)ocal or take (o)ther? 
+  keep (l)ocal, take (o)ther, or leave (u)nresolved? 
   --- diff of status ---
   (status identical)
   
@@ -655,7 +655,7 @@  invocations.)
   remote changed file2 which local deleted
   use (c)hanged version or leave (d)eleted? 
   no tool found to merge file3
-  keep (l)ocal or take (o)ther? 
+  keep (l)ocal, take (o)ther, or leave (u)nresolved? 
   --- diff of status ---
   (status identical)
   
diff --git a/tests/test-merge-tools.t b/tests/test-merge-tools.t
--- a/tests/test-merge-tools.t
+++ b/tests/test-merge-tools.t
@@ -532,7 +532,7 @@  ui.merge specifies internal:prompt:
   # hg update -C 1
   $ hg merge -r 2 --config ui.merge=internal:prompt
   no tool found to merge f
-  keep (l)ocal or take (o)ther? l
+  keep (l)ocal, take (o)ther, or leave (u)nresolved? l
   0 files updated, 1 files merged, 0 files removed, 0 files unresolved
   (branch merge, don't forget to commit)
   $ aftermerge
@@ -544,6 +544,31 @@  ui.merge specifies internal:prompt:
   # hg resolve --list
   R f
 
+ui.merge specifies :prompt, with 'leave unresolved' chosen
+
+  $ beforemerge
+  [merge-tools]
+  false.whatever=
+  true.priority=1
+  true.executable=cat
+  # hg update -C 1
+  $ hg merge -r 2 --config ui.merge=:prompt --config ui.interactive=True << EOF
+  > u
+  > EOF
+  no tool found to merge f
+  keep (l)ocal, take (o)ther, or leave (u)nresolved? u
+  0 files updated, 0 files merged, 0 files removed, 1 files unresolved
+  use 'hg resolve' to retry unresolved file merges or 'hg update -C .' to abandon
+  [1]
+  $ aftermerge
+  # cat f
+  revision 1
+  space
+  # hg stat
+  M f
+  # hg resolve --list
+  U f
+
 prompt with EOF
 
   $ beforemerge
@@ -554,7 +579,7 @@  prompt with EOF
   # hg update -C 1
   $ hg merge -r 2 --config ui.merge=internal:prompt --config ui.interactive=true
   no tool found to merge f
-  keep (l)ocal or take (o)ther? 
+  keep (l)ocal, take (o)ther, or leave (u)nresolved? 
   0 files updated, 0 files merged, 0 files removed, 1 files unresolved
   use 'hg resolve' to retry unresolved file merges or 'hg update -C .' to abandon
   [1]
@@ -568,7 +593,7 @@  prompt with EOF
   U f
   $ hg resolve --all --config ui.merge=internal:prompt --config ui.interactive=true
   no tool found to merge f
-  keep (l)ocal or take (o)ther? 
+  keep (l)ocal, take (o)ther, or leave (u)nresolved? 
   [1]
   $ aftermerge
   # cat f
@@ -582,7 +607,7 @@  prompt with EOF
   $ rm f
   $ hg resolve --all --config ui.merge=internal:prompt --config ui.interactive=true
   no tool found to merge f
-  keep (l)ocal or take (o)ther? 
+  keep (l)ocal, take (o)ther, or leave (u)nresolved? 
   [1]
   $ aftermerge
   # cat f
@@ -594,7 +619,7 @@  prompt with EOF
   U f
   $ hg resolve --all --config ui.merge=internal:prompt
   no tool found to merge f
-  keep (l)ocal or take (o)ther? l
+  keep (l)ocal, take (o)ther, or leave (u)nresolved? l
   (no more unresolved files)
   $ aftermerge
   # cat f
diff --git a/tests/test-merge-types.t b/tests/test-merge-types.t
--- a/tests/test-merge-types.t
+++ b/tests/test-merge-types.t
@@ -172,7 +172,7 @@  Update to link with local change should 
   (couldn't find merge tool hgmerge|tool hgmerge can't handle symlinks) (re)
   picked tool ':prompt' for a (binary False symlink True changedelete False)
   no tool found to merge a
-  keep (l)ocal or take (o)ther? l
+  keep (l)ocal, take (o)ther, or leave (u)nresolved? l
   0 files updated, 1 files merged, 0 files removed, 0 files unresolved
   $ hg diff --git
   diff --git a/a b/a