template: modify showextras to return a hybrid
authorMatthew Turk <matthewturk@gmail.com>
Thu, 21 Nov 2013 15:46:49 -0500
changeset 20183 de7e6c489412
parent 20182 04036798ebed
child 20184 a14d93b2fb1b
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.
mercurial/templatekw.py
--- 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."""