Question about a general tempting plan
timeless
timeless at gmail.com
Mon Feb 29 23:40:13 UTC 2016
Please note that temporarily the json format is intentionally undocumented.
because we (=me) are trying to unify the names of identifiers.
But otherwise, I think you're on the right track.
On Mon, Feb 29, 2016 at 5:13 PM, Kostia Balytskyi <ikostia at fb.com> wrote:
>
>
>
>
>
> On 2/29/16, 10:00 PM, "Matt Mackall" <mpm at selenic.com> wrote:
>
>>On Mon, 2016-02-29 at 21:19 +0000, Kostia Balytskyi wrote:
>>>
>>>
>>>
>>>
>>> On 2/29/16, 8:01 PM, "Matt Mackall" <mpm at selenic.com> wrote:
>>>
>>> > On Fri, 2016-02-26 at 16:39 +0000, Kostia Balytskyi wrote:
>>> > > Guys,
>>> > >
>>> > > I have a question related to this topic: https://urldefense.proofpoint.com
>>> > > /v2/url?u=https-3A__www.mercurial-
>>> > > 2Dscm.org_wiki_Ge&d=CwIDaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=Pp-
>>> > > gQYFgs4tKlSFPF5kfCw&m=yzRzFBVjzsTCKWTnOk23iSCfiNe_iJWhsBxu7SXjt3M&s=wA98fJ
>>> > > CBStx1RLI9EIuNWUCNj9orGF3TSOjVEkF5VuY&e=
>>> > > nericTemplatingPlan
>>> > >
>>> > > Let's say I want to implement a command. This command can be done as a
>>> > > version
>>> > > of `hg log` with a special enforced template.
>>> >
>>> > Then how will the _user_ control the output to meet their needs? Because
>>> > that is
>>> > the whole point of the templater/formatter: giving the user more
>>> > flexibility.
>>>
>>> Sorry, I made a mistake here, I was thinking of enforced revset and predefined
>>> template.
>>> As in, I want to make a command that does the same as other commands do, but
>>> requires
>>> less keystrokes (like `hg parents`). Surely, user-supplied template will have
>>> priority over
>>> the predefined one.
>>
>>Ok, but consider:
>>
>>hg evolve --list -Tjson
>>
>>If the underlying command is just "log".. then -Tjson is going to show you the
>>things that "hg log -Tjson" shows you (a pretty generic subset of the available
>>template data):
>>
>>$ hg log -l1 -Tjson
>>[
>> {
>> "rev": 34619,
>> "node": "4591cd6b679474a3d1b40c362843bf761fb3e168",
>> "branch": "default",
>> "phase": "draft",
>> "user": "timeless <timeless at mozdev.org>",
>> "date": [1456419254, 0],
>> "desc": "tests: rename regression tests",
>> "bookmarks": [],
>> "tags": ["tip"],
>> "parents": ["6d0d11731e1c9cf103703d9bbc0293b2d9893057"]
>> }
>>]
>>
>>...and a user will have to "rediscover" the "evolve --list" magic by grovelling
>>through the templating help. Whereas if you use the formatter, you'll have the
>>ability to say "this is what's important in this context" and a user can
>>discover the available elements just by dumping one of the machine-readable
>>forms. See for instance:
>>
>>$ hg branches -Tjson
>>[
>> {
>> "active": true,
>> "branch": "default",
>> "closed": false,
>> "current": true,
>> "node": "4591cd6b679474a3d1b40c362843bf761fb3e168",
>> "rev": 34619
>> },
>> {
>> "active": true,
>> "branch": "stable",
>> "closed": false,
>> "current": false,
>> "node": "b966e35aad78dfa3e132291261b7a77f4a0b9ff5",
>> "rev": 34568
>> }
>>]
>>
>>The formatter, as the very much newer API, should be viewed as "the right way to
>>do things today".
>>
>>--
>>Mathematics is the supreme nostalgia of our time.
>
> Ok, this emphasis on specifying important stuff in json finally answers my question of why we should prefer formatter in this case. Before that I was thinking of json output as of "all we know about this thing" dump. Thank you.
>
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel at mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
More information about the Mercurial-devel
mailing list