# HG changeset patch
# User Durham Goode
# Date 1474415164 25200
# Tue Sep 20 16:46:04 2016 -0700
# Node ID 69b91c12d904f329eff6618ac43f5cfef631e8dc
# Parent 52a206d772021194ab4356aeba2c73650851a624
manifest: change manifestlog mancache to be directory based
In the last patch we added a get() function that allows fetching directory level
treemanifestctxs. It didn't handle caching at directory level though, so we
need to
change our mancache to support multiple directories.
diff --git a/mercurial/manifest.py b/mercurial/manifest.py
--- a/mercurial/manifest.py
+++ b/mercurial/manifest.py
@@ -1021,9 +1021,16 @@ class manifestlog(object):
usetreemanifest = opts.get('treemanifest', usetreemanifest)
self._treeinmem = usetreemanifest
+# A dictionary containing the cache for each directory
+self._dirmancache = {}
+
# We'll separate this into it's own cache once oldmanifest is no longer
# used
-self._mancache = repo.manifest._mancache
+self._dirmancache[''] = repo.manifest._mancache
+
+# A future patch makes this use the same config value as the existing
+# mancache
+self.cachesize = 4
@property
def _revlog(self):
@@ -1039,6 +1046,14 @@ class manifestlog(object):
"""Retrieves the manifest instance for the given node. Throws a
KeyError
if not found.
"""
+if node in self._dirmancache.get(dir, ()):
+cachemf = self._dirmancache[dir][node]
+# The old manifest may put non-ctx manifests in the cache, so
+# skip those since they don't implement the full api.
+if (isinstance(cachemf, manifestctx) or
+isinstance(cachemf, treemanifestctx)):
+return cachemf
+
if dir:
if self._revlog._treeondisk:
m = treemanifestctx(self._revlog.dirlog(dir), dir, node)
@@ -1047,20 +1062,17 @@ class manifestlog(object):
_("cannot ask for manifest directory '%s' in a flat "
"manifest") % dir)
else:
-if node in self._mancache:
-cachemf = self._mancache[node]
-# The old manifest may put non-ctx manifests in the cache, so
-# skip those since they don't implement the full api.
-if (isinstance(cachemf, manifestctx) or
-isinstance(cachemf, treemanifestctx)):
-return cachemf
-
if self._treeinmem:
m = treemanifestctx(self._revlog, '', node)
else:
m = manifestctx(self._revlog, node)
-if node != revlog.nullid:
-self._mancache[node] = m
+
+if node != revlog.nullid:
+mancache = self._dirmancache.get(dir)
+if not mancache:
+mancache = util.lrucachedict(self.cachesize)
+self._dirmancache[dir] = mancache
+mancache[node] = m
return m
def add(self, m, transaction, link, p1, p2, added, removed):
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel