comparison mercurial/cmdutil.py @ 43905:fff21278554b

rebase: use cmdutil.check_at_most_one_arg() for action Here we also needed to know what the action was (if any), so I've updated the helper to return any specified option. Differential Revision: https://phab.mercurial-scm.org/D7640
author Martin von Zweigbergk <martinvonz@google.com>
date Thu, 12 Dec 2019 15:55:33 -0800
parents 023ad45e2fd2
children daed70e95d60
comparison
equal deleted inserted replaced
43904:023ad45e2fd2 43905:fff21278554b
259 # editor text 259 # editor text
260 _linebelow = b"^HG: ------------------------ >8 ------------------------$" 260 _linebelow = b"^HG: ------------------------ >8 ------------------------$"
261 261
262 262
263 def check_at_most_one_arg(opts, *args): 263 def check_at_most_one_arg(opts, *args):
264 """abort if more than one of the arguments are in opts""" 264 """abort if more than one of the arguments are in opts
265
266 Returns the unique argument or None if none of them were specified.
267 """
265 previous = None 268 previous = None
266 for x in args: 269 for x in args:
267 if opts.get(x): 270 if opts.get(x):
268 if previous: 271 if previous:
269 raise error.Abort( 272 raise error.Abort(
270 _(b'cannot specify both --%s and --%s') % (previous, x) 273 _(b'cannot specify both --%s and --%s') % (previous, x)
271 ) 274 )
272 previous = x 275 previous = x
276 return previous
273 277
274 278
275 def check_incompatible_arguments(opts, first, *others): 279 def check_incompatible_arguments(opts, first, *others):
276 """abort if the first argument is given along with any of the others 280 """abort if the first argument is given along with any of the others
277 281