changeset 38859:db03e5cefc82

resolve: support commands.resolve.confirm option with --mark flag Now, commands.resolve.confirm config option also respect --mark; and confirm to mark all 'unresolved' files as 'resolved'. It will confirm only when you don't pass any pats i.e 'hg resolve -m', because when no file pats are passed then --mark's default functionality is to mark all unresolved files. And if user has given file pats then I think there is no need to confirm. Differential Revision: https://phab.mercurial-scm.org/D4101
author Sushil khanchi <sushilkhanchi97@gmail.com>
date Sat, 04 Aug 2018 12:23:18 +0530
parents e9740c07158d
children 257c9846b532
files mercurial/commands.py tests/test-resolve.t
diffstat 2 files changed, 31 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/commands.py	Fri Aug 03 12:59:01 2018 -0700
+++ b/mercurial/commands.py	Sat Aug 04 12:23:18 2018 +0530
@@ -4546,6 +4546,10 @@
     if not (all or pats or show or mark or unmark):
         raise error.Abort(_('no files or directories specified'),
                          hint=('use --all to re-merge all unresolved files'))
+    if mark and confirm and not pats:
+        if ui.promptchoice(_(b'mark all unresolved files as resolved (yn)?'
+                             b'$$ &Yes $$ &No')):
+            raise error.Abort(_('user quit'))
 
     if show:
         ui.pager('resolve')
--- a/tests/test-resolve.t	Fri Aug 03 12:59:01 2018 -0700
+++ b/tests/test-resolve.t	Sat Aug 04 12:23:18 2018 +0530
@@ -509,6 +509,33 @@
   warning: conflicts while merging emp3! (edit, then use 'hg resolve --mark')
   [1]
 
+Test that commands.resolve.confirm respect --mark option (only when no patterns args are given):
+===============================================================================================
+
+  $ hg resolve -m emp1
+  $ hg resolve -l
+  R emp1
+  U emp2
+  U emp3
+
+  $ hg resolve -m << EOF
+  > n
+  > EOF
+  mark all unresolved files as resolved (yn)? n
+  abort: user quit
+  [255]
+
+  $ hg resolve -m << EOF
+  > y
+  > EOF
+  mark all unresolved files as resolved (yn)? y
+  (no more unresolved files)
+  continue: hg rebase --continue
+  $ hg resolve -l
+  R emp1
+  R emp2
+  R emp3
+
   $ hg rebase --abort
   rebase aborted
   $ cd ..