comparison mercurial/manifest.py @ 39763:5ccd791344f3

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
author Gregory Szorc <gregory.szorc@gmail.com>
date Tue, 18 Sep 2018 15:15:24 -0700
parents 24870f1be088
children b63dee7bd0d9
comparison
equal deleted inserted replaced
39762:edaa40dc5fe5 39763:5ccd791344f3
1607 1607
1608 In this situation, 'manifest' refers to the abstract concept of a snapshot 1608 In this situation, 'manifest' refers to the abstract concept of a snapshot
1609 of the list of files in the given commit. Consumers of the output of this 1609 of the list of files in the given commit. Consumers of the output of this
1610 class do not care about the implementation details of the actual manifests 1610 class do not care about the implementation details of the actual manifests
1611 they receive (i.e. tree or flat or lazily loaded, etc).""" 1611 they receive (i.e. tree or flat or lazily loaded, etc)."""
1612 def __init__(self, opener, repo): 1612 def __init__(self, opener, repo, rootstore):
1613 usetreemanifest = False 1613 usetreemanifest = False
1614 cachesize = 4 1614 cachesize = 4
1615 1615
1616 opts = getattr(opener, 'options', None) 1616 opts = getattr(opener, 'options', None)
1617 if opts is not None: 1617 if opts is not None:
1618 usetreemanifest = opts.get('treemanifest', usetreemanifest) 1618 usetreemanifest = opts.get('treemanifest', usetreemanifest)
1619 cachesize = opts.get('manifestcachesize', cachesize) 1619 cachesize = opts.get('manifestcachesize', cachesize)
1620 1620
1621 self._treemanifests = usetreemanifest 1621 self._treemanifests = usetreemanifest
1622 1622
1623 self._rootstore = repo._constructmanifest() 1623 self._rootstore = rootstore
1624 self._rootstore._setupmanifestcachehooks(repo) 1624 self._rootstore._setupmanifestcachehooks(repo)
1625 self._narrowmatch = repo.narrowmatch() 1625 self._narrowmatch = repo.narrowmatch()
1626 1626
1627 # A cache of the manifestctx or treemanifestctx for each directory 1627 # A cache of the manifestctx or treemanifestctx for each directory
1628 self._dirmancache = {} 1628 self._dirmancache = {}