comparison mercurial/dispatch.py @ 45914:be25b66f86ab

errors: raise InputError when too few arguments given to alias Differential Revision: https://phab.mercurial-scm.org/D9389
author Martin von Zweigbergk <martinvonz@google.com>
date Mon, 23 Nov 2020 16:05:03 -0800
parents 35ab6e39f482
children ac565222b9f8
comparison
equal deleted inserted replaced
45913:9acbe30953e8 45914:be25b66f86ab
508 def replacer(m): 508 def replacer(m):
509 num = int(m.group(1)) - 1 509 num = int(m.group(1)) - 1
510 nums.append(num) 510 nums.append(num)
511 if num < len(givenargs): 511 if num < len(givenargs):
512 return givenargs[num] 512 return givenargs[num]
513 raise error.Abort(_(b'too few arguments for command alias')) 513 raise error.InputError(_(b'too few arguments for command alias'))
514 514
515 cmd = re.sub(br'\$(\d+|\$)', replacer, cmd) 515 cmd = re.sub(br'\$(\d+|\$)', replacer, cmd)
516 givenargs = [x for i, x in enumerate(givenargs) if i not in nums] 516 givenargs = [x for i, x in enumerate(givenargs) if i not in nums]
517 args = pycompat.shlexsplit(cmd) 517 args = pycompat.shlexsplit(cmd)
518 return args + givenargs 518 return args + givenargs