comparison mercurial/dispatch.py @ 35145:25c543944bc0

py3: add b'' to regular expressions which are raw strings Differential Revision: https://phab.mercurial-scm.org/D1538
author Pulkit Goyal <7895pulkit@gmail.com>
date Wed, 29 Nov 2017 04:47:27 +0530
parents fe987d0b9e1e
children e6487522ef92
comparison
equal deleted inserted replaced
35144:8f6641fa7c89 35145:25c543944bc0
402 # parameters, separated out into words. Emulate the same behavior here by 402 # parameters, separated out into words. Emulate the same behavior here by
403 # quoting the arguments individually. POSIX shells will then typically 403 # quoting the arguments individually. POSIX shells will then typically
404 # tokenize each argument into exactly one word. 404 # tokenize each argument into exactly one word.
405 replacemap['"$@"'] = ' '.join(util.shellquote(arg) for arg in args) 405 replacemap['"$@"'] = ' '.join(util.shellquote(arg) for arg in args)
406 # escape '\$' for regex 406 # escape '\$' for regex
407 regex = '|'.join(replacemap.keys()).replace('$', r'\$') 407 regex = '|'.join(replacemap.keys()).replace('$', br'\$')
408 r = re.compile(regex) 408 r = re.compile(regex)
409 return r.sub(lambda x: replacemap[x.group()], cmd) 409 return r.sub(lambda x: replacemap[x.group()], cmd)
410 410
411 class cmdalias(object): 411 class cmdalias(object):
412 def __init__(self, name, definition, cmdtable, source): 412 def __init__(self, name, definition, cmdtable, source):
447 else: 447 else:
448 ui.debug("No argument found for substitution " 448 ui.debug("No argument found for substitution "
449 "of %i variable in alias '%s' definition." 449 "of %i variable in alias '%s' definition."
450 % (int(m.groups()[0]), self.name)) 450 % (int(m.groups()[0]), self.name))
451 return '' 451 return ''
452 cmd = re.sub(r'\$(\d+|\$)', _checkvar, self.definition[1:]) 452 cmd = re.sub(br'\$(\d+|\$)', _checkvar, self.definition[1:])
453 cmd = aliasinterpolate(self.name, args, cmd) 453 cmd = aliasinterpolate(self.name, args, cmd)
454 return ui.system(cmd, environ=env, 454 return ui.system(cmd, environ=env,
455 blockedtag='alias_%s' % self.name) 455 blockedtag='alias_%s' % self.name)
456 self.fn = fn 456 self.fn = fn
457 return 457 return