treemanifest: support readdelta in fastmanifest

If we were using fastmanifest in a treeonly repository, hg show would try to
access the manifest delta via the revlog which would crash. The fix is to make
fastmanifest first try accessing the data via the tree, before falling back to
the delta.

My attempts at automatically testing this failed, but I had a repro in a real
repository and confirmed this fixed the issue.
This commit is contained in:
Durham Goode 2017-11-01 17:10:05 -07:00
parent 712de93f88
commit 0332f82cce

View File

@ -849,6 +849,22 @@ class hybridmanifestctx(object):
return self._hybridmanifest
def readdelta(self, shallow=False):
p1, p2 = self.parents
mf = self.read()
parentmf = self._manifestlog[p1].read()
treemf = mf._treemanifest()
ptreemf = parentmf._treemanifest()
if treemf is not None and ptreemf is not None:
diff = ptreemf.diff(treemf)
result = manifest.manifestdict()
for path, ((oldn, oldf), (newn, newf)) in diff.iteritems():
if newn is not None:
result[path] = newn
if newf:
result.setflag(path, newf)
return mf._converttohybridmanifest(result)
rl = self._revlog
if rl._usemanifestv2:
# Need to perform a slow delta