Mercurial > hg
changeset 20520:5c65ee4193e1
template: add 'current' to scope during {bookmarks % ...}
This adds the keyword 'current' to the template scope when processing a
bookmark list. The 'current' keyword resolves to the name of the currently
active bookmark in the repo. This allows us to apply special labels to the
current bookmark to distinguish it (especially in the case where there are
multiple bookmarks on the same commit).
Example: "{bookmarks % '{bookmark}{ifeq(bookmark, current, \"*\")} '}"
Results in a space separated list of bookmarks where the current bookmark has
an asterix.
author | Durham Goode <durham@fb.com> |
---|---|
date | Tue, 11 Feb 2014 21:40:33 -0800 |
parents | cda9d2b6beab |
children | 1850a7f5fb66 |
files | mercurial/templatekw.py tests/test-command-template.t |
diffstat | 2 files changed, 12 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/templatekw.py Tue Feb 11 21:04:12 2014 -0800 +++ b/mercurial/templatekw.py Tue Feb 11 21:40:33 2014 -0800 @@ -195,8 +195,12 @@ """:bookmarks: List of strings. Any bookmarks associated with the changeset. """ + repo = args['ctx']._repo bookmarks = args['ctx'].bookmarks() - return showlist('bookmark', bookmarks, **args) + hybrid = showlist('bookmark', bookmarks, **args) + for value in hybrid.values: + value['current'] = repo._bookmarkcurrent + return hybrid def showchildren(**args): """:children: List of strings. The children of the changeset."""
--- a/tests/test-command-template.t Tue Feb 11 21:04:12 2014 -0800 +++ b/tests/test-command-template.t Tue Feb 11 21:40:33 2014 -0800 @@ -1676,3 +1676,10 @@ Rev: 0 Ancestor: 0 +Test current bookmark templating + + $ hg book foo + $ hg book bar + $ hg log --template "{rev} {bookmarks % '{bookmark}{ifeq(bookmark, current, \"*\")} '}\n" + 1 bar* foo + 0