Mercurial > hg
comparison mercurial/repair.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 | 2002c193f2bc |
children | 3d22aef3ecd5 |
comparison
equal
deleted
inserted
replaced
39243:0d97530eb535 | 39244:73cf21b2e8a6 |
---|---|
79 def _collectrevlog(revlog, striprev): | 79 def _collectrevlog(revlog, striprev): |
80 _, brokenset = revlog.getstrippoint(striprev) | 80 _, brokenset = revlog.getstrippoint(striprev) |
81 return [revlog.linkrev(r) for r in brokenset] | 81 return [revlog.linkrev(r) for r in brokenset] |
82 | 82 |
83 def _collectmanifest(repo, striprev): | 83 def _collectmanifest(repo, striprev): |
84 return _collectrevlog(repo.manifestlog._revlog, striprev) | 84 return _collectrevlog(repo.manifestlog.getstorage(b''), striprev) |
85 | 85 |
86 def _collectbrokencsets(repo, files, striprev): | 86 def _collectbrokencsets(repo, files, striprev): |
87 """return the changesets which will be broken by the truncation""" | 87 """return the changesets which will be broken by the truncation""" |
88 s = set() | 88 s = set() |
89 | 89 |
320 if topic: | 320 if topic: |
321 callback.topic = topic | 321 callback.topic = topic |
322 callback.addnodes(nodelist) | 322 callback.addnodes(nodelist) |
323 | 323 |
324 def stripmanifest(repo, striprev, tr, files): | 324 def stripmanifest(repo, striprev, tr, files): |
325 revlog = repo.manifestlog._revlog | 325 revlog = repo.manifestlog.getstorage(b'') |
326 revlog.strip(striprev, tr) | 326 revlog.strip(striprev, tr) |
327 striptrees(repo, tr, striprev, files) | 327 striptrees(repo, tr, striprev, files) |
328 | 328 |
329 def striptrees(repo, tr, striprev, files): | 329 def striptrees(repo, tr, striprev, files): |
330 if 'treemanifest' in repo.requirements: # safe but unnecessary | 330 if 'treemanifest' in repo.requirements: # safe but unnecessary |
331 # otherwise | 331 # otherwise |
332 for unencoded, encoded, size in repo.store.datafiles(): | 332 for unencoded, encoded, size in repo.store.datafiles(): |
333 if (unencoded.startswith('meta/') and | 333 if (unencoded.startswith('meta/') and |
334 unencoded.endswith('00manifest.i')): | 334 unencoded.endswith('00manifest.i')): |
335 dir = unencoded[5:-12] | 335 dir = unencoded[5:-12] |
336 repo.manifestlog._revlog.dirlog(dir).strip(striprev, tr) | 336 repo.manifestlog.getstorage(dir).strip(striprev, tr) |
337 | 337 |
338 def rebuildfncache(ui, repo): | 338 def rebuildfncache(ui, repo): |
339 """Rebuilds the fncache file from repo history. | 339 """Rebuilds the fncache file from repo history. |
340 | 340 |
341 Missing entries will be added. Extra entries will be removed. | 341 Missing entries will be added. Extra entries will be removed. |