changeset 24238:49cee6d8573d

templatekw: give name to lambda that constructs variables map of templater The constructed list is useless for "ifcontains()" and "get()". Instead, makemap() and raw dict will be passed to _hybrid object.
author Yuya Nishihara <yuya@tcha.org>
date Sun, 08 Mar 2015 14:38:50 +0900
parents 9ad02823dc5b
children 31f9b1b16d1e
files mercurial/templatekw.py
diffstat 1 files changed, 8 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/templatekw.py	Sun Mar 08 14:17:35 2015 +0900
+++ b/mercurial/templatekw.py	Sun Mar 08 14:38:50 2015 +0900
@@ -200,7 +200,8 @@
     repo = args['ctx']._repo
     bookmarks = args['ctx'].bookmarks()
     current = repo._bookmarkcurrent
-    c = [{'bookmark': x, 'current': current} for x in bookmarks]
+    makemap = lambda v: {'bookmark': v, 'current': current}
+    c = [makemap(v) for v in bookmarks]
     f = _showlist('bookmark', bookmarks, **args)
     return _hybrid(f, c, lambda x: x['bookmark'])
 
@@ -242,7 +243,8 @@
     field of this changeset."""
     extras = args['ctx'].extra()
     extras = util.sortdict((k, extras[k]) for k in sorted(extras))
-    c = [{'key': k, 'value': extras[k]} for k in extras]
+    makemap = lambda k: {'key': k, 'value': extras[k]}
+    c = [makemap(k) for k in extras]
     f = _showlist('extra', c, plural='extras', **args)
     return _hybrid(f, c, lambda x: '%s=%s' % (x['key'], x['value']))
 
@@ -269,7 +271,8 @@
                 copies.append((fn, rename[0]))
 
     copies = util.sortdict(copies)
-    c = [{'name': k, 'source': copies[k]} for k in copies]
+    makemap = lambda k: {'name': k, 'source': copies[k]}
+    c = [makemap(k) for k in copies]
     f = _showlist('file_copy', c, plural='file_copies', **args)
     return _hybrid(f, c, lambda x: '%s (%s)' % (x['name'], x['source']))
 
@@ -282,7 +285,8 @@
     """
     copies = args['revcache'].get('copies') or []
     copies = util.sortdict(copies)
-    c = [{'name': k, 'source': copies[k]} for k in copies]
+    makemap = lambda k: {'name': k, 'source': copies[k]}
+    c = [makemap(k) for k in copies]
     f = _showlist('file_copy', c, plural='file_copies', **args)
     return _hybrid(f, c, lambda x: '%s (%s)' % (x['name'], x['source']))