[Request] [+-- ] D8669: graft: leverage cmdutil.check_incompatible_arguments() for --abort/--stop

martinvonz (Martin von Zweigbergk) phabricator at mercurial-scm.org
Thu Jun 25 22:58:24 UTC 2020


martinvonz created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REPOSITORY
  rHG Mercurial

BRANCH
  default

REVISION DETAIL
  https://phab.mercurial-scm.org/D8669

AFFECTED FILES
  mercurial/commands.py
  tests/test-graft-interrupted.t

CHANGE DETAILS

diff --git a/tests/test-graft-interrupted.t b/tests/test-graft-interrupted.t
--- a/tests/test-graft-interrupted.t
+++ b/tests/test-graft-interrupted.t
@@ -253,13 +253,13 @@
   [255]
 
   $ hg graft --stop -U
-  abort: cannot specify any other flag with '--stop'
+  abort: cannot specify both --stop and --user
   [255]
   $ hg graft --stop --rev 4
-  abort: cannot specify any other flag with '--stop'
+  abort: cannot specify both --stop and --rev
   [255]
   $ hg graft --stop --log
-  abort: cannot specify any other flag with '--stop'
+  abort: cannot specify both --stop and --log
   [255]
 
   $ hg graft --stop
@@ -363,11 +363,11 @@
   [255]
 
   $ hg graft --abort --currentuser
-  abort: cannot specify any other flag with '--abort'
+  abort: cannot specify both --abort and --user
   [255]
 
   $ hg graft --abort --edit
-  abort: cannot specify any other flag with '--abort'
+  abort: cannot specify both --abort and --edit
   [255]
 
 #if abortcommand
diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -2995,35 +2995,32 @@
     graftstate = statemod.cmdstate(repo, b'graftstate')
 
     if opts.get(b'stop'):
-        if any(
-            (
-                opts.get(b'edit'),
-                opts.get(b'log'),
-                opts.get(b'user'),
-                opts.get(b'date'),
-                opts.get(b'currentdate'),
-                opts.get(b'currentuser'),
-                opts.get(b'rev'),
-            )
-        ):
-            raise error.Abort(_(b"cannot specify any other flag with '--stop'"))
+        cmdutil.check_incompatible_arguments(
+            opts,
+            b'stop',
+            [
+                b'edit',
+                b'log',
+                b'user',
+                b'date',
+                b'currentdate' b'currentuser',
+                b'rev',
+            ],
+        )
         return _stopgraft(ui, repo, graftstate)
     elif opts.get(b'abort'):
-        if any(
-            (
-                opts.get(b'edit'),
-                opts.get(b'log'),
-                opts.get(b'user'),
-                opts.get(b'date'),
-                opts.get(b'currentdate'),
-                opts.get(b'currentuser'),
-                opts.get(b'rev'),
-            )
-        ):
-            raise error.Abort(
-                _(b"cannot specify any other flag with '--abort'")
-            )
-
+        cmdutil.check_incompatible_arguments(
+            opts,
+            b'abort',
+            [
+                b'edit',
+                b'log',
+                b'user',
+                b'date',
+                b'currentdate' b'currentuser',
+                b'rev',
+            ],
+        )
         return cmdutil.abortgraft(ui, repo, graftstate)
     elif opts.get(b'continue'):
         cont = True



To: martinvonz, #hg-reviewers
Cc: mercurial-patches, mercurial-devel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mercurial-scm.org/pipermail/mercurial-patches/attachments/20200625/c24e3524/attachment-0001.html>


More information about the Mercurial-patches mailing list