config: make sortdict keys() and iterkeys() methods respect the item order
The config.sortdict class is a simple "sorted dictionary" container
class, based on python's regular dict container. The main difference
compared to regular dicts is that sortdicts remember the order in
which items have been added to it.
Without this patch the items() method returns the sortdict elements in
the right order. However, getting the list of keys by using the keys()
or iterkeys() methods, and consequencly, looping through the container
elements in a for loop does not respect that order. This patch fixes
this problem.
--- a/mercurial/config.py Mon Jun 04 16:59:57 2012 -0500
+++ b/mercurial/config.py Tue May 29 23:26:55 2012 +0200
@@ -35,6 +35,10 @@
def __delitem__(self, key):
dict.__delitem__(self, key)
self._list.remove(key)
+ def keys(self):
+ return self._list
+ def iterkeys(self):
+ return self._list.__iter__()
class config(object):
def __init__(self, data=None):