resolve: support confirm config option with --unmark flag
authorSushil khanchi <sushilkhanchi97@gmail.com>
Sat, 04 Aug 2018 12:43:41 +0530
changeset 38874 f35f6791595f
parent 38873 7e75777e4a51
child 38875 755741c39230
resolve: support confirm config option with --unmark flag Now, commands.resolve.confirm also respect --unmark option; and confirm to unresolve all resolved files. It will confirm only when no files pats are passed (same as --mark), because when no pats are passed the default is to mark resolved files as unresolved. And if user has passed file pats then I think there is no need to confirm for that. Differential Revision: https://phab.mercurial-scm.org/D4102
mercurial/commands.py
tests/test-resolve.t
--- a/mercurial/commands.py	Sun Aug 05 00:53:55 2018 -0700
+++ b/mercurial/commands.py	Sat Aug 04 12:43:41 2018 +0530
@@ -4546,10 +4546,15 @@
     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 unmark and confirm and not pats:
+        if ui.promptchoice(_(b'mark all resolved files as unresolved (yn)?'
+                             b'$$ &Yes $$ &No')):
+            raise error.Abort(_('user quit'))
 
     if show:
         ui.pager('resolve')
--- a/tests/test-resolve.t	Sun Aug 05 00:53:55 2018 -0700
+++ b/tests/test-resolve.t	Sat Aug 04 12:43:41 2018 +0530
@@ -557,6 +557,35 @@
   R emp2
   R emp3
 
+Test that commands.resolve.confirm respect --unmark option (only when no patterns args are given):
+===============================================================================================
+
+  $ hg resolve -u emp1
+
+  $ hg resolve -l
+  U emp1
+  R emp2
+  R emp3
+
+  $ hg resolve -u << EOF
+  > n
+  > EOF
+  mark all resolved files as unresolved (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 ..