sortdict: have update() accept either dict or iterable of key/value pairs
authorYuya Nishihara <yuya@tcha.org>
Wed, 18 Feb 2015 22:53:53 +0900
changeset 24236 de14c3972c2f
parent 24235 79fceed67676
child 24237 9ad02823dc5b
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.
mercurial/util.py
--- 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 = []