Patchwork [2,of,5] rebase: consolidate check for --abort/--stop/--continue conflicts

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

Comments

Yuya Nishihara - Aug. 15, 2018, 2:06 a.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1534296966 -32400
#      Wed Aug 15 10:36:06 2018 +0900
# Node ID 7e9c0c5ff2eabf69ec4392c8110dc4f094fc9013
# Parent  c1a1fb389b4dda254ae5d7af56a9b11de0c5e288
rebase: consolidate check for --abort/--stop/--continue conflicts

Patch

diff --git a/hgext/rebase.py b/hgext/rebase.py
--- a/hgext/rebase.py
+++ b/hgext/rebase.py
@@ -807,12 +807,14 @@  def rebase(ui, repo, **opts):
     dryrun = opts.get('dry_run')
     confirm = opts.get('confirm')
     stop = opts.get('stop')
+    selactions = [k for k in ['abort', 'stop', 'continue'] if opts.get(k)]
+    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 opts.get('abort') or opts.get('continue'):
-            raise error.Abort(_('cannot use --stop with --abort or --continue'))
     if dryrun:
         if opts.get('abort'):
             raise error.Abort(_('cannot specify both --dry-run and --abort'))
@@ -950,8 +952,6 @@  def _origrebase(ui, repo, opts, rbsrt, i
                 _('message can only be specified with collapse'))
 
         if contf or abortf:
-            if contf and abortf:
-                raise error.Abort(_('cannot use both abort and continue'))
             if rbsrt.collapsef:
                 raise error.Abort(
                     _('cannot use collapse with continue or abort'))
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
@@ -2020,7 +2020,7 @@  Test --stop raise errors with conflictin
   (use 'hg rebase --continue' or 'hg rebase --abort')
   [255]
   $ hg rebase --stop --continue
-  abort: cannot use --stop with --abort or --continue
+  abort: cannot use --stop with --continue
   [255]
 
 Test --stop moves bookmarks of original revisions to new rebased nodes:
diff --git a/tests/test-rebase-parameters.t b/tests/test-rebase-parameters.t
--- a/tests/test-rebase-parameters.t
+++ b/tests/test-rebase-parameters.t
@@ -61,7 +61,7 @@  These fail:
   [1]
 
   $ hg rebase --continue --abort
-  abort: cannot use both abort and continue
+  abort: cannot use --abort with --continue
   [255]
 
   $ hg rebase --continue --collapse