[PATCH] help: add pad function to template help

Thomas De Schampheleire patrickdepinguin+mercurial at gmail.com
Tue Aug 26 06:04:44 CDT 2014


On Tue, Aug 26, 2014 at 12:30 PM, Durham Goode <durham at fb.com> wrote:
> On 8/26/14, 10:12 AM, "Thomas De Schampheleire"
> <patrickdepinguin+mercurial at gmail.com> wrote:
>
>>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.
>
> Your quoting is off for that last example.  Need “” instead of ‘’ around
> the _.
>
> ~/hg> hg log -r . -T 'X {pad(author|person, 40,"_")} X\n'
> X Durham Goode____________________________ X
> ~/hg> hg log -r . -T 'X {pad(author|person, 40,"_", True)} X\n'
> X ____________________________Durham Goode X
>

Ah yes, stupid mistake, thanks!


Jordi, I think a one-line description could be:

pad 'text' up to 'width' characters using 'fillchar' (default: ' ').
Set 'right' to True to right-align the text.

Clearly, this assumes that the user knows what 'padding' means.

Best regards,
Thomas


More information about the Mercurial-devel mailing list