changeset 32346:2d19664e257d

util: drop unneeded override, sortdict.copy() OrderedDict.copy() returns self.__class__(self).
author Yuya Nishihara <yuya@tcha.org>
date Wed, 17 May 2017 23:01:56 +0900
parents 911057981ba4
children 3caec778774b
files mercurial/util.py
diffstat 1 files changed, 11 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/util.py	Wed May 17 10:48:56 2017 -0700
+++ b/mercurial/util.py	Wed May 17 23:01:56 2017 +0900
@@ -568,13 +568,21 @@
     return f
 
 class sortdict(collections.OrderedDict):
-    '''a simple sorted dictionary'''
+    '''a simple sorted dictionary
+
+    >>> d1 = sortdict([('a', 0), ('b', 1)])
+    >>> d2 = d1.copy()
+    >>> d2
+    sortdict([('a', 0), ('b', 1)])
+    >>> d2.update([('a', 2)])
+    >>> d2.keys() # should still be in last-set order
+    ['b', 'a']
+    '''
+
     def __setitem__(self, key, value):
         if key in self:
             del self[key]
         super(sortdict, self).__setitem__(key, value)
-    def copy(self):
-        return sortdict(self)
 
 class _lrucachenode(object):
     """A node in a doubly linked list.