[PATCH 1 of 3] formatter: add support for functions in json
Yuya Nishihara
yuya at tcha.org
Tue Aug 30 09:49:37 EDT 2016
On Mon, 29 Aug 2016 12:52:41 -0500, Mathias De Maré wrote:
> # HG changeset patch
> # User Mathias De Maré <mathias.demare at gmail.com>
> # Date 1472483920 -7200
> # Mon Aug 29 17:18:40 2016 +0200
> # Node ID fb88d0c87c2746bd84983f1005ed83276c6e9c68
> # Parent 318e2b600b80e4ed3c6f37df46ec7544f60d4c0b
> formatter: add support for functions in json
>
> Some extensions (like largefiles) assign functions to configuration entries.
> This was only possible without formatting so far.
>
> diff --git a/mercurial/formatter.py b/mercurial/formatter.py
> --- a/mercurial/formatter.py
> +++ b/mercurial/formatter.py
> @@ -193,6 +193,8 @@
> elif isinstance(v, (int, float)):
> return str(v)
> else:
> + if callable(v):
> + v = "<function %s>" % v.func_name
It should be stringified by the caller. A callable isn't always serializable,
and it would be actually called in templater.
More information about the Mercurial-devel
mailing list