[PATCH 9 of 9] template: use template-engine for obsfate

Yuya Nishihara yuya at tcha.org
Wed Jul 12 12:08:45 EDT 2017


On Wed, 12 Jul 2017 15:44:13 +0200, Boris Feld wrote:
> On Wed, 2017-07-12 at 00:06 +0900, Yuya Nishihara wrote:
> > Guessing from the PATCH 4, which has the following functions,
> > 
> >   obsfatedata: ctx => [succs, ...] => [(succs, markers), ...]
> > 
> > maybe we'll want a template function which converts 'succs' to
> > 'markers' ?
> > Let's call it 'relatedmarkers' here.
> > 
> >   relatedmarkers: succs => [marker, ...]  (where marker is a _hybrid
> > dict)
> > 
> > Then, a part of {obsfate} could probably be written as:
> > 
> >   {successorsets % "{relatedmarkers(successorset)
> >                      % "{get(marker, "verb")} ..."}"}
> 
> I hadn't thought about splitting the template into several templates
> functions, it's a good idea!.
> 
> One small, but important detail: the verb, users list and dates are
> computed from the markers list. Something like this might work, what do
> you think?
> 
>     {successorsets % "{obsfateverb(successorset)} by
> {obsfateusers(successorset)} as {join(get(successorset, 'successors'),
> ', ')}"}

That will work. Maybe obsfatexxx() could be a single function which
summarizes markers.

  {successorsets % "{obsxxx(markers(successorset))} % "{verb} {user}...

or

  {successorsets % "{obsxxx(successorset)} % "{verb} {user}...

> Would it be possible to keep the current {obsfate} template? It is easy
> to use for users who are OK with the default obsfate output format
> (which could be updated of course).
> 
> Also I've almost successfully reproduce the obsfate output "by hand"
> with:
> 
> $ hg log -r 34177 --hidden -v -T "{obsfate}"
> rewritten by Boris Feld <boris.feld at octobus.net> as e18d8e61b726 (at
> 2017-07-06 23:47 +0200)
> 
> $ hg log -r 34177 --hidden -T '{obsfate % "{get(obsfate, "verb")} by
> {join(get(obsfate, "users"), ", ")} as {get(obsfate, "successors")} (at
> {get(obsfate, "min_date")|isodate})\n"}'
> rewritten by Boris Feld <boris.feld at octobus.net> as e18d8e61b726 (at
> 2017-07-06 23:47 +0200)

I don't think a template keyword should generate a long descriptive output.
You could instead add it to map-cmdline.default. I know it isn't always
useful, but that is another issue.


More information about the Mercurial-devel mailing list