Mercurial > hg
comparison mercurial/changegroup.py @ 39244: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 |
comparison
equal
deleted
inserted
replaced
39243:0d97530eb535 | 39244:73cf21b2e8a6 |
---|---|
251 # if the result of the merge of 1 and 2 is the same in 3 and 4, | 251 # if the result of the merge of 1 and 2 is the same in 3 and 4, |
252 # no new manifest will be created and the manifest group will | 252 # no new manifest will be created and the manifest group will |
253 # be empty during the pull | 253 # be empty during the pull |
254 self.manifestheader() | 254 self.manifestheader() |
255 deltas = self.deltaiter() | 255 deltas = self.deltaiter() |
256 # TODO this violates storage abstraction. | 256 repo.manifestlog.getstorage(b'').addgroup(deltas, revmap, trp) |
257 repo.manifestlog._revlog.addgroup(deltas, revmap, trp) | |
258 prog.complete() | 257 prog.complete() |
259 self.callback = None | 258 self.callback = None |
260 | 259 |
261 def apply(self, repo, tr, srctype, url, targetphase=phases.draft, | 260 def apply(self, repo, tr, srctype, url, targetphase=phases.draft, |
262 expectedtotal=None): | 261 expectedtotal=None): |
483 super(cg3unpacker, self)._unpackmanifests(repo, revmap, trp, prog) | 482 super(cg3unpacker, self)._unpackmanifests(repo, revmap, trp, prog) |
484 for chunkdata in iter(self.filelogheader, {}): | 483 for chunkdata in iter(self.filelogheader, {}): |
485 # If we get here, there are directory manifests in the changegroup | 484 # If we get here, there are directory manifests in the changegroup |
486 d = chunkdata["filename"] | 485 d = chunkdata["filename"] |
487 repo.ui.debug("adding %s revisions\n" % d) | 486 repo.ui.debug("adding %s revisions\n" % d) |
488 dirlog = repo.manifestlog._revlog.dirlog(d) | |
489 deltas = self.deltaiter() | 487 deltas = self.deltaiter() |
490 if not dirlog.addgroup(deltas, revmap, trp): | 488 if not repo.manifestlog.getstorage(d).addgroup(deltas, revmap, trp): |
491 raise error.Abort(_("received dir revlog group is empty")) | 489 raise error.Abort(_("received dir revlog group is empty")) |
492 | 490 |
493 class headerlessfixup(object): | 491 class headerlessfixup(object): |
494 def __init__(self, fh, h): | 492 def __init__(self, fh, h): |
495 self._h = h | 493 self._h = h |
1017 `source` is unused here, but is used by extensions like remotefilelog to | 1015 `source` is unused here, but is used by extensions like remotefilelog to |
1018 change what is sent based in pulls vs pushes, etc. | 1016 change what is sent based in pulls vs pushes, etc. |
1019 """ | 1017 """ |
1020 repo = self._repo | 1018 repo = self._repo |
1021 mfl = repo.manifestlog | 1019 mfl = repo.manifestlog |
1022 dirlog = mfl._revlog.dirlog | |
1023 tmfnodes = {'': manifests} | 1020 tmfnodes = {'': manifests} |
1024 | 1021 |
1025 # Callback for the manifest, used to collect linkrevs for filelog | 1022 # Callback for the manifest, used to collect linkrevs for filelog |
1026 # revisions. | 1023 # revisions. |
1027 # Returns the linkrev node (collected in lookupcl). | 1024 # Returns the linkrev node (collected in lookupcl). |
1064 return clnode | 1061 return clnode |
1065 return lookupmflinknode | 1062 return lookupmflinknode |
1066 | 1063 |
1067 while tmfnodes: | 1064 while tmfnodes: |
1068 tree, nodes = tmfnodes.popitem() | 1065 tree, nodes = tmfnodes.popitem() |
1069 store = dirlog(tree) | 1066 store = mfl.getstorage(tree) |
1070 | 1067 |
1071 if not self._filematcher.visitdir(store._tree[:-1] or '.'): | 1068 if not self._filematcher.visitdir(store._tree[:-1] or '.'): |
1072 prunednodes = [] | 1069 prunednodes = [] |
1073 else: | 1070 else: |
1074 frev, flr = store.rev, store.linkrev | 1071 frev, flr = store.rev, store.linkrev |