Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mercurial template: separator for tags and bookmarks

Can I put space characters as separators only if I have any Tag or Bookmark?

Example:

hg log --template "{rev} {author} {tags} {bookmarks} {desc|firstline}\n"

Output:
3: Author1 TIP BKMRK_NAME Another commit
2: Author1   Third commit
1: Author1 TAG1  Second commit
0: Author1   Initial commit

The changesets that don't have Tags or Bookmarks prints the space characters. I'd like to suppress those extra spaces:

3: Author1 TAG_NAME BKMRK_NAME Another commit
2: Author1 Third commit
1: Author1 TAG1 Second commit
0: Author1 Initial commit
like image 499
Rafael Piccolo Avatar asked Jan 18 '26 09:01

Rafael Piccolo


1 Answers

With a recent Mercurial (after 2.5), you can use the if template expression:

hg log --template '{rev} {author}{if(tags, " {tags}")}{if(bookmarks," {bookmarks}")} {desc|firstline}\n'
like image 165
tonfa Avatar answered Jan 21 '26 08:01

tonfa