Mercurial > hg
comparison mercurial/templatekw.py @ 13156:d79fdff55627
template: add showbranch template for {branch}
Like showbranches, but always yields exactly one branch. Replaces the less
correct {branches|nonempty}.
author | Eric Eisner <ede@mit.edu> |
---|---|
date | Mon, 13 Dec 2010 10:30:15 -0500 |
parents | 8f29a08e7bbc |
children | f78bc5ddbe4f |
comparison
equal
deleted
inserted
replaced
13155:f02d7a562a21 | 13156:d79fdff55627 |
---|---|
143 | 143 |
144 | 144 |
145 def showauthor(repo, ctx, templ, **args): | 145 def showauthor(repo, ctx, templ, **args): |
146 return ctx.user() | 146 return ctx.user() |
147 | 147 |
148 def showbranch(**args): | |
149 return args['ctx'].branch() | |
150 | |
148 def showbranches(**args): | 151 def showbranches(**args): |
149 branch = args['ctx'].branch() | 152 branch = args['ctx'].branch() |
150 if branch != 'default': | 153 if branch != 'default': |
151 return showlist('branch', [branch], plural='branches', **args) | 154 return showlist('branch', [branch], plural='branches', **args) |
152 | 155 |
245 # templ - the templater instance | 248 # templ - the templater instance |
246 # cache - a cache dictionary for the whole templater run | 249 # cache - a cache dictionary for the whole templater run |
247 # revcache - a cache dictionary for the current revision | 250 # revcache - a cache dictionary for the current revision |
248 keywords = { | 251 keywords = { |
249 'author': showauthor, | 252 'author': showauthor, |
253 'branch': showbranch, | |
250 'branches': showbranches, | 254 'branches': showbranches, |
251 'children': showchildren, | 255 'children': showchildren, |
252 'date': showdate, | 256 'date': showdate, |
253 'desc': showdescription, | 257 'desc': showdescription, |
254 'diffstat': showdiffstat, | 258 'diffstat': showdiffstat, |