NewLine handling in templates

Ernie Rael errael at raelity.com
Thu Nov 17 04:09:44 UTC 2022


On 22/11/16 7:36 PM, Yuya Nishihara wrote:
> On Wed, 16 Nov 2022 14:07:38 -0800, Ernie Rael wrote:
>> I want to include some bookmark info in a template I use to summarize log.
>>
>> It looks like the trailing "\n" in the first template gets lost when
>> there are bookmarks present, and this seems to be confirmed by the
>> second template which uses "{if(bookmarks, '\n')}" as a fixup. The
>> behavior using log instead of glog is as expected.
>>
>> hg glog -T"{bookmarks % '{bookmark}\n'}{rev} {phase}\n"
>> o  MaskFormattingJavadocCleanup
>> |  1177 draft
>> o  4.0.11-SNAPSHOT
>> |  1175 draft
>> o    1172 draft
>> |\
>> | o  1171 draft
>> | |
>> | o  1170 draft
>> | |
>>
>>
>> hg glog -T"{bookmarks % '{bookmark}\n'}{rev} {phase}{if(bookmarks, '\n')}\n"
>> o  MaskFormattingJavadocCleanup
>> |  1177 draft
>> |
>> o  4.0.11-SNAPSHOT
>> |  1175 draft
>> |
>> o    1172 draft
>> |\
>> | o  1171 draft
>> | |
>> | o  1170 draft
>> | |
> I don't fully understand the problem, but glog needs to allocate enough
> height to draw the graph, maybe which is why the output looks different
> from the plain log. "hg glog -T." appends extra "\n\n" for example.

Thanks for the response. So you are saying that glog changeset will 
always have at least two lines. When there are bookmarks, I need to 
explicitly add a "\n" for an empty line. OK I can see that.

To learn more, I'll play with it and I'll dig deeper into template help.

Thanks again,
-ernie



More information about the Mercurial mailing list