##// END OF EJS Templates
manifest: change manifestlog mancache to be directory based...
Durham Goode -
r30292:d4b340bf default
parent child Browse files
Show More
@@ -1257,9 +1257,17 b' class manifestlog(object):'
1257 self._oldmanifest = repo._constructmanifest()
1257 self._oldmanifest = repo._constructmanifest()
1258 self._revlog = self._oldmanifest
1258 self._revlog = self._oldmanifest
1259
1259
1260 # A cache of the manifestctx or treemanifestctx for each directory
1261 self._dirmancache = {}
1262
1260 # We'll separate this into it's own cache once oldmanifest is no longer
1263 # We'll separate this into it's own cache once oldmanifest is no longer
1261 # used
1264 # used
1262 self._mancache = self._oldmanifest._mancache
1265 self._mancache = self._oldmanifest._mancache
1266 self._dirmancache[''] = self._mancache
1267
1268 # A future patch makes this use the same config value as the existing
1269 # mancache
1270 self.cachesize = 4
1263
1271
1264 def __getitem__(self, node):
1272 def __getitem__(self, node):
1265 """Retrieves the manifest instance for the given node. Throws a
1273 """Retrieves the manifest instance for the given node. Throws a
@@ -1271,6 +1279,14 b' class manifestlog(object):'
1271 """Retrieves the manifest instance for the given node. Throws a
1279 """Retrieves the manifest instance for the given node. Throws a
1272 LookupError if not found.
1280 LookupError if not found.
1273 """
1281 """
1282 if node in self._dirmancache.get(dir, ()):
1283 cachemf = self._dirmancache[dir][node]
1284 # The old manifest may put non-ctx manifests in the cache, so
1285 # skip those since they don't implement the full api.
1286 if (isinstance(cachemf, manifestctx) or
1287 isinstance(cachemf, treemanifestctx)):
1288 return cachemf
1289
1274 if dir:
1290 if dir:
1275 if self._revlog._treeondisk:
1291 if self._revlog._treeondisk:
1276 dirlog = self._revlog.dirlog(dir)
1292 dirlog = self._revlog.dirlog(dir)
@@ -1283,14 +1299,6 b' class manifestlog(object):'
1283 _("cannot ask for manifest directory '%s' in a flat "
1299 _("cannot ask for manifest directory '%s' in a flat "
1284 "manifest") % dir)
1300 "manifest") % dir)
1285 else:
1301 else:
1286 if node in self._mancache:
1287 cachemf = self._mancache[node]
1288 # The old manifest may put non-ctx manifests in the cache, so
1289 # skip those since they don't implement the full api.
1290 if (isinstance(cachemf, manifestctx) or
1291 isinstance(cachemf, treemanifestctx)):
1292 return cachemf
1293
1294 if node not in self._revlog.nodemap:
1302 if node not in self._revlog.nodemap:
1295 raise LookupError(node, self._revlog.indexfile,
1303 raise LookupError(node, self._revlog.indexfile,
1296 _('no node'))
1304 _('no node'))
@@ -1298,8 +1306,13 b' class manifestlog(object):'
1298 m = treemanifestctx(self._repo, '', node)
1306 m = treemanifestctx(self._repo, '', node)
1299 else:
1307 else:
1300 m = manifestctx(self._repo, node)
1308 m = manifestctx(self._repo, node)
1301 if node != revlog.nullid:
1309
1302 self._mancache[node] = m
1310 if node != revlog.nullid:
1311 mancache = self._dirmancache.get(dir)
1312 if not mancache:
1313 mancache = util.lrucachedict(self.cachesize)
1314 self._dirmancache[dir] = mancache
1315 mancache[node] = m
1303 return m
1316 return m
1304
1317
1305 def add(self, m, transaction, link, p1, p2, added, removed):
1318 def add(self, m, transaction, link, p1, p2, added, removed):
General Comments 0
You need to be logged in to leave comments. Login now