[PATCH 3 of 6] templatekw: give name to lambda that constructs variables map of templater
Yuya Nishihara
yuya at tcha.org
Sun Mar 8 06:56:05 CDT 2015
# HG changeset patch
# User Yuya Nishihara <yuya at tcha.org>
# Date 1425793130 -32400
# Sun Mar 08 14:38:50 2015 +0900
# Node ID 14e6a56fa9b60a2bcec6c0a972e56b90deb78f56
# Parent d15979ee87019b8343801b0674f76080d2362123
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.
diff --git a/mercurial/templatekw.py b/mercurial/templatekw.py
--- a/mercurial/templatekw.py
+++ b/mercurial/templatekw.py
@@ -200,7 +200,8 @@ def showbookmarks(**args):
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 @@ def showextras(**args):
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 @@ def showfilecopies(**args):
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 @@ def showfilecopiesswitch(**args):
"""
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']))
More information about the Mercurial-devel
mailing list