This is an archive of the discontinued Mercurial Phabricator instance.

localrepo: pass root manifest into manifestlog.__init__
ClosedPublic

Authored by indygreg on Sep 18 2018, 6:40 PM.

Details

Summary

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.

Diff Detail

Repository
rHG Mercurial
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

indygreg created this revision.Sep 18 2018, 6:40 PM
yuja added a subscriber: yuja.Sep 23 2018, 5:30 AM

Queued, thanks.

diff --git a/mercurial/unionrepo.py b/mercurial/unionrepo.py

  • a/mercurial/unionrepo.py

+++ b/mercurial/unionrepo.py
@@ -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)

Perhaps unionrepository._constructmanifest() can be removed.

This revision was automatically updated to reflect the committed changes.