cmdutil: change check_incompatible_arguments() *arg to single iterable
This makes it clearer on the call-sites that the first argument is
special. Thanks to Yuya for the suggestion.
Differential Revision: https://phab.mercurial-scm.org/D8018
--- a/hgext/rebase.py Mon Jan 27 12:38:59 2020 -0800
+++ b/hgext/rebase.py Mon Jan 27 09:14:19 2020 -0800
@@ -1011,10 +1011,10 @@
action = cmdutil.check_at_most_one_arg(opts, b'abort', b'stop', b'continue')
if action:
cmdutil.check_incompatible_arguments(
- opts, action, b'confirm', b'dry_run'
+ opts, action, [b'confirm', b'dry_run']
)
cmdutil.check_incompatible_arguments(
- opts, action, b'rev', b'source', b'base', b'dest'
+ opts, action, [b'rev', b'source', b'base', b'dest']
)
cmdutil.check_at_most_one_arg(opts, b'confirm', b'dry_run')
cmdutil.check_at_most_one_arg(opts, b'rev', b'source', b'base')
@@ -1028,7 +1028,7 @@
if opts.get(b'auto_orphans'):
disallowed_opts = set(opts) - {b'auto_orphans'}
cmdutil.check_incompatible_arguments(
- opts, b'auto_orphans', *disallowed_opts
+ opts, b'auto_orphans', disallowed_opts
)
userrevs = list(repo.revs(opts.get(b'auto_orphans')))
--- a/hgext/releasenotes.py Mon Jan 27 12:38:59 2020 -0800
+++ b/hgext/releasenotes.py Mon Jan 27 09:14:19 2020 -0800
@@ -654,7 +654,7 @@
opts = pycompat.byteskwargs(opts)
sections = releasenotessections(ui, repo)
- cmdutil.check_incompatible_arguments(opts, b'list', b'rev', b'check')
+ cmdutil.check_incompatible_arguments(opts, b'list', [b'rev', b'check'])
if opts.get(b'list'):
return _getadmonitionlist(ui, sections)
--- a/hgext/transplant.py Mon Jan 27 12:38:59 2020 -0800
+++ b/hgext/transplant.py Mon Jan 27 09:14:19 2020 -0800
@@ -761,12 +761,12 @@
def checkopts(opts, revs):
if opts.get(b'continue'):
cmdutil.check_incompatible_arguments(
- opts, b'continue', b'branch', b'all', b'merge'
+ opts, b'continue', [b'branch', b'all', b'merge']
)
return
if opts.get(b'stop'):
cmdutil.check_incompatible_arguments(
- opts, b'stop', b'branch', b'all', b'merge'
+ opts, b'stop', [b'branch', b'all', b'merge']
)
return
if not (
--- a/mercurial/cmdutil.py Mon Jan 27 12:38:59 2020 -0800
+++ b/mercurial/cmdutil.py Mon Jan 27 09:14:19 2020 -0800
@@ -281,11 +281,11 @@
return previous
-def check_incompatible_arguments(opts, first, *others):
+def check_incompatible_arguments(opts, first, others):
"""abort if the first argument is given along with any of the others
Unlike check_at_most_one_arg(), `others` are not mutually exclusive
- among themselves.
+ among themselves, and they're passed as a single collection.
"""
for other in others:
check_at_most_one_arg(opts, first, other)
--- a/mercurial/commands.py Mon Jan 27 12:38:59 2020 -0800
+++ b/mercurial/commands.py Mon Jan 27 09:14:19 2020 -0800
@@ -1228,7 +1228,7 @@
action = cmdutil.check_at_most_one_arg(opts, b'delete', b'rename', b'list')
if action:
- cmdutil.check_incompatible_arguments(opts, action, b'rev')
+ cmdutil.check_incompatible_arguments(opts, action, [b'rev'])
elif names or rev:
action = b'add'
elif inactive:
@@ -1236,7 +1236,9 @@
else:
action = b'list'
- cmdutil.check_incompatible_arguments(opts, b'inactive', b'delete', b'list')
+ cmdutil.check_incompatible_arguments(
+ opts, b'inactive', [b'delete', b'list']
+ )
if not names and action in {b'add', b'delete'}:
raise error.Abort(_(b"bookmark name required"))
@@ -4847,7 +4849,7 @@
abort = opts.get(b'abort')
if abort and repo.dirstate.p2() == nullid:
cmdutil.wrongtooltocontinue(repo, _(b'merge'))
- cmdutil.check_incompatible_arguments(opts, b'abort', b'rev', b'preview')
+ cmdutil.check_incompatible_arguments(opts, b'abort', [b'rev', b'preview'])
if abort:
state = cmdutil.getunfinishedstate(repo)
if state and state._opname != b'merge':
--- a/relnotes/next Mon Jan 27 12:38:59 2020 -0800
+++ b/relnotes/next Mon Jan 27 09:14:19 2020 -0800
@@ -17,3 +17,6 @@
* `hg.merge()` has lost its `abort` argument. Please call
`hg.abortmerge()` directly instead.
+
+ * The `*others` argument of `cmdutil.check_incompatible_arguments()`
+ changed from being varargs argument to being a single collection.