##// END OF EJS Templates
revset: inline isvalidfunc(), getfuncname() and getfuncargs()...
Yuya Nishihara -
r28707:af5f90f2 default
parent child Browse files
Show More
@@ -332,25 +332,6 b' def getargsdict(x, funcname, keys):'
332 return parser.buildargsdict(getlist(x), funcname, keys.split(),
332 return parser.buildargsdict(getlist(x), funcname, keys.split(),
333 keyvaluenode='keyvalue', keynode='symbol')
333 keyvaluenode='keyvalue', keynode='symbol')
334
334
335 def isvalidfunc(tree):
336 """Examine whether specified ``tree`` is valid ``func`` or not
337 """
338 return tree[0] == 'func' and tree[1][0] == 'symbol'
339
340 def getfuncname(tree):
341 """Get function name from valid ``func`` in ``tree``
342
343 This assumes that ``tree`` is already examined by ``isvalidfunc``.
344 """
345 return tree[1][1]
346
347 def getfuncargs(tree):
348 """Get list of function arguments from valid ``func`` in ``tree``
349
350 This assumes that ``tree`` is already examined by ``isvalidfunc``.
351 """
352 return getlist(tree[2])
353
354 def getset(repo, subset, x):
335 def getset(repo, subset, x):
355 if not x:
336 if not x:
356 raise error.ParseError(_("missing argument"))
337 raise error.ParseError(_("missing argument"))
@@ -2314,13 +2295,13 b' def _parsealiasdecl(decl):'
2314 return (decl, None, None, _("'$' not for alias arguments"))
2295 return (decl, None, None, _("'$' not for alias arguments"))
2315 return (name, ('symbol', name), None, None)
2296 return (name, ('symbol', name), None, None)
2316
2297
2317 if isvalidfunc(tree):
2298 if tree[0] == 'func' and tree[1][0] == 'symbol':
2318 # "name(arg, ....) = ...." style
2299 # "name(arg, ....) = ...." style
2319 name = getfuncname(tree)
2300 name = tree[1][1]
2320 if name.startswith('$'):
2301 if name.startswith('$'):
2321 return (decl, None, None, _("'$' not for alias arguments"))
2302 return (decl, None, None, _("'$' not for alias arguments"))
2322 args = []
2303 args = []
2323 for arg in getfuncargs(tree):
2304 for arg in getlist(tree[2]):
2324 if arg[0] != 'symbol':
2305 if arg[0] != 'symbol':
2325 return (decl, None, None, _("invalid argument list"))
2306 return (decl, None, None, _("invalid argument list"))
2326 args.append(arg[1])
2307 args.append(arg[1])
General Comments 0
You need to be logged in to leave comments. Login now