D4499: util: make capacity a public attribute on lrucachedict

indygreg (Gregory Szorc) phabricator at mercurial-scm.org
Wed Sep 12 10:52:41 EDT 2018


This revision was automatically updated to reflect the committed changes.
Closed by commit rHG5d75a3c16193: util: make capacity a public attribute on lrucachedict (authored by indygreg, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D4499?vs=10818&id=10938

REVISION DETAIL
  https://phab.mercurial-scm.org/D4499

AFFECTED FILES
  mercurial/util.py
  tests/test-lrucachedict.py

CHANGE DETAILS

diff --git a/tests/test-lrucachedict.py b/tests/test-lrucachedict.py
--- a/tests/test-lrucachedict.py
+++ b/tests/test-lrucachedict.py
@@ -11,6 +11,7 @@
 class testlrucachedict(unittest.TestCase):
     def testsimple(self):
         d = util.lrucachedict(4)
+        self.assertEqual(d.capacity, 4)
         d['a'] = 'va'
         d['b'] = 'vb'
         d['c'] = 'vc'
diff --git a/mercurial/util.py b/mercurial/util.py
--- a/mercurial/util.py
+++ b/mercurial/util.py
@@ -1241,7 +1241,7 @@
         head.prev = head
         head.next = head
         self._size = 1
-        self._capacity = max
+        self.capacity = max
 
     def __len__(self):
         return len(self._cache)
@@ -1269,7 +1269,7 @@
             self._movetohead(node)
             return
 
-        if self._size < self._capacity:
+        if self._size < self.capacity:
             node = self._addcapacity()
         else:
             # Grab the last/oldest item.
@@ -1312,7 +1312,7 @@
         self._cache.clear()
 
     def copy(self):
-        result = lrucachedict(self._capacity)
+        result = lrucachedict(self.capacity)
 
         # We copy entries by iterating in oldest-to-newest order so the copy
         # has the correct ordering.



To: indygreg, #hg-reviewers
Cc: mercurial-devel


More information about the Mercurial-devel mailing list