##// END OF EJS Templates
revset: replace parsing alias definition by _parsealiasdefn to parse strictly...
FUJIWARA Katsunori -
r23994:8a215678 default
parent child Browse files
Show More
@@ -2324,16 +2324,8 b' class revsetalias(object):'
2324 ' "%s": %s') % (self.name, self.error)
2324 ' "%s": %s') % (self.name, self.error)
2325 return
2325 return
2326
2326
2327 if self.args:
2328 for arg in self.args:
2329 # _aliasarg() is an unknown symbol only used separate
2330 # alias argument placeholders from regular strings.
2331 value = value.replace(arg, '_aliasarg(%r)' % (arg,))
2332
2333 try:
2327 try:
2334 self.replacement, pos = parse(value)
2328 self.replacement = _parsealiasdefn(value, self.args)
2335 if pos != len(value):
2336 raise error.ParseError(_('invalid token'), pos)
2337 # Check for placeholder injection
2329 # Check for placeholder injection
2338 _checkaliasarg(self.replacement, self.args)
2330 _checkaliasarg(self.replacement, self.args)
2339 except error.ParseError, inst:
2331 except error.ParseError, inst:
@@ -1024,6 +1024,19 b' far away.'
1024 ('symbol', 'tip')
1024 ('symbol', 'tip')
1025 warning: failed to parse the declaration of revset alias "bad name": at 4: invalid token
1025 warning: failed to parse the declaration of revset alias "bad name": at 4: invalid token
1026 9
1026 9
1027 $ echo 'strictreplacing($1, $10) = $10 or desc("$1")' >> .hg/hgrc
1028 $ try 'strictreplacing("foo", tip)'
1029 (func
1030 ('symbol', 'strictreplacing')
1031 (list
1032 ('string', 'foo')
1033 ('symbol', 'tip')))
1034 (or
1035 ('symbol', 'tip')
1036 (func
1037 ('symbol', 'desc')
1038 ('string', '$1')))
1039 9
1027
1040
1028 $ try 'd(2:5)'
1041 $ try 'd(2:5)'
1029 (func
1042 (func
General Comments 0
You need to be logged in to leave comments. Login now