Mercurial > public > mercurial-scm > hg-stable
diff mercurial/cmd_impls/graft.py @ 52368:8faabe8abf66
graft: gather arg compatibility code
Lets do it all in one place and at the start, this is easier to maintain
consistently.
We also take this as an opportunity to do this before we resolve commit options,
that so user do not get error about "--date" when they actually they specified
the "--current-date" argument.
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Thu, 28 Nov 2024 13:22:31 +0100 |
parents | 0b52283d50bb |
children | 58827d815646 |
line wrap: on
line diff
--- a/mercurial/cmd_impls/graft.py Wed Nov 20 04:23:45 2024 +0100 +++ b/mercurial/cmd_impls/graft.py Thu Nov 28 13:22:31 2024 +0100 @@ -44,49 +44,28 @@ # list of new nodes created by ongoing graft statedata[b'newnodes'] = [] - cmdutil.resolve_commit_options(ui, opts) + # argument incompatible with followup from an interrupted operation + commit_args = ['edit', 'log', 'user', 'date', 'currentdate', 'currentuser'] + nofollow_args = commit_args + ['rev'] + arg_compatibilities = [ + ('no_commit', commit_args), + ('stop', nofollow_args), + ('abort', nofollow_args), + ] cmdutil.check_at_most_one_arg(opts, 'abort', 'stop', 'continue') + for arg, incompatible in arg_compatibilities: + cmdutil.check_incompatible_arguments(opts, arg, incompatible) + + cmdutil.resolve_commit_options(ui, opts) cont = False - if opts.get('no_commit'): - cmdutil.check_incompatible_arguments( - opts, - 'no_commit', - ['edit', 'currentuser', 'currentdate', 'log'], - ) graftstate = statemod.cmdstate(repo, b'graftstate') if opts.get('stop'): - cmdutil.check_incompatible_arguments( - opts, - 'stop', - [ - 'edit', - 'log', - 'user', - 'date', - 'currentdate', - 'currentuser', - 'rev', - ], - ) return "STOP", graftstate, None elif opts.get('abort'): - cmdutil.check_incompatible_arguments( - opts, - 'abort', - [ - 'edit', - 'log', - 'user', - 'date', - 'currentdate', - 'currentuser', - 'rev', - ], - ) return "ABORT", graftstate, None elif opts.get('continue'): cont = True