util: properly implement lrucachedict.get()
authorGregory Szorc <gregory.szorc@gmail.com>
Mon, 22 Aug 2016 20:30:37 -0700
changeset 29828 79add5a4e857
parent 29827 a22b3de3b65a
child 29829 dae97049345b
util: properly implement lrucachedict.get() Before, it was returning the raw _lrucachenode instance instead of its value.
mercurial/util.py
tests/test-lrucachedict.py
--- a/mercurial/util.py	Wed Aug 17 13:25:13 2016 -0700
+++ b/mercurial/util.py	Mon Aug 22 20:30:37 2016 -0700
@@ -651,7 +651,7 @@
 
     def get(self, k, default=None):
         try:
-            return self._cache[k]
+            return self._cache[k].value
         except KeyError:
             return default
 
--- a/tests/test-lrucachedict.py	Wed Aug 17 13:25:13 2016 -0700
+++ b/tests/test-lrucachedict.py	Mon Aug 22 20:30:37 2016 -0700
@@ -25,6 +25,9 @@
     d['e'] = 've'
     printifpresent(d, ['a', 'b', 'c', 'd', 'e'])
 
+    assert d.get('a') is None
+    assert d.get('e') == 've'
+
     # touch entries in some order (get or set).
     d['e']
     d['c'] = 'vc2'