[PATCH 05 of 10 V2] manifest: make manifestlog use it's own cache

Durham Goode durham at fb.com
Fri Nov 11 04:26:38 EST 2016


# HG changeset patch
# User Durham Goode <durham at fb.com>
# Date 1478772799 28800
#      Thu Nov 10 02:13:19 2016 -0800
# Node ID dfffa0ee1b405f24d674b2d1f87bc55f0e8944c6
# Parent  259727f11f4039f683ea6e51741ad114b77f4ed8
manifest: make manifestlog use it's own cache

As we start to make manifestlog the primary manifest source, the dependency on
manifest.manifest will cause circular dependency problems. Let's break this
dependency by making manifestlog use it's own cache. In a near future patch we
will remove the previous manifest cache so we're not duplicating it.

diff --git a/mercurial/manifest.py b/mercurial/manifest.py
--- a/mercurial/manifest.py
+++ b/mercurial/manifest.py
@@ -1255,10 +1255,12 @@ class manifestlog(object):
         self._repo = repo
 
         usetreemanifest = False
+        cachesize = 4
 
         opts = getattr(opener, 'options', None)
         if opts is not None:
             usetreemanifest = opts.get('treemanifest', usetreemanifest)
+            cachesize = opts.get('manifestcachesize', cachesize)
         self._treeinmem = usetreemanifest
 
         self._oldmanifest = repo._constructmanifest()
@@ -1266,15 +1268,9 @@ class manifestlog(object):
 
         # A cache of the manifestctx or treemanifestctx for each directory
         self._dirmancache = {}
+        self._dirmancache[''] = util.lrucachedict(cachesize)
 
-        # We'll separate this into it's own cache once oldmanifest is no longer
-        # used
-        self._mancache = self._oldmanifest._mancache
-        self._dirmancache[''] = self._mancache
-
-        # A future patch makes this use the same config value as the existing
-        # mancache
-        self.cachesize = 4
+        self.cachesize = cachesize
 
     def __getitem__(self, node):
         """Retrieves the manifest instance for the given node. Throws a


More information about the Mercurial-devel mailing list