localrepo: pass root manifest into manifestlog.__init__
Today, localrepository has a method that can be overloaded which
returns an instance of the root manifest storage object. When a
manifestlog is created, it calls this private method and stores
the root manifest object on it.
This "hook" on localrepository isn't part of the documented interface.
It isn't compatible with our desire to make repo storage determined
before the repo object is constructed.
This commit changes manifestlog.__init__ to accept the root
storage object instead of calling into the repo to construct it.
By doing things this way, the repo instance is responsible for
constructing the manifest storage object directly.
This does mean that other derived repo types need to overload
manifestlog(). But they should have been doing this already,
as manifestlog() is typically decorated in a storage-specific way.
e.g. localrepository.manifestlog() is decorated as
@storecache('00manifest.i'). And this assumes that a 00manifest.i
file exists in the store vfs. This condition may not hold for
repository types using non-revlog storage. So it is important
for special repo types to override manifestlog() to remove this
file association.
The code changed in perf is wrong because it isn't compatible with
older Mercurial versions. But I'm pretty sure the code was broken
on older versions before this commit. It only affects `hg perftags`.
I don't care enough to fix that at this time.
.. api::
``manifest.manifestlog.__init__()`` now receives the root manifest
storage instance instead of calling into a private method on
the repo object to obtain it.
Differential Revision: https://phab.mercurial-scm.org/D4641
--- a/contrib/perf.py Fri Sep 21 21:44:27 2018 -0400
+++ b/contrib/perf.py Tue Sep 18 15:15:24 2018 -0700
@@ -495,7 +495,9 @@
repocleartagscache = repocleartagscachefunc(repo)
def t():
repo.changelog = mercurial.changelog.changelog(svfs)
- repo.manifestlog = mercurial.manifest.manifestlog(svfs, repo)
+ rootmanifest = mercurial.manifest.manifestrevlog(svfs)
+ repo.manifestlog = mercurial.manifest.manifestlog(svfs, repo,
+ rootmanifest)
repocleartagscache()
return len(repo.tags())
timer(t)
--- a/mercurial/bundlerepo.py Fri Sep 21 21:44:27 2018 -0400
+++ b/mercurial/bundlerepo.py Tue Sep 18 15:15:24 2018 -0700
@@ -364,14 +364,16 @@
self.manstart = self._cgunpacker.tell()
return c
- def _constructmanifest(self):
+ @localrepo.unfilteredpropertycache
+ def manifestlog(self):
self._cgunpacker.seek(self.manstart)
# consume the header if it exists
self._cgunpacker.manifestheader()
linkmapper = self.unfiltered().changelog.rev
- m = bundlemanifest(self.svfs, self._cgunpacker, linkmapper)
+ rootstore = bundlemanifest(self.svfs, self._cgunpacker, linkmapper)
self.filestart = self._cgunpacker.tell()
- return m
+
+ return manifest.manifestlog(self.svfs, self, rootstore)
def _consumemanifest(self):
"""Consumes the manifest portion of the bundle, setting filestart so the
--- a/mercurial/localrepo.py Fri Sep 21 21:44:27 2018 -0400
+++ b/mercurial/localrepo.py Tue Sep 18 15:15:24 2018 -0700
@@ -994,15 +994,10 @@
return changelog.changelog(self.svfs,
trypending=txnutil.mayhavepending(self.root))
- def _constructmanifest(self):
- # This is a temporary function while we migrate from manifest to
- # manifestlog. It allows bundlerepo and unionrepo to intercept the
- # manifest creation.
- return manifest.manifestrevlog(self.svfs)
-
@storecache('00manifest.i')
def manifestlog(self):
- return manifest.manifestlog(self.svfs, self)
+ rootstore = manifest.manifestrevlog(self.svfs)
+ return manifest.manifestlog(self.svfs, self, rootstore)
@repofilecache('dirstate')
def dirstate(self):
--- a/mercurial/manifest.py Fri Sep 21 21:44:27 2018 -0400
+++ b/mercurial/manifest.py Tue Sep 18 15:15:24 2018 -0700
@@ -1609,7 +1609,7 @@
of the list of files in the given commit. Consumers of the output of this
class do not care about the implementation details of the actual manifests
they receive (i.e. tree or flat or lazily loaded, etc)."""
- def __init__(self, opener, repo):
+ def __init__(self, opener, repo, rootstore):
usetreemanifest = False
cachesize = 4
@@ -1620,7 +1620,7 @@
self._treemanifests = usetreemanifest
- self._rootstore = repo._constructmanifest()
+ self._rootstore = rootstore
self._rootstore._setupmanifestcachehooks(repo)
self._narrowmatch = repo.narrowmatch()
--- a/mercurial/statichttprepo.py Fri Sep 21 21:44:27 2018 -0400
+++ b/mercurial/statichttprepo.py Tue Sep 18 15:15:24 2018 -0700
@@ -185,7 +185,8 @@
self._filecache = {}
self.requirements = requirements
- self.manifestlog = manifest.manifestlog(self.svfs, self)
+ rootmanifest = manifest.manifestrevlog(self.svfs)
+ self.manifestlog = manifest.manifestlog(self.svfs, self, rootmanifest)
self.changelog = changelog.changelog(self.svfs)
self._tags = None
self.nodetagscache = None
--- a/mercurial/unionrepo.py Fri Sep 21 21:44:27 2018 -0400
+++ b/mercurial/unionrepo.py Tue Sep 18 15:15:24 2018 -0700
@@ -208,6 +208,12 @@
def changelog(self):
return unionchangelog(self.svfs, self.repo2.svfs)
+ @localrepo.unfilteredpropertycache
+ def manifestlog(self):
+ rootstore = unionmanifest(self.svfs, self.repo2.svfs,
+ self.unfiltered()._clrev)
+ return manifest.manifestlog(self.svfs, self, rootstore)
+
def _clrev(self, rev2):
"""map from repo2 changelog rev to temporary rev in self.changelog"""
node = self.repo2.changelog.node(rev2)
--- a/tests/test-check-interfaces.py Fri Sep 21 21:44:27 2018 -0400
+++ b/tests/test-check-interfaces.py Tue Sep 18 15:15:24 2018 -0700
@@ -184,7 +184,7 @@
checkzobject(fl, allowextra=True)
# Conforms to imanifestlog.
- ml = manifest.manifestlog(vfs, repo)
+ ml = manifest.manifestlog(vfs, repo, manifest.manifestrevlog(repo.svfs))
checkzobject(ml)
checkzobject(repo.manifestlog)