[PATCH] help: add pad function to template help

Thomas De Schampheleire patrickdepinguin+mercurial at gmail.com
Tue Aug 26 05:12:08 CDT 2014


Hi Jordi,

On Mon, Aug 25, 2014 at 4:30 PM, Jordi Gutiérrez Hermoso
<jordigh at octave.org> wrote:
> On Mon, 2014-08-25 at 15:41 +0200, Thomas De Schampheleire wrote:
>> # HG changeset patch
>> # User Thomas De Schampheleire <thomas.de.schampheleire at gmail.com>
>> # Date 1408972209 -7200
>> #      Mon Aug 25 15:10:09 2014 +0200
>> # Node ID 6dd4d3afa394f86e29968aaaed6f25712c6cde9f
>> # Parent  90cf454edd709c616d1e5ea4f30fb4d02f0c01a4
>> help: add pad function to template help
>>
>> Commit aa51392da507 introduced a pad function for use in templates, but did
>> not add the corresponding documentation to 'hg help templating'.
>>
>> diff --git a/mercurial/help/templates.txt b/mercurial/help/templates.txt
>> --- a/mercurial/help/templates.txt
>> +++ b/mercurial/help/templates.txt
>> @@ -57,6 +57,8 @@
>>
>>  - label(label, expr)
>>
>> +- pad(text, width[, fillchar, right])
>> +
>
> I could hardly call this "documentation". I'm preparing a fix to
> actually say what all of these functions *do*, since it's not
> documented anywhere. I suppose you can sort of guess for some of them,
> but overall it's still fairly obscure.

True. I was merely following the existing approach, but 'real'
documentation would be even better.

>
> Can you come up with a one-line explanation of what this function
> does? I think it's reasonable to give one-line descriptions of what
> all of these do. Very important to keep it short, but not nonexistent.
>
> Also, this needs an example, if nothing else.

While I can use the first two mandatory arguments without problem,
specifying an alternate padding character, or specifying right-padding
doesn't work for me.

Durham Goode, the original author of the function, could probably help here.

This works:
hg log -l3 --template 'X {pad(author|person, 40)} X\n'

but
hg log -l3 --template 'X {pad(author|person, 40,_)} X\n'
hg log -l3 --template 'X {pad(author|person, 40,'_')} X\n'
or anything else I tried does not.

Best regards,
Thomas


More information about the Mercurial-devel mailing list