manifest: make manifestctx store the repo stable
authorDurham Goode <durham@fb.com>
Tue, 18 Oct 2016 17:44:26 -0700
branchstable
changeset 30220 acc8885a6450
parent 30219 3c8811efdddc
child 30221 f2c5b9d48b29
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).
mercurial/manifest.py
--- a/mercurial/manifest.py	Tue Oct 18 17:33:39 2016 -0700
+++ b/mercurial/manifest.py	Tue Oct 18 17:44:26 2016 -0700
@@ -1276,7 +1276,7 @@
         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 @@
     """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 @@
             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 @@
         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():