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

Boris Feld boris.feld at octobus.net
Fri Jul 7 06:24:16 EDT 2017


On Thu, 2017-07-06 at 18:05 -0700, Sean Farley wrote:
> Boris Feld <boris.feld at octobus.net> writes:
> 
> > # HG changeset patch
> > # User Boris Feld <boris.feld at octobus.net>
> > # Date 1499085172 -7200
> > #      Mon Jul 03 14:32:52 2017 +0200
> > # Node ID e18d8e61b7260e246a82727c8cde01f936692cff
> > # Parent  098585d4fbc88dc54513e12fa306d0e52ea2b323
> > # EXP-Topic obsfatetemplate
> > template: use template-engine for obsfate
> > 
> > Try to replace the obsfateprinter part by "sub-templates".
> > 
> > The code is hacky, I've tried to use at maximum the template engine
> > but the
> > raw data-structure doesn't seems well supported:
> > 
> >     [{'markers': [{}, {}, ...], 'successors': [A, ...], 'verb': '',
> > ...}, ...]
> > 
> > I've put this changeset at the end so the beginning of the serie
> > might be
> > accepted without it. Even without this changeset, we already have
> > good tests
> > and the right structure for the computation of obsfate data.
> 
> I like the general sentiment of this series, so thanks for that! But
> by
> the end of reading the series I found myself want to customize (e.g.
> not
> include some of the info; colorize differently, etc.) the string.
> 
> I think an easy approach for now (unless I'm missing something) would
> be
> to make {obsfate} a meta-like template that is just an alias for
> finer
> grain templates: {obsfate_user} {obsfate_succesors} (or whatever name
> you prefer).

Interesting, I didn't think about your use-cases much.

The main twist in obsfate is that the value is a list. The list could
contains 1 element in case of a simple evolution or several elements in
case of a divergence. We could have a top-level template
{obsfate_users} being a list of list, but it would be hard to combine
with another top-level template {obsfate_verb} for example.

Also, I just found out that it's possible to access the data with the
template engine.

For example if you only want the verb and the users:
    hg log -G -T '{obsfate % "obsolete: {get(obsfate, "verb")} by
{get(obsfate, "users")}\n"}'

Which would returns "obsolete: rewritten by test" in simple cases.
Unfortunately it fails with multiple users "obsolete: rewritten by
test1test2"

I tried changing the template into:

    hg log -G -T '{obsfate % "obsolete: {get(obsfate, "verb")} by
{join(get(obsfate, "users"), ', ')}\n"}'

Unfortunately I only get a blank output, maybe a template engine
experts could help me identify what am I doing wrong.

Apart from this problem, do you think is it customizable enough for
your needs?

We can even access the markers with:

    $ hg log -T '{obsfate % "obsolete: {ge
t(obsfate, "markers")|json}\n"}'
    obsolete: [["471f378eab4c5e25f6c77f785b27c936efb22874",
["fdf9bde5129a28d4548fadd3f62b265cdd3b7a2e"], 0, [["user", "test"]],
[0.0, 0], null]]
    obsolete: [["471f378eab4c5e25f6c77f785b27c936efb22874",
["65b757b745b935093c87a2bccd877521cccffcbd"], 0, [["user", "test"]],
[0.0, 0], null], ["65b757b745b935093c87a2bccd877521cccffcbd",
["019fadeab383f6699fa83ad7bdb4d82ed2c0e5ab"], 0, [["user", "test"]],
[0.0, 0], null]]

However, I'm not sure what would be the use-cases to accessing the
markers as obsfate is designed to show a summary of the evolution of a
changeset. There could be multiple successorsets in case of divergence
and several markers for each successorsets in case the changeset has
been rewritten several times.

Cheers,

> 
> I have the same critique for 'hg show' as well (*cough* Greg
> *cough*).
> _______________________________________________
> 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