[PATCH 2 of 2] templaterfilters: add 'newline' filter

Sean Farley sean.michael.farley at gmail.com
Fri Jan 18 12:36:34 CST 2013


On Fri, Jan 18, 2013 at 12:12 PM, Matt Mackall <mpm at selenic.com> wrote:
> On Thu, 2013-01-17 at 21:11 -0600, Sean Farley wrote:
>> On Thu, Jan 17, 2013 at 12:41 PM, Matt Mackall <mpm at selenic.com> wrote:
>> > On Thu, 2013-01-17 at 12:36 -0600, Sean Farley wrote:
>> >> On Wed, Jan 9, 2013 at 2:09 PM, Matt Mackall <mpm at selenic.com> wrote:
>> >> > On Wed, 2013-01-09 at 12:12 -0600, Sean Farley wrote:
>> >> >> # HG changeset patch
>> >> >> # User Sean Farley <sean.michael.farley at gmail.com>
>> >> >> # Date 1357671975 21600
>> >> >> # Node ID f8098885faa0fa09c8a9cfc887d807fa3c140cf4
>> >> >> # Parent  e9a1700097f2e520b5b0773f902cb92fe7af99ae
>> >> >> templaterfilters: add 'newline' filter
>> >> >
>> >> > We've got things like if() and sub() now, so we shouldn't need to add
>> >> > more special-purpose filters like this.
>> >> >
>> >> > $ hg tip --template '{if(author, "{author}\n")}'
>> >> > Matt Mackall <mpm at selenic.com>
>> >>
>> >> That's true. I'll drop this patch series. Also, I just figured out how
>> >> to do 'notfirstname' with sub(). For those wondering, I was able to
>> >> use sub(r'^.*\n?\n?', '', desc).
>> >
>> > Feel free to add examples to the template page.
>>
>> Just to make sure, you're talking about this page,
>>
>> http://mercurial.selenic.com/wiki/TemplateFilters
>>
>> correct?
>
> Actually, I was talking about 'hg help templates'.
>
> Things that are as yet undocumented:
>
> if(expr, then[, else])
> ifeq(expr, expr, then[, else])
> sub(pat, repl, expr)
> join(list, sep)
> label(label, expr)
> date(date[, fmt])
> fill(text[, width])
>
> expr % "{template}"
> expr|filter -> filter(expr)
>
>
> The most frequently asked question is how to format lists like files.
> Previously, this required writing a style file, but can now be done with
> something like:
>
> $ hg log --template "{files % '{rev}: {file}\n'}"

Aha, I was confused by the use of "page," but I'm with you now. I'll
try to whip up some documentation patches this afternoon.


More information about the Mercurial-devel mailing list