[PATCH] formatter: allow json to handle more levels of depth

Yuya Nishihara yuya at tcha.org
Tue Mar 8 10:17:00 EST 2016

On Mon, 7 Mar 2016 15:55:08 +0000, Kostia Balytskyi wrote:
> On 3/7/16, 3:49 PM, "Yuya Nishihara" <youjah at gmail.com on behalf of yuya at tcha.org> wrote:
> >Hmm, but we provide -T option because people are likely to have their own needs.
> >They'll expect {rev}, {branch}, etc. can be used if "evolve -l" looks like a
> >log command.
> >
> >That said, I think it's okay to start from a limited version. My main concern
> >is that a nested data structure looks ugly in JSON if it has to be compatible
> >with the templater. And JSON output should be stable. (timeless is working on
> >it.)
> Well, if people expect ``rev``, ``node``, ``desc``, I can just provide those to a reasonable amount. And "nothing in evolution is stable" seems to be an argument for getting working versions out there without much fear for backwards compatibility-related problems.
> Another thing: we're currently discussing ``evolve --list`` rather than
> multi-level JSON output. What harm does the latter do?

Oh, do we? I'm totally fine with the multi-level template output of
"evolve --list".

If you don't care about the JSON output, I think using the changeset_templater
will be much easier. We can put new keywords to templatekw.keywrods. And we'll
need a way to select template other than ui.logtemplate.

> Also, I don't get what you mean by "nested data structure looks ugly in JSON
> if it has to be compatible with templater"

The templater requires a list of dicts, which isn't always necessary in JSON.
For example, "log -Tjson" renders "tags" as follows:

  "tags": ["tip"],

We can't do that with the current formatter API. To make it compatible with
the template functions, we would have to render it as follows:

  "tags": [{"tag": "tip"}]

This is IMO ugly.

> "JSON output should be stable".

It would be a big BC to change the structure of JSON output. I know it's okay
for "evolve --list" since it is experimental, but this patch isn't specific to

More information about the Mercurial-devel mailing list