[PATCH] alias: support for $ escaping in shell-alias definition
Roman Sokolov
sokolov.r.v at gmail.com
Wed Feb 9 08:24:07 CST 2011
# HG changeset patch
# User Roman Sokolov <sokolov.r.v at gmail.com>
# Date 1297261323 -10800
# Node ID f996022846eac117abcdb934c0a6e06e0c25f6c5
# Parent 8f5c865b7b4a947b6eb2089ea31ebcc91132cc7f
alias: support for $ escaping in shell-alias definition
Allows using double sigil in alias definition to avoid its substitution.
diff -r 8f5c865b7b4a -r f996022846ea mercurial/dispatch.py
--- a/mercurial/dispatch.py Tue Feb 01 17:53:50 2011 -0600
+++ b/mercurial/dispatch.py Wed Feb 09 17:22:03 2011 +0300
@@ -224,12 +224,16 @@
if int(m.groups()[0]) <= len(args):
return m.group()
else:
+ ui.warn(_(
+ "No argument found for substitution of %i variable"
+ "in alias definition." % int(m.groups()[0])))
return ''
- cmd = re.sub(r'\$(\d+)', _checkvar, self.definition[1:])
+ cmd = re.sub(r'(?<!\$)\$(\d+)', _checkvar, self.definition[1:])
replace = dict((str(i + 1), arg) for i, arg in enumerate(args))
replace['0'] = self.name
replace['@'] = ' '.join(args)
- cmd = util.interpolate(r'\$', replace, cmd)
+ cmd = util.interpolate(r'(?<!\$)\$', replace, cmd)
+ cmd = cmd.replace(r'$$', r'$')
return util.system(cmd, environ=env)
self.fn = fn
return
More information about the Mercurial-devel
mailing list