[PATCH STABLE] help: add example of '[templates]' usage

Mathias De Maré mathias.demare at gmail.com
Mon Aug 8 12:11:47 EDT 2016


On Mon, Aug 8, 2016 at 5:47 PM, Anton Shestakov <engored at ya.ru> wrote:

> 08.08.2016, 22:53, "Mathias De Mar" <mathias.demare at gmail.com>:
> > # HG changeset patch
> > # User Mathias De Maré <mathias.demare at gmail.com>
> > # Date 1470667662 -7200
> > # Mon Aug 08 16:47:42 2016 +0200
> > # Branch stable
> > # Node ID bbcf7bff5bac8b56b61942a50a562f0d45448297
> > # Parent b8f9cdca88077e97d4869320b9d18481fbe252ef
> > help: add example of '[templates]' usage
> >
> > diff --git a/mercurial/help/templates.txt b/mercurial/help/templates.txt
> > --- a/mercurial/help/templates.txt
> > +++ b/mercurial/help/templates.txt
> > @@ -71,6 +71,21 @@
> >  defines two symbol aliases, ``r`` and ``rn``, and a function alias
> >  ``leftpad()``.
> >
> > +It's also possible to specify entirely new template commands,
> > +using the ``templates`` section.
> > +The syntax is the same as with ``templatealias``.
>
> Nit: superfluous line break.
>
Thanks, I'll change this.

>
> > +
> > +For example,
> > +
> > +::
> > +
> > + [templates]
> > + short = "{shortest(node, 8)}"
>
> Nit: minlength of 8 is not very useful at all, here's what it's like on
> the hg repo:
>
> $ hg log -T '{shortest(node, 8)|count}\n' | sort -u
> 8
>
> So it's literally just wasting time checking that the first 8 characters
> are unique (and they all are for almost 30k changesets). smartlog template
> uses the default minlength of 4. Bitbucket, for example, shows just first 7
> symbols (without any checks that shortest() does, even).
>

Thanks, I'll change it to 4.

>
> > +
> > +defines a template, ``short``, which can be called like::
> > +
> > + $ hg log -r . -Tshort
> > +
>
> It probably should point out the difference between templatealias and
> templates.
>
> (hg help config also doesn't mention [templates], only web.templates)
>

Thanks, I'll mention the difference and will add [templates] to config.txt
as well.


On Mon, Aug 8, 2016 at 5:48 PM, Yuya Nishihara <yuya at tcha.org> wrote:

> On Mon, 08 Aug 2016 09:53:05 -0500, Mathias De Maré wrote:
> > +It's also possible to specify entirely new template commands,
> > +using the ``templates`` section.
> > +The syntax is the same as with ``templatealias``.
>
> Nit: they aren't exactly the same. Aliases are expressions, but templates
> are template strings, e.g.
>
>   [templatealias]
>   # function = function
>   utcdate(date) = localdate(date, "UTC")
>   # keyword = '"' template-string '"' ('"' starts a template string)
>   revnode = "{rev}:{node|short}"
>
>   [templates]
>   # name = template-string (optionally quoted)
>   short = "{shortest(node, 8)}"
>
> Maybe we can say "the same as ``ui.logtemplate``."
>

I'll mention the difference, but I won't compare to ui.logtemplate (as
that's not mentioned in templates.txt).

I'll resubmit with the comments addressed.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.mercurial-scm.org/pipermail/mercurial-devel/attachments/20160808/ee06bc0c/attachment.html>


More information about the Mercurial-devel mailing list