# HG changeset patch # User FUJIWARA Katsunori # Date 1422886024 -32400 # Node ID 8a215678083975b85fed011b38297134e497818f # Parent eedade0064580e7dfd997d5567558196136f4138 revset: replace parsing alias definition by _parsealiasdefn to parse strictly Before this patch, referring alias arguments is parsed by string base operation "str.replace". This causes problems below (see the previous patch introducing "_parsealiasdefn" for detail) - the shorter name argument breaks referring the longer name - argument names in the quoted string are broken This patch replaces parsing alias definition by "_parsealiasdefn" to parse strictly. diff -r eedade006458 -r 8a2156780839 mercurial/revset.py --- a/mercurial/revset.py Mon Feb 02 23:07:04 2015 +0900 +++ b/mercurial/revset.py Mon Feb 02 23:07:04 2015 +0900 @@ -2324,16 +2324,8 @@ ' "%s": %s') % (self.name, self.error) return - if self.args: - for arg in self.args: - # _aliasarg() is an unknown symbol only used separate - # alias argument placeholders from regular strings. - value = value.replace(arg, '_aliasarg(%r)' % (arg,)) - try: - self.replacement, pos = parse(value) - if pos != len(value): - raise error.ParseError(_('invalid token'), pos) + self.replacement = _parsealiasdefn(value, self.args) # Check for placeholder injection _checkaliasarg(self.replacement, self.args) except error.ParseError, inst: diff -r eedade006458 -r 8a2156780839 tests/test-revset.t --- a/tests/test-revset.t Mon Feb 02 23:07:04 2015 +0900 +++ b/tests/test-revset.t Mon Feb 02 23:07:04 2015 +0900 @@ -1024,6 +1024,19 @@ ('symbol', 'tip') warning: failed to parse the declaration of revset alias "bad name": at 4: invalid token 9 + $ echo 'strictreplacing($1, $10) = $10 or desc("$1")' >> .hg/hgrc + $ try 'strictreplacing("foo", tip)' + (func + ('symbol', 'strictreplacing') + (list + ('string', 'foo') + ('symbol', 'tip'))) + (or + ('symbol', 'tip') + (func + ('symbol', 'desc') + ('string', '$1'))) + 9 $ try 'd(2:5)' (func