Patchwork [05,of,10] manifest: make manifestlog use it's own cache

login
register
mail settings
Submitter Durham Goode
Date Nov. 9, 2016, 7:31 p.m.
Message ID <604c120a5f8643b424f3.1478719879@dev111.prn1.facebook.com>
Download mbox | patch
Permalink /patch/17424/
State Accepted
Headers show

Comments

Durham Goode - Nov. 9, 2016, 7:31 p.m.
# HG changeset patch
# User Durham Goode <durham@fb.com>
# Date 1478684480 28800
#      Wed Nov 09 01:41:20 2016 -0800
# Node ID 604c120a5f8643b424f397d4db539675f00627e4
# Parent  9b070d4fce7896d247e9ad98c3088c5b25f3ce18
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.

Patch

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