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)
--- a/mercurial/manifest.py Thu Nov 10 09:45:42 2016 -0800
+++ b/mercurial/manifest.py Mon Nov 14 15:17:27 2016 -0800
@@ -1278,9 +1278,12 @@
"""
return self.get('', node)
- def get(self, dir, node):
+ def get(self, dir, node, verify=True):
"""Retrieves the manifest instance for the given node. Throws a
LookupError if not found.
+
+ `verify` - if True an exception will be thrown if the node is not in
+ the revlog
"""
if node in self._dirmancache.get(dir, ()):
cachemf = self._dirmancache[dir][node]
@@ -1292,19 +1295,21 @@
if dir:
if self._revlog._treeondisk:
- dirlog = self._revlog.dirlog(dir)
- if node not in dirlog.nodemap:
- raise LookupError(node, dirlog.indexfile,
- _('no node'))
+ if verify:
+ dirlog = self._revlog.dirlog(dir)
+ if node not in dirlog.nodemap:
+ raise LookupError(node, dirlog.indexfile,
+ _('no node'))
m = treemanifestctx(self._repo, dir, node)
else:
raise error.Abort(
_("cannot ask for manifest directory '%s' in a flat "
"manifest") % dir)
else:
- if node not in self._revlog.nodemap:
- raise LookupError(node, self._revlog.indexfile,
- _('no node'))
+ if verify:
+ if node not in self._revlog.nodemap:
+ raise LookupError(node, self._revlog.indexfile,
+ _('no node'))
if self._treeinmem:
m = treemanifestctx(self._repo, '', node)
else: