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

Yuya Nishihara yuya at tcha.org
Sun Mar 13 07:49:02 EDT 2016


On Tue, 8 Mar 2016 20:53:29 +0000, Pierre-Yves David wrote:
> 
> 
> On 03/04/2016 04:29 PM, Kostia Balytskyi wrote:
> > This is a sample output of `evolve --list` with below fix applied to mercurial:
> >
> > ```
> > ikostia at dev1902.lla1:~/temprepos/supertroubledrepo$ HGRCPATH= ~/clowncopter/hg evolve --list  --config extensions.lz4revlog= --config extensions.color= --config extensions.evolve=~/evolve/hgext/evolve.py
> > [
> > ...
> >    {
> >      "desc": "e (e+f split)",
> >      "divergentsets": [{"divergentwith": [{"node": "01a3e66ba0301a4cbb7d519f8b9980af271241bd"}],"gcea": "3efa43a7427b9b19dc715853251d4891d3e9334c"}, {"divergentwith": [{"node": "add9a356b8cfca95c588f51f05291ad97ffbaea8"}],"gcea": "3efa43a7427b9b19dc715853251d4891d3e9334c"}],
> >      "node": "84e1c6ae319d139241a02ef5e939d7494b9b11d7",
> >      "unstableparents": [{"unstableparent": "1995fc658ad6db877b932a45deb411980ccc064e"}]
> >    },
> >
> > ...
> > ]
> >
> > ```
> 
> I had a bit more unified structure in mind (vague proposal):
> 
> [
>   {"desc": "e (e+f split)",
>    "node": "84e1c6ae319d139241a02ef5e939d7494b9b11d7",
>    [… author node level stuff…]
>    "troubles": [
>      {"troubletype": "unstable",
>       "sourcetype": "unstableparent",
>       "sourcenode": "1995fc658ad6db877b932a45deb411980ccc064e"},
>      {"troubletype": "divergent",
>       "divergentnode": "01a3e66ba0301a4cbb7d519f8b9980af271241bd",
>       "gceanode": ""3efa43a7427b9b19dc715853251d4891d3e9334c"},
>      {"troubletype": "divergent",
>       "divergentnode": "add9a356b8cfca95c588f51f05291ad97ffbaea8",
>       "gceanode": ""3efa43a7427b9b19dc715853251d4891d3e9334c"},
>      ]
> ]
> 
> This make the structure a bit more "complexobject" containing few (one) 
> list of complex object with somewhat standard strucuture. Instead of 
> multiple small list with very specific data in each of them.
> 
> I'm not sure this is superior, but I'm dumping my brain to expand the 
> discussion a bit.

Yeah, I think this will be easier to handle by templater API. On the other
hand, it will be slightly harder to write a template that sorts out "troubles"
by "troubletype".

  unstable: {troubles % "{ifeq(troubletype, 'unstable', sourcenode|short)}"}
  divergent: {troubles % "{ifeq(troubletype, 'divergent', sourcenode|short)}"}
  ...


More information about the Mercurial-devel mailing list