changeset 39099:3f9a5d746cf6

rebase: consolidate check for --dry-run/--confirm on abort/stop/continue
author Yuya Nishihara <yuya@tcha.org>
date Wed, 15 Aug 2018 10:41:26 +0900
parents a42506059522
children e9e742bd0501
files hgext/rebase.py tests/test-rebase-obsolete.t
diffstat 2 files changed, 8 insertions(+), 17 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/rebase.py	Wed Aug 15 10:36:06 2018 +0900
+++ b/hgext/rebase.py	Wed Aug 15 10:41:26 2018 +0900
@@ -811,22 +811,13 @@
     if len(selactions) > 1:
         raise error.Abort(_('cannot use --%s with --%s')
                           % tuple(selactions[:2]))
-    if stop:
-        if opts.get('dry_run') or opts.get('confirm'):
-            raise error.Abort(_('cannot use --stop with --dry-run '
-                                'or --confirm'))
-    if dryrun:
-        if opts.get('abort'):
-            raise error.Abort(_('cannot specify both --dry-run and --abort'))
-        if opts.get('continue'):
-            raise error.Abort(_('cannot specify both --dry-run and --continue'))
-    if confirm:
-        if opts.get('dry_run'):
-            raise error.Abort(_('cannot specify both --confirm and --dry-run'))
-        if opts.get('abort'):
-            raise error.Abort(_('cannot specify both --confirm and --abort'))
-        if opts.get('continue'):
-            raise error.Abort(_('cannot specify both --confirm and --continue'))
+    action = selactions[0] if selactions else None
+    if dryrun and action:
+        raise error.Abort(_('cannot specify both --dry-run and --%s') % action)
+    if confirm and action:
+        raise error.Abort(_('cannot specify both --confirm and --%s') % action)
+    if dryrun and confirm:
+        raise error.Abort(_('cannot specify both --confirm and --dry-run'))
 
     if (opts.get('continue') or opts.get('abort') or
         repo.currenttransaction() is not None):
--- a/tests/test-rebase-obsolete.t	Wed Aug 15 10:36:06 2018 +0900
+++ b/tests/test-rebase-obsolete.t	Wed Aug 15 10:41:26 2018 +0900
@@ -2012,7 +2012,7 @@
   unresolved conflicts (see hg resolve, then hg rebase --continue)
   [1]
   $ hg rebase --stop --dry-run
-  abort: cannot use --stop with --dry-run or --confirm
+  abort: cannot specify both --dry-run and --stop
   [255]
 
   $ hg rebase -s 3 -d 5