Mercurial > hg
changeset 50637:32837c7e2e4b
revlog: add a `get_revlog` method
This might seen weird, but I actually thing we have been needing this for a
long time. There is multiple object that kind of pretend being revlogs while
actually wrapping the actual revlog. Since multiple code needs to access the
actuel revlog. See documentation for more details.
Expect cleanup of various places one the current series is done.
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Sun, 28 May 2023 05:23:46 +0200 |
parents | c90ea9bbf327 |
children | 8fc10bfd9887 |
files | mercurial/filelog.py mercurial/interfaces/repository.py mercurial/manifest.py mercurial/revlog.py |
diffstat | 4 files changed, 30 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/filelog.py Mon May 29 04:26:39 2023 +0200 +++ b/mercurial/filelog.py Sun May 28 05:23:46 2023 +0200 @@ -42,6 +42,15 @@ opts = opener.options self._fix_issue6528 = opts.get(b'issue6528.fix-incoming', True) + def get_revlog(self): + """return an actual revlog instance if any + + This exist because a lot of code leverage the fact the underlying + storage is a revlog for optimization, so giving simple way to access + the revlog instance helps such code. + """ + return self._revlog + def __len__(self): return len(self._revlog)
--- a/mercurial/interfaces/repository.py Mon May 29 04:26:39 2023 +0200 +++ b/mercurial/interfaces/repository.py Sun May 28 05:23:46 2023 +0200 @@ -1404,6 +1404,14 @@ This one behaves the same way, except for manifest data. """ + def get_revlog(): + """return an actual revlog instance if any + + This exist because a lot of code leverage the fact the underlying + storage is a revlog for optimization, so giving simple way to access + the revlog instance helps such code. + """ + class imanifestlog(interfaceutil.Interface): """Interface representing a collection of manifest snapshots.
--- a/mercurial/manifest.py Mon May 29 04:26:39 2023 +0200 +++ b/mercurial/manifest.py Sun May 28 05:23:46 2023 +0200 @@ -1617,6 +1617,15 @@ self.index = self._revlog.index self._generaldelta = self._revlog._generaldelta + def get_revlog(self): + """return an actual revlog instance if any + + This exist because a lot of code leverage the fact the underlying + storage is a revlog for optimization, so giving simple way to access + the revlog instance helps such code. + """ + return self._revlog + def _setupmanifestcachehooks(self, repo): """Persist the manifestfulltextcache on lock release""" if not util.safehasattr(repo, '_wlockref'):
--- a/mercurial/revlog.py Mon May 29 04:26:39 2023 +0200 +++ b/mercurial/revlog.py Sun May 28 05:23:46 2023 +0200 @@ -663,6 +663,10 @@ # revlog header -> revlog compressor self._decompressors = {} + def get_revlog(self): + """simple function to mirror API of other not-really-revlog API""" + return self + @util.propertycache def revlog_kind(self): return self.target[0]