Patchwork [2,of,2] manifest: change treemanifestctx to construct subtrees from the manifestlog

login
register
mail settings
Submitter Durham Goode
Date Nov. 14, 2016, 11:27 p.m.
Message ID <2804de346a3e239ca0f0.1479166030@dev111.prn1.facebook.com>
Download mbox | patch
Permalink /patch/17565/
State Accepted
Headers show

Comments

Durham Goode - Nov. 14, 2016, 11:27 p.m.
# HG changeset patch
# User Durham Goode <durham@fb.com>
# Date 1479165847 28800
#      Mon Nov 14 15:24:07 2016 -0800
# Node ID 2804de346a3e239ca0f067068ac8823ebb41d6ae
# Parent  27209d52a5865422c5ef4ba05cedb28ce32919ed
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.

Patch

diff --git a/mercurial/manifest.py b/mercurial/manifest.py
--- a/mercurial/manifest.py
+++ b/mercurial/manifest.py
@@ -1489,7 +1489,10 @@  class treemanifestctx(object):
                 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 yet.
+                    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 @@  class treemanifestctx(object):
         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():