Patchwork [3,of,5] rebase: consolidate check for --dry-run/--confirm on abort/stop/continue

login
register
mail settings
Submitter Yuya Nishihara
Date Aug. 15, 2018, 2:06 a.m.
Message ID <b0d79161af9f7e55b6a8.1534298790@mimosa>
Download mbox | patch
Permalink /patch/33738/
State Accepted
Headers show

Comments

Yuya Nishihara - Aug. 15, 2018, 2:06 a.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1534297286 -32400
#      Wed Aug 15 10:41:26 2018 +0900
# Node ID b0d79161af9f7e55b6a83675940eb3cf7eb0f0a8
# Parent  7e9c0c5ff2eabf69ec4392c8110dc4f094fc9013
rebase: consolidate check for --dry-run/--confirm on abort/stop/continue

Patch

diff --git a/hgext/rebase.py b/hgext/rebase.py
--- a/hgext/rebase.py
+++ b/hgext/rebase.py
@@ -811,22 +811,13 @@  def rebase(ui, repo, **opts):
     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):
diff --git a/tests/test-rebase-obsolete.t b/tests/test-rebase-obsolete.t
--- a/tests/test-rebase-obsolete.t
+++ b/tests/test-rebase-obsolete.t
@@ -2012,7 +2012,7 @@  Test --stop raise errors with conflictin
   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