comparison mercurial/templatekw.py @ 20183:de7e6c489412

template: modify showextras to return a hybrid This modifies slightly the behavior introduced in 519120a96c63 to allow showextras to return a hybrid, rather than showlist. The example in the template help file now executes and returns meaningful results.
author Matthew Turk <matthewturk@gmail.com>
date Thu, 21 Nov 2013 15:46:49 -0500
parents d4838302305c
children 0c22257388d6
comparison
equal deleted inserted replaced
20182:04036798ebed 20183:de7e6c489412
220 return '%s: +%s/-%s' % (len(stats), adds, removes) 220 return '%s: +%s/-%s' % (len(stats), adds, removes)
221 221
222 def showextras(**args): 222 def showextras(**args):
223 """:extras: List of dicts with key, value entries of the 'extras' 223 """:extras: List of dicts with key, value entries of the 'extras'
224 field of this changeset.""" 224 field of this changeset."""
225 yield showlist('extra', sorted(dict(key=a, value=b) 225 extras = args['ctx'].extra()
226 for (a, b) in args['ctx'].extra().items()), **args) 226 c = [{'key': x[0], 'value': x[1]} for x in sorted(extras.items())]
227 f = _showlist('extra', c, plural='extras', **args)
228 return _hybrid(f, c, lambda x: '%s=%s' % (x['key'], x['value']))
227 229
228 def showfileadds(**args): 230 def showfileadds(**args):
229 """:file_adds: List of strings. Files added by this changeset.""" 231 """:file_adds: List of strings. Files added by this changeset."""
230 repo, ctx, revcache = args['repo'], args['ctx'], args['revcache'] 232 repo, ctx, revcache = args['repo'], args['ctx'], args['revcache']
231 return showlist('file_add', getfiles(repo, ctx, revcache)[1], 233 return showlist('file_add', getfiles(repo, ctx, revcache)[1],