changeset 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 04036798ebed
children a14d93b2fb1b
files mercurial/templatekw.py
diffstat 1 files changed, 4 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/templatekw.py	Fri Nov 15 23:18:08 2013 -0500
+++ b/mercurial/templatekw.py	Thu Nov 21 15:46:49 2013 -0500
@@ -222,8 +222,10 @@
 def showextras(**args):
     """:extras: List of dicts with key, value entries of the 'extras'
     field of this changeset."""
-    yield showlist('extra', sorted(dict(key=a, value=b)
-                   for (a, b) in args['ctx'].extra().items()), **args)
+    extras = args['ctx'].extra()
+    c = [{'key': x[0], 'value': x[1]} for x in sorted(extras.items())]
+    f = _showlist('extra', c, plural='extras', **args)
+    return _hybrid(f, c, lambda x: '%s=%s' % (x['key'], x['value']))
 
 def showfileadds(**args):
     """:file_adds: List of strings. Files added by this changeset."""