# HG changeset patch # User Durham Goode # Date 1478133211 25200 # Node ID 1a0c1ad578331bfb4cc9cd6ee83bafe4b759f6f7 # Parent 1f92056c40666dce45fca946144a4afb3cdb4279 manifest: throw LookupError if node not in revlog When accessing a manifest via manifestlog[node], let's verify that the node actually exists and throw a LookupError if it doesn't. This matches the old read behavior, so we don't accidentally return invalid manifestctxs. We do this in manifestlog instead of in the manifestctx/treemanifestctx constructors because the treemanifest code currently relies on the fact that certain code paths can produce treemanifests without touching the revlogs (and it has tests that verify things work if certain revlogs are missing entirely, so they break if we add validation that tries to read them). diff -r 1f92056c4066 -r 1a0c1ad57833 mercurial/manifest.py --- a/mercurial/manifest.py Sun Oct 23 10:40:33 2016 -0700 +++ b/mercurial/manifest.py Wed Nov 02 17:33:31 2016 -0700 @@ -1262,8 +1262,8 @@ self._mancache = self._oldmanifest._mancache def __getitem__(self, node): - """Retrieves the manifest instance for the given node. Throws a KeyError - if not found. + """Retrieves the manifest instance for the given node. Throws a + LookupError if not found. """ if node in self._mancache: cachemf = self._mancache[node] @@ -1273,6 +1273,9 @@ isinstance(cachemf, treemanifestctx)): return cachemf + if node not in self._revlog.nodemap: + raise LookupError(node, self._revlog.indexfile, + _('no node')) if self._treeinmem: m = treemanifestctx(self._repo, '', node) else: