##// END OF EJS Templates
revset: unify function that parses alias declaration and definition...
Yuya Nishihara -
r28874:552eabef default
parent child Browse files
Show More
@@ -2234,35 +2234,27 b' def _tokenizealias(program, lookup=None)'
2234 return tokenize(program, lookup=lookup,
2234 return tokenize(program, lookup=lookup,
2235 syminitletters=_aliassyminitletters)
2235 syminitletters=_aliassyminitletters)
2236
2236
2237 def _parsealiasdecl(decl):
2237 def _parsealias(spec):
2238 """Parse alias declaration ``decl``
2238 """Parse alias declaration/definition ``spec``
2239
2239
2240 >>> _parsealiasdecl('foo($1)')
2240 >>> _parsealias('foo($1)')
2241 ('func', ('symbol', 'foo'), ('symbol', '$1'))
2241 ('func', ('symbol', 'foo'), ('symbol', '$1'))
2242 >>> _parsealiasdecl('foo bar')
2242 >>> _parsealias('foo bar')
2243 Traceback (most recent call last):
2243 Traceback (most recent call last):
2244 ...
2244 ...
2245 ParseError: ('invalid token', 4)
2245 ParseError: ('invalid token', 4)
2246 """
2246 """
2247 p = parser.parser(elements)
2247 p = parser.parser(elements)
2248 tree, pos = p.parse(_tokenizealias(decl))
2248 tree, pos = p.parse(_tokenizealias(spec))
2249 if pos != len(decl):
2249 if pos != len(spec):
2250 raise error.ParseError(_('invalid token'), pos)
2251 return parser.simplifyinfixops(tree, ('list',))
2252
2253 def _parsealiasdefn(defn):
2254 """Parse alias definition ``defn``"""
2255 p = parser.parser(elements)
2256 tree, pos = p.parse(_tokenizealias(defn))
2257 if pos != len(defn):
2258 raise error.ParseError(_('invalid token'), pos)
2250 raise error.ParseError(_('invalid token'), pos)
2259 return parser.simplifyinfixops(tree, ('list', 'or'))
2251 return parser.simplifyinfixops(tree, ('list', 'or'))
2260
2252
2261 class _aliasrules(parser.basealiasrules):
2253 class _aliasrules(parser.basealiasrules):
2262 """Parsing and expansion rule set of revset aliases"""
2254 """Parsing and expansion rule set of revset aliases"""
2263 _section = _('revset alias')
2255 _section = _('revset alias')
2264 _parsedecl = staticmethod(_parsealiasdecl)
2256 _parsedecl = staticmethod(_parsealias)
2265 _parsedefn = staticmethod(_parsealiasdefn)
2257 _parsedefn = staticmethod(_parsealias)
2266 _getlist = staticmethod(getlist)
2258 _getlist = staticmethod(getlist)
2267
2259
2268 class revsetalias(object):
2260 class revsetalias(object):
General Comments 0
You need to be logged in to leave comments. Login now