comparison mercurial/manifest.py @ 30413:a431daa93f8c

manifest: make revlog verification optional This patches adds an parameter to manifestlog.get() to disable hash checking. This will be used in an upcoming patch to support treemanifestctx reading sub-trees without loading them from the revlog. (This is already supported but does not go through the manifestlog.get() code path)
author Durham Goode <durham@fb.com>
date Mon, 14 Nov 2016 15:17:27 -0800
parents 2019fbdab075
children a1beadaa4061
comparison
equal deleted inserted replaced
30412:945f8229b30d 30413:a431daa93f8c
1276 """Retrieves the manifest instance for the given node. Throws a 1276 """Retrieves the manifest instance for the given node. Throws a
1277 LookupError if not found. 1277 LookupError if not found.
1278 """ 1278 """
1279 return self.get('', node) 1279 return self.get('', node)
1280 1280
1281 def get(self, dir, node): 1281 def get(self, dir, node, verify=True):
1282 """Retrieves the manifest instance for the given node. Throws a 1282 """Retrieves the manifest instance for the given node. Throws a
1283 LookupError if not found. 1283 LookupError if not found.
1284
1285 `verify` - if True an exception will be thrown if the node is not in
1286 the revlog
1284 """ 1287 """
1285 if node in self._dirmancache.get(dir, ()): 1288 if node in self._dirmancache.get(dir, ()):
1286 cachemf = self._dirmancache[dir][node] 1289 cachemf = self._dirmancache[dir][node]
1287 # The old manifest may put non-ctx manifests in the cache, so 1290 # The old manifest may put non-ctx manifests in the cache, so
1288 # skip those since they don't implement the full api. 1291 # skip those since they don't implement the full api.
1290 isinstance(cachemf, treemanifestctx)): 1293 isinstance(cachemf, treemanifestctx)):
1291 return cachemf 1294 return cachemf
1292 1295
1293 if dir: 1296 if dir:
1294 if self._revlog._treeondisk: 1297 if self._revlog._treeondisk:
1295 dirlog = self._revlog.dirlog(dir) 1298 if verify:
1296 if node not in dirlog.nodemap: 1299 dirlog = self._revlog.dirlog(dir)
1297 raise LookupError(node, dirlog.indexfile, 1300 if node not in dirlog.nodemap:
1298 _('no node')) 1301 raise LookupError(node, dirlog.indexfile,
1302 _('no node'))
1299 m = treemanifestctx(self._repo, dir, node) 1303 m = treemanifestctx(self._repo, dir, node)
1300 else: 1304 else:
1301 raise error.Abort( 1305 raise error.Abort(
1302 _("cannot ask for manifest directory '%s' in a flat " 1306 _("cannot ask for manifest directory '%s' in a flat "
1303 "manifest") % dir) 1307 "manifest") % dir)
1304 else: 1308 else:
1305 if node not in self._revlog.nodemap: 1309 if verify:
1306 raise LookupError(node, self._revlog.indexfile, 1310 if node not in self._revlog.nodemap:
1307 _('no node')) 1311 raise LookupError(node, self._revlog.indexfile,
1312 _('no node'))
1308 if self._treeinmem: 1313 if self._treeinmem:
1309 m = treemanifestctx(self._repo, '', node) 1314 m = treemanifestctx(self._repo, '', node)
1310 else: 1315 else:
1311 m = manifestctx(self._repo, node) 1316 m = manifestctx(self._repo, node)
1312 1317