[PATCH 2 of 2 V2 📕] sortdict: add insert method
Sean Farley
sean.michael.farley at gmail.com
Mon Nov 10 21:55:07 UTC 2014
# HG changeset patch
# User Sean Farley <sean.michael.farley at gmail.com>
# Date 1413401959 25200
# Wed Oct 15 12:39:19 2014 -0700
# Node ID a05038b7067da828f6d19634ab74ff7c7921118e
# Parent 5d023569ba26d41f41f074130103c7782cb87197
sortdict: add insert method
Future patches will allow extensions to choose which order a namespace should
output in the log, so we add a way for sortdict to insert to a specific
location.
diff --git a/mercurial/util.py b/mercurial/util.py
--- a/mercurial/util.py
+++ b/mercurial/util.py
@@ -370,10 +370,13 @@ class sortdict(dict):
def iterkeys(self):
return self._list.__iter__()
def iteritems(self):
for k in self._list:
yield k, self[k]
+ def insert(self, index, key, val):
+ self._list.insert(index, key)
+ dict.__setitem__(self, key, val)
class lrucachedict(object):
'''cache most recent gets from or sets to this dictionary'''
def __init__(self, maxsize):
self._cache = {}
More information about the Mercurial-devel
mailing list