Mercurial > public > mercurial-scm > hg
comparison mercurial/templatekw.py @ 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 | 0c22257388d6 |
children | 6cb419dd3703 |
comparison
equal
deleted
inserted
replaced
20519:cda9d2b6beab | 20520:5c65ee4193e1 |
---|---|
193 | 193 |
194 def showbookmarks(**args): | 194 def showbookmarks(**args): |
195 """:bookmarks: List of strings. Any bookmarks associated with the | 195 """:bookmarks: List of strings. Any bookmarks associated with the |
196 changeset. | 196 changeset. |
197 """ | 197 """ |
198 repo = args['ctx']._repo | |
198 bookmarks = args['ctx'].bookmarks() | 199 bookmarks = args['ctx'].bookmarks() |
199 return showlist('bookmark', bookmarks, **args) | 200 hybrid = showlist('bookmark', bookmarks, **args) |
201 for value in hybrid.values: | |
202 value['current'] = repo._bookmarkcurrent | |
203 return hybrid | |
200 | 204 |
201 def showchildren(**args): | 205 def showchildren(**args): |
202 """:children: List of strings. The children of the changeset.""" | 206 """:children: List of strings. The children of the changeset.""" |
203 ctx = args['ctx'] | 207 ctx = args['ctx'] |
204 childrevs = ['%d:%s' % (cctx, cctx) for cctx in ctx.children()] | 208 childrevs = ['%d:%s' % (cctx, cctx) for cctx in ctx.children()] |