Mercurial > public > mercurial-scm > hg
comparison mercurial/commands.py @ 44194:d4c1501225c4
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
author | Martin von Zweigbergk <martinvonz@google.com> |
---|---|
date | Mon, 27 Jan 2020 09:14:19 -0800 |
parents | 293cab97a766 |
children | 15eb90965a00 |
comparison
equal
deleted
inserted
replaced
44193:3c265cef6edc | 44194:d4c1501225c4 |
---|---|
1226 rev = opts.get(b'rev') | 1226 rev = opts.get(b'rev') |
1227 inactive = opts.get(b'inactive') # meaning add/rename to inactive bookmark | 1227 inactive = opts.get(b'inactive') # meaning add/rename to inactive bookmark |
1228 | 1228 |
1229 action = cmdutil.check_at_most_one_arg(opts, b'delete', b'rename', b'list') | 1229 action = cmdutil.check_at_most_one_arg(opts, b'delete', b'rename', b'list') |
1230 if action: | 1230 if action: |
1231 cmdutil.check_incompatible_arguments(opts, action, b'rev') | 1231 cmdutil.check_incompatible_arguments(opts, action, [b'rev']) |
1232 elif names or rev: | 1232 elif names or rev: |
1233 action = b'add' | 1233 action = b'add' |
1234 elif inactive: | 1234 elif inactive: |
1235 action = b'inactive' # meaning deactivate | 1235 action = b'inactive' # meaning deactivate |
1236 else: | 1236 else: |
1237 action = b'list' | 1237 action = b'list' |
1238 | 1238 |
1239 cmdutil.check_incompatible_arguments(opts, b'inactive', b'delete', b'list') | 1239 cmdutil.check_incompatible_arguments( |
1240 opts, b'inactive', [b'delete', b'list'] | |
1241 ) | |
1240 if not names and action in {b'add', b'delete'}: | 1242 if not names and action in {b'add', b'delete'}: |
1241 raise error.Abort(_(b"bookmark name required")) | 1243 raise error.Abort(_(b"bookmark name required")) |
1242 | 1244 |
1243 if action in {b'add', b'delete', b'rename', b'inactive'}: | 1245 if action in {b'add', b'delete', b'rename', b'inactive'}: |
1244 with repo.wlock(), repo.lock(), repo.transaction(b'bookmark') as tr: | 1246 with repo.wlock(), repo.lock(), repo.transaction(b'bookmark') as tr: |
4845 | 4847 |
4846 opts = pycompat.byteskwargs(opts) | 4848 opts = pycompat.byteskwargs(opts) |
4847 abort = opts.get(b'abort') | 4849 abort = opts.get(b'abort') |
4848 if abort and repo.dirstate.p2() == nullid: | 4850 if abort and repo.dirstate.p2() == nullid: |
4849 cmdutil.wrongtooltocontinue(repo, _(b'merge')) | 4851 cmdutil.wrongtooltocontinue(repo, _(b'merge')) |
4850 cmdutil.check_incompatible_arguments(opts, b'abort', b'rev', b'preview') | 4852 cmdutil.check_incompatible_arguments(opts, b'abort', [b'rev', b'preview']) |
4851 if abort: | 4853 if abort: |
4852 state = cmdutil.getunfinishedstate(repo) | 4854 state = cmdutil.getunfinishedstate(repo) |
4853 if state and state._opname != b'merge': | 4855 if state and state._opname != b'merge': |
4854 raise error.Abort( | 4856 raise error.Abort( |
4855 _(b'cannot abort merge with %s in progress') % (state._opname), | 4857 _(b'cannot abort merge with %s in progress') % (state._opname), |