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

Pierre-Yves David pierre-yves.david at ens-lyon.org
Tue Mar 8 15:53:29 EST 2016



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.


Something interesting that emerged from the current discussion is "How 
is the templater expected to handle the nesting. I did not though much 
about it beforehand so I don't have a strong opinion yet.

I seems like the current kostia approach would help to standardize 
handling for list of elements. On the otherhand the more unified version 
above would give us a "troublectx" like "object" to feed the templater 
quite simply.

I'll let the night rest over it.

-- 
Pierre-Yves David


More information about the Mercurial-devel mailing list