changeset 29828:79add5a4e857

util: properly implement lrucachedict.get() Before, it was returning the raw _lrucachenode instance instead of its value.
author Gregory Szorc <gregory.szorc@gmail.com>
date Mon, 22 Aug 2016 20:30:37 -0700
parents a22b3de3b65a
children dae97049345b
files mercurial/util.py tests/test-lrucachedict.py
diffstat 2 files changed, 4 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- 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'