diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py --- a/mercurial/cmdutil.py +++ b/mercurial/cmdutil.py @@ -260,6 +260,18 @@ _linebelow = b"^HG: ------------------------ >8 ------------------------$" +def check_unique_argument(opts, *args): + """abort if more than one of the arguments are in opts""" + previous = None + for x in args: + if opts.get(x): + if previous: + raise error.Abort( + _(b'cannot specify both --%s and --%s') % (previous, x) + ) + previous = x + + def resolvecommitoptions(ui, opts): """modify commit options dict to handle related options diff --git a/mercurial/commands.py b/mercurial/commands.py --- a/mercurial/commands.py +++ b/mercurial/commands.py @@ -1889,8 +1889,7 @@ Returns 0 on success. """ opts = pycompat.byteskwargs(opts) - if opts.get(b'noupdate') and opts.get(b'updaterev'): - raise error.Abort(_(b"cannot specify both --noupdate and --updaterev")) + cmdutil.check_unique_argument(opts, b'noupdate', b'updaterev') # --include/--exclude can come from narrow or sparse. includepats, excludepats = None, None