[PATCH 2 of 3 RFC] revset: add function to build dict of positional and keyword arguments
Yuya Nishihara
yuya at tcha.org
Tue Jun 30 12:52:01 UTC 2015
On Mon, 29 Jun 2015 23:51:30 +0900, Yuya Nishihara wrote:
> # HG changeset patch
> # User Yuya Nishihara <yuya at tcha.org>
> # Date 1435393501 -32400
> # Sat Jun 27 17:25:01 2015 +0900
> # Node ID acaa4d55a0524e607e354cc873b4008f4fe48f70
> # Parent 164e1587bcf1164dad21f7f01b2ba160a011898d
> 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.
> +def getkwargs(x, funcname, keys):
> + return parser.buildargsdict(getlist(x), funcname, keys.split(),
> + keyvaluenode='keyvalue', keynode='symbol')
Perhaps I should call it as getargsdict(). It packs both positional and
keyword arguments.
More information about the Mercurial-devel
mailing list