Mercurial > public > mercurial-scm > hg
comparison mercurial/templatekw.py @ 21896:2b41ee1b5ea1
templatekw: add 'currentbookmark' keyword to show current bookmark easily
Before this patch, complicated template expression below is required
to show current active bookmark if it is associated with the
changeset.
"{bookmarks % '{ifeq(bookmark, current, \"{bookmark}\")}'}"
This patch add 'currentbookmark' keyword to show current bookmark
easily.
author | FUJIWARA Katsunori <foozy@lares.dti.ne.jp> |
---|---|
date | Tue, 15 Jul 2014 23:34:13 +0900 |
parents | 6cb419dd3703 |
children | 764adc332f6e |
comparison
equal
deleted
inserted
replaced
21895:5809d62e7106 | 21896:2b41ee1b5ea1 |
---|---|
206 """:children: List of strings. The children of the changeset.""" | 206 """:children: List of strings. The children of the changeset.""" |
207 ctx = args['ctx'] | 207 ctx = args['ctx'] |
208 childrevs = ['%d:%s' % (cctx, cctx) for cctx in ctx.children()] | 208 childrevs = ['%d:%s' % (cctx, cctx) for cctx in ctx.children()] |
209 return showlist('children', childrevs, element='child', **args) | 209 return showlist('children', childrevs, element='child', **args) |
210 | 210 |
211 def showcurrentbookmark(**args): | |
212 """:currentbookmark: String. The active bookmark, if it is | |
213 associated with the changeset""" | |
214 import bookmarks as bookmarks # to avoid circular import issues | |
215 repo = args['repo'] | |
216 if bookmarks.iscurrent(repo): | |
217 current = repo._bookmarkcurrent | |
218 if current in args['ctx'].bookmarks(): | |
219 return current | |
220 return '' | |
221 | |
211 def showdate(repo, ctx, templ, **args): | 222 def showdate(repo, ctx, templ, **args): |
212 """:date: Date information. The date when the changeset was committed.""" | 223 """:date: Date information. The date when the changeset was committed.""" |
213 return ctx.date() | 224 return ctx.date() |
214 | 225 |
215 def showdescription(repo, ctx, templ, **args): | 226 def showdescription(repo, ctx, templ, **args): |
362 'bisect': showbisect, | 373 'bisect': showbisect, |
363 'branch': showbranch, | 374 'branch': showbranch, |
364 'branches': showbranches, | 375 'branches': showbranches, |
365 'bookmarks': showbookmarks, | 376 'bookmarks': showbookmarks, |
366 'children': showchildren, | 377 'children': showchildren, |
378 'currentbookmark': showcurrentbookmark, | |
367 'date': showdate, | 379 'date': showdate, |
368 'desc': showdescription, | 380 'desc': showdescription, |
369 'diffstat': showdiffstat, | 381 'diffstat': showdiffstat, |
370 'extras': showextras, | 382 'extras': showextras, |
371 'file_adds': showfileadds, | 383 'file_adds': showfileadds, |