Patchwork D7647: bookmarks: use cmdutil.check_at_most_one_arg() for action

login
register
mail settings
Submitter phabricator
Date Dec. 16, 2019, 11:21 p.m.
Message ID <c5801fe9550a64b9b93550ec297fa14c@localhost.localdomain>
Download mbox | patch
Permalink /patch/43885/
State Not Applicable
Headers show

Comments

phabricator - Dec. 16, 2019, 11:21 p.m.
martinvonz retitled this revision from "bookmarks: use cmdutil.check_unique_argument() for action" to "bookmarks: use cmdutil.check_at_most_one_arg() for action".
martinvonz updated this revision to Diff 18774.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D7647?vs=18682&id=18774

BRANCH
  default

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D7647/new/

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

AFFECTED FILES
  mercurial/commands.py
  tests/test-bookmarks.t

CHANGE DETAILS




To: martinvonz, #hg-reviewers
Cc: mercurial-devel

Patch

diff --git a/tests/test-bookmarks.t b/tests/test-bookmarks.t
--- a/tests/test-bookmarks.t
+++ b/tests/test-bookmarks.t
@@ -475,7 +475,7 @@ 
   $ cd repo
 
   $ hg bookmark -m Y -d Z
-  abort: --delete and --rename are incompatible
+  abort: cannot specify both --delete and --rename
   [255]
 
   $ hg bookmark -r 1 -d Z
diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -1226,13 +1226,9 @@ 
     rev = opts.get(b'rev')
     inactive = opts.get(b'inactive')  # meaning add/rename to inactive bookmark
 
-    selactions = [k for k in [b'delete', b'rename', b'list'] if opts.get(k)]
-    if len(selactions) > 1:
-        raise error.Abort(
-            _(b'--%s and --%s are incompatible') % tuple(selactions[:2])
-        )
-    if selactions:
-        action = selactions[0]
+    action = cmdutil.check_at_most_one_arg(opts, b'delete', b'rename', b'list')
+    if action:
+        pass
     elif names or rev:
         action = b'add'
     elif inactive: