util: fix sorteddict.pop
authorPierre-Yves David <pierre-yves.david@fb.com>
Thu, 02 Oct 2014 12:39:37 -0500
changeset 22643 3b1c0e1ede4c
parent 22642 45e50d8546d9
child 22644 1ec7cdaf898f
util: fix sorteddict.pop When using `.pop` on such object the list was not cleared of the popped key, leading to crash.
mercurial/util.py
--- a/mercurial/util.py	Fri Sep 26 12:51:55 2014 -0700
+++ b/mercurial/util.py	Thu Oct 02 12:39:37 2014 -0500
@@ -252,6 +252,12 @@
     def __delitem__(self, key):
         dict.__delitem__(self, key)
         self._list.remove(key)
+    def pop(self, key, *args, **kwargs):
+        dict.pop(self, key, *args, **kwargs)
+        try:
+            self._list.remove(key)
+        except ValueError:
+            pass
     def keys(self):
         return self._list
     def iterkeys(self):