Mercurial模板:标签和书签的分隔符

Raf*_*olo 2 mercurial templates

只有当我有任何标签或书签时,我才能将空格字符作为分隔符吗?

例:

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
Run Code Online (Sandbox Code Playgroud)

没有标签或书签的变更集会打印空格字符.我想压制那些多余的空间:

3: Author1 TAG_NAME BKMRK_NAME Another commit
2: Author1 Third commit
1: Author1 TAG1 Second commit
0: Author1 Initial commit
Run Code Online (Sandbox Code Playgroud)

ton*_*nfa 6

使用最近的Mercurial(2.5之后),您可以使用if模板表达式:

hg log --template '{rev} {author}{if(tags, " {tags}")}{if(bookmarks," {bookmarks}")} {desc|firstline}\n'
Run Code Online (Sandbox Code Playgroud)