Writing a template which displays only relevant parents

Matt Mackall mpm at selenic.com
Thu Feb 4 18:06:30 UTC 2016


On Thu, 2016-02-04 at 17:42 +0100, Dr Rainer Woitok wrote:
> Greetings,
> 
> part of my template to display a changeset is
> 
>    {if(parents,"\n<-{p1rev}:{p1node|short}{ifeq(p2rev,-
> 1,'',',{p2rev}:{p2node|short}')}")}
> 
> and this works.   However, I want to improve  this output  in such a way
> that trivial parents (immediately preceding revisions) are replaced with
> an asterisk.

There is in fact a way to "do the math", namely by using the revset template
function together with if. But the smarts you want are already built into
"parents":

$ hg log -l15 -T '{rev}: {join(parents % "{rev}", ", ")}\n'
34135: 34135, 34135
34134: 
34133: 
34132: 
34131: 
34130: 
34129: 
34128: 
34127: 
34126: 
34125: 
34124: 34124
34123: 34123, 34123
34122: 
34121: 

-- 
Mathematics is the supreme nostalgia of our time.




More information about the Mercurial mailing list