# HG changeset patch # User Durham Goode # Date 2016-10-19 00:44:26 # Node ID acc8885a6450e5dec5426cddaa87b90a5125111f # Parent 3c8811efdddcee3e54632e62af8ebd808220c806 manifest: make manifestctx store the repo The old manifestctx stored a reference to the revlog. If the inmemory revlog became invalid, the ctx now held an old copy and would be incorrect. To fix this, we need the ctx to go through the manifestlog for each access. This is the same pattern that changectx already uses (it stores the repo, and accesses commit data through self._repo.changelog). diff --git a/mercurial/manifest.py b/mercurial/manifest.py --- a/mercurial/manifest.py +++ b/mercurial/manifest.py @@ -1276,7 +1276,7 @@ class manifestlog(object): if self._treeinmem: m = treemanifestctx(self._revlog, '', node) else: - m = manifestctx(self._revlog, node) + m = manifestctx(self._repo, node) if node != revlog.nullid: self._mancache[node] = m return m @@ -1288,8 +1288,8 @@ class manifestctx(object): """A class representing a single revision of a manifest, including its contents, its parent revs, and its linkrev. """ - def __init__(self, revlog, node): - self._revlog = revlog + def __init__(self, repo, node): + self._repo = repo self._data = None self._node = node @@ -1309,14 +1309,15 @@ class manifestctx(object): if self._node == revlog.nullid: self._data = manifestdict() else: - text = self._revlog.revision(self._node) + rl = self._repo.manifestlog._revlog + text = rl.revision(self._node) arraytext = array.array('c', text) - self._revlog._fulltextcache[self._node] = arraytext + rl._fulltextcache[self._node] = arraytext self._data = manifestdict(text) return self._data def readfast(self): - rl = self._revlog + rl = self._repo.manifestlog._revlog r = rl.rev(self._node) deltaparent = rl.deltaparent(r) if deltaparent != revlog.nullrev and deltaparent in rl.parentrevs(r): @@ -1324,11 +1325,11 @@ class manifestctx(object): return self.read() def readdelta(self): - revlog = self._revlog + revlog = self._repo.manifestlog._revlog if revlog._usemanifestv2: # Need to perform a slow delta r0 = revlog.deltaparent(revlog.rev(self._node)) - m0 = manifestctx(revlog, revlog.node(r0)).read() + m0 = manifestctx(self._repo, revlog.node(r0)).read() m1 = self.read() md = manifestdict() for f, ((n0, fl0), (n1, fl1)) in m0.diff(m1).iteritems():