changeset 24237:9ad02823dc5b

templatekw: convert list of key/value pairs to sortdict These sortdict objects will be passed to _hybrid later, which will allow us to handle them by "ifcontains()" and "get()" as expected.
author Yuya Nishihara <yuya@tcha.org>
date Sun, 08 Mar 2015 14:17:35 +0900
parents de14c3972c2f
children 49cee6d8573d
files mercurial/templatekw.py
diffstat 1 files changed, 6 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/templatekw.py	Wed Feb 18 22:53:53 2015 +0900
+++ b/mercurial/templatekw.py	Sun Mar 08 14:17:35 2015 +0900
@@ -241,7 +241,8 @@
     """:extras: List of dicts with key, value entries of the 'extras'
     field of this changeset."""
     extras = args['ctx'].extra()
-    c = [{'key': x[0], 'value': x[1]} for x in sorted(extras.items())]
+    extras = util.sortdict((k, extras[k]) for k in sorted(extras))
+    c = [{'key': k, 'value': extras[k]} for k in extras]
     f = _showlist('extra', c, plural='extras', **args)
     return _hybrid(f, c, lambda x: '%s=%s' % (x['key'], x['value']))
 
@@ -267,7 +268,8 @@
             if rename:
                 copies.append((fn, rename[0]))
 
-    c = [{'name': x[0], 'source': x[1]} for x in copies]
+    copies = util.sortdict(copies)
+    c = [{'name': k, 'source': copies[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']))
 
@@ -279,7 +281,8 @@
     only if the --copied switch is set.
     """
     copies = args['revcache'].get('copies') or []
-    c = [{'name': x[0], 'source': x[1]} for x in copies]
+    copies = util.sortdict(copies)
+    c = [{'name': k, 'source': copies[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']))