Mercurial > public > mercurial-scm > hg
comparison mercurial/revset.py @ 25705:48919d246a47
revset: add function to build dict of positional and keyword arguments
Keyword arguments will be convenient for functions that will take more than
one optional or boolean flags. For example,
file(pattern[, subrepos=false])
subrepo([[pattern], status])
Because I don't think all functions should accept key=value syntax, getkwargs()
does not support variadic functions such as 'ancestor(*changeset)'.
The core logic is placed in the parser module because keyword arguments will
be more useful in the templater, where functions take more options. Test cases
will be added by the next patch.
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Sat, 27 Jun 2015 17:25:01 +0900 |
parents | 70a2082f855a |
children | b7f53c474e2c |
comparison
equal
deleted
inserted
replaced
25704:70a2082f855a | 25705:48919d246a47 |
---|---|
280 l = getlist(x) | 280 l = getlist(x) |
281 if len(l) < min or (max >= 0 and len(l) > max): | 281 if len(l) < min or (max >= 0 and len(l) > max): |
282 raise error.ParseError(err) | 282 raise error.ParseError(err) |
283 return l | 283 return l |
284 | 284 |
285 def getkwargs(x, funcname, keys): | |
286 return parser.buildargsdict(getlist(x), funcname, keys.split(), | |
287 keyvaluenode='keyvalue', keynode='symbol') | |
288 | |
285 def isvalidsymbol(tree): | 289 def isvalidsymbol(tree): |
286 """Examine whether specified ``tree`` is valid ``symbol`` or not | 290 """Examine whether specified ``tree`` is valid ``symbol`` or not |
287 """ | 291 """ |
288 return tree[0] == 'symbol' and len(tree) > 1 | 292 return tree[0] == 'symbol' and len(tree) > 1 |
289 | 293 |