rebase: consolidate check for --dry-run/--confirm on abort/stop/continue
authorYuya Nishihara <yuya@tcha.org>
Wed, 15 Aug 2018 10:41:26 +0900
changeset 39099 3f9a5d746cf6
parent 39098 a42506059522
child 39100 e9e742bd0501
rebase: consolidate check for --dry-run/--confirm on abort/stop/continue
hgext/rebase.py
tests/test-rebase-obsolete.t
--- 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