changeset 30403: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 945f8229b30d
children a1beadaa4061
files mercurial/manifest.py
diffstat 1 files changed, 13 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- 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: