Mercurial > hg
changeset 24236:de14c3972c2f
sortdict: have update() accept either dict or iterable of key/value pairs
Future patches will make the templater store a sorted dict in the _hybrid object.
sortdict should be constructed from a sorted list.
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Wed, 18 Feb 2015 22:53:53 +0900 |
parents | 79fceed67676 |
children | 9ad02823dc5b |
files | mercurial/util.py |
diffstat | 1 files changed, 4 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/util.py Fri Mar 06 15:57:43 2015 -0800 +++ b/mercurial/util.py Wed Feb 18 22:53:53 2015 +0900 @@ -359,8 +359,10 @@ def __iter__(self): return self._list.__iter__() def update(self, src): - for k in src: - self[k] = src[k] + if isinstance(src, dict): + src = src.iteritems() + for k, v in src: + self[k] = v def clear(self): dict.clear(self) self._list = []