manifest: change treemanifestctx to construct subtrees from the manifestlog
authorDurham Goode <durham@fb.com>
Mon, 14 Nov 2016 15:24:07 -0800
changeset 30404 a1beadaa4061
parent 30403 a431daa93f8c
child 30405 e77e8876886f
manifest: change treemanifestctx to construct subtrees from the manifestlog Previously, treemanifestctx would directly construct its subtrees. By making it get the subtrees through manifestlog.get() we consolidate all treemanifestctx creation into manifestlog.get() and therefore extensions that need to wrap manifestctx creation (like narrow-hg) can intercept manifestctxs at that single place. This also means fetching subtrees will take advantage of the manifestlog ctx cache now, which it did not before.
mercurial/manifest.py
--- a/mercurial/manifest.py	Mon Nov 14 15:17:27 2016 -0800
+++ b/mercurial/manifest.py	Mon Nov 14 15:24:07 2016 -0800
@@ -1489,7 +1489,10 @@
                 def gettext():
                     return rl.revision(self._node)
                 def readsubtree(dir, subm):
-                    return treemanifestctx(self._repo, dir, subm).read()
+                    # Set verify to False since we need to be able to create
+                    # subtrees for trees that don't exist on disk.
+                    return self._repo.manifestlog.get(dir, subm,
+                                                      verify=False).read()
                 m.read(gettext, readsubtree)
                 m.setnode(self._node)
                 self._data = m
@@ -1531,7 +1534,7 @@
         else:
             # Need to perform a slow delta
             r0 = revlog.deltaparent(revlog.rev(self._node))
-            m0 = treemanifestctx(self._repo, self._dir, revlog.node(r0)).read()
+            m0 = self._repo.manifestlog.get(self._dir, revlog.node(r0)).read()
             m1 = self.read()
             md = treemanifest(dir=self._dir)
             for f, ((n0, fl0), (n1, fl1)) in m0.diff(m1).iteritems():