Mercurial > hg-stable
changeset 51820:3e9a660b074a
manifest: expose a version of the Class without interface decorator
The decorator confuse Pytype. Having the "raw" python class exposed will also
helps pytype when it get replaced by a native implementation. At least until we
start using `typing.Protocol` in the future.
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Mon, 05 Aug 2024 09:22:18 +0200 |
parents | 61976dece720 |
children | 897972398e61 |
files | mercurial/manifest.py |
diffstat | 1 files changed, 40 insertions(+), 16 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/manifest.py Sun Aug 04 10:50:38 2024 +0200 +++ b/mercurial/manifest.py Mon Aug 05 09:22:18 2024 +0200 @@ -161,7 +161,7 @@ _manifestflags = {b'', b'l', b't', b'x'} -class _lazymanifest: +class _LazyManifest: """A pure python manifest backed by a byte string. It is supplimented with internal lists as it is modified, until it is compacted back to a pure byte string. @@ -472,11 +472,10 @@ try: _lazymanifest = parsers.lazymanifest except AttributeError: - pass + _lazymanifest = _LazyManifest -@interfaceutil.implementer(repository.imanifestdict) -class manifestdict: +class ManifestDict: def __init__(self, nodelen, data=b''): self._nodelen = nodelen self._lm = _lazymanifest(nodelen, data) @@ -713,6 +712,9 @@ return arraytext, deltatext +manifestdict = interfaceutil.implementer(repository.imanifestdict)(ManifestDict) + + def _msearch(m, s, lo=0, hi=None): """return a tuple (start, end) that says where to find s within m. @@ -801,8 +803,7 @@ _noop = lambda s: None -@interfaceutil.implementer(repository.imanifestdict) -class treemanifest: +class TreeManifest: def __init__(self, nodeconstants, dir=b'', text=b''): self._dir = dir self.nodeconstants = nodeconstants @@ -1441,6 +1442,9 @@ yield subtree +treemanifest = interfaceutil.implementer(repository.imanifestdict)(TreeManifest) + + class manifestfulltextcache(util.lrucachedict): """File-backed LRU cache for the manifest cache @@ -1575,8 +1579,7 @@ """Exception raised when fastdelta isn't usable on a manifest.""" -@interfaceutil.implementer(repository.imanifeststorage) -class manifestrevlog: +class ManifestRevlog: """A revlog that stores manifest texts. This is responsible for caching the full-text manifest contents. """ @@ -1949,6 +1952,11 @@ self._revlog.opener = value +manifestrevlog = interfaceutil.implementer(repository.imanifeststorage)( + ManifestRevlog +) + + @interfaceutil.implementer(repository.imanifestlog) class manifestlog: """A collection class representing the collection of manifest snapshots @@ -2048,8 +2056,7 @@ return self._rootstore._revlog.update_caches(transaction=transaction) -@interfaceutil.implementer(repository.imanifestrevisionwritable) -class memmanifestctx: +class MemManifestCtx: def __init__(self, manifestlog): self._manifestlog = manifestlog self._manifestdict = manifestdict(manifestlog.nodeconstants.nodelen) @@ -2078,8 +2085,12 @@ ) -@interfaceutil.implementer(repository.imanifestrevisionstored) -class manifestctx: +memmanifestctx = interfaceutil.implementer( + repository.imanifestrevisionwritable +)(MemManifestCtx) + + +class ManifestCtx: """A class representing a single revision of a manifest, including its contents, its parent revs, and its linkrev. """ @@ -2158,8 +2169,12 @@ return self.read().find(key) -@interfaceutil.implementer(repository.imanifestrevisionwritable) -class memtreemanifestctx: +manifestctx = interfaceutil.implementer(repository.imanifestrevisionstored)( + ManifestCtx +) + + +class MemTreeManifestCtx: def __init__(self, manifestlog, dir=b''): self._manifestlog = manifestlog self._dir = dir @@ -2193,8 +2208,12 @@ ) -@interfaceutil.implementer(repository.imanifestrevisionstored) -class treemanifestctx: +memtreemanifestctx = interfaceutil.implementer( + repository.imanifestrevisionwritable +)(MemTreeManifestCtx) + + +class TreeManifestCtx: def __init__(self, manifestlog, dir, node): self._manifestlog = manifestlog self._dir = dir @@ -2317,6 +2336,11 @@ return self.read().find(key) +treemanifestctx = interfaceutil.implementer(repository.imanifestrevisionstored)( + TreeManifestCtx +) + + class excludeddir(treemanifest): """Stand-in for a directory that is excluded from the repository.