Mercurial > public > mercurial-scm > hg-stable
diff mercurial/changegroup.py @ 39272:73cf21b2e8a6
manifest: add getstorage() to manifestlog and use it globally
It is a common pattern to obtain a directory manifest storage instance
(a manifestrevlog) by going through manifestlog._revlog.dirlog().
Why access to storage and caching of other manifests is done through
manifestrevlog instead of manifestlog, I don't know.
This commit establishes a getstorage(tree) API on manifestlog and
imanifestlog that provides a public API for accessing manifest storage.
All consumers previously using private attributes have been updated
to use this new method.
.. api:: manifestlog now has a getstorage(tree) method
It should be used for obtaining an object representing the
manifest's storage implementation. Accessing
manifestlog._revlog should be avoided.
Differential Revision: https://phab.mercurial-scm.org/D4277
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Fri, 10 Aug 2018 15:01:06 -0700 |
parents | 0d97530eb535 |
children | 57c3864f3aad |
line wrap: on
line diff
--- a/mercurial/changegroup.py Fri Aug 10 14:44:50 2018 -0700 +++ b/mercurial/changegroup.py Fri Aug 10 15:01:06 2018 -0700 @@ -253,8 +253,7 @@ # be empty during the pull self.manifestheader() deltas = self.deltaiter() - # TODO this violates storage abstraction. - repo.manifestlog._revlog.addgroup(deltas, revmap, trp) + repo.manifestlog.getstorage(b'').addgroup(deltas, revmap, trp) prog.complete() self.callback = None @@ -485,9 +484,8 @@ # If we get here, there are directory manifests in the changegroup d = chunkdata["filename"] repo.ui.debug("adding %s revisions\n" % d) - dirlog = repo.manifestlog._revlog.dirlog(d) deltas = self.deltaiter() - if not dirlog.addgroup(deltas, revmap, trp): + if not repo.manifestlog.getstorage(d).addgroup(deltas, revmap, trp): raise error.Abort(_("received dir revlog group is empty")) class headerlessfixup(object): @@ -1019,7 +1017,6 @@ """ repo = self._repo mfl = repo.manifestlog - dirlog = mfl._revlog.dirlog tmfnodes = {'': manifests} # Callback for the manifest, used to collect linkrevs for filelog @@ -1066,7 +1063,7 @@ while tmfnodes: tree, nodes = tmfnodes.popitem() - store = dirlog(tree) + store = mfl.getstorage(tree) if not self._filematcher.visitdir(store._tree[:-1] or '.'): prunednodes = []