mercurial/revset.py
changeset 28707 af5f90f23515
parent 28706 b33ca687c1e3
child 28708 ab06b5ef93f7
equal deleted inserted replaced
28706:b33ca687c1e3 28707:af5f90f23515
   330 
   330 
   331 def getargsdict(x, funcname, keys):
   331 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"))
   357     s = methods[x[0]](repo, subset, *x[1:])
   338     s = methods[x[0]](repo, subset, *x[1:])
   358     if util.safehasattr(s, 'isascending'):
   339     if util.safehasattr(s, 'isascending'):
  2312             name = tree[1]
  2293             name = tree[1]
  2313             if name.startswith('$'):
  2294             if name.startswith('$'):
  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])
  2327             if len(args) != len(set(args)):
  2308             if len(args) != len(set(args)):
  2328                 return (name, None, None,
  2309                 return (name, None, None,