Mercurial > public > mercurial-scm > hg-stable
changeset 52514:dfb60fb155da
interfaces: convert `ilocalrepositorymain` from zope `Attribute` attrs
This is the same transformation as b455dfddfed0 did for dirstate. This is also
the last of the `interfaceutil.Attribute` style attributes.
author | Matt Harbison <matt_harbison@yahoo.com> |
---|---|
date | Tue, 22 Oct 2024 23:14:32 -0400 |
parents | d371efa7c358 |
children | c0d9fda9f5f5 |
files | mercurial/interfaces/repository.py |
diffstat | 1 files changed, 139 insertions(+), 144 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/interfaces/repository.py Tue Oct 22 22:56:10 2024 -0400 +++ b/mercurial/interfaces/repository.py Tue Oct 22 23:14:32 2024 -0400 @@ -13,21 +13,27 @@ from typing import ( Any, + Callable, Collection, + Mapping, Protocol, ) from ..i18n import _ from .. import error -from . import util as interfaceutil if typing.TYPE_CHECKING: # Almost all mercurial modules are only imported in the type checking phase # to avoid circular imports + from .. import ( + util, + ) from ..utils import ( urlutil, ) + from . import dirstate as intdirstate + # TODO: make a protocol class for this NodeConstants = Any @@ -1632,132 +1638,119 @@ This currently captures the reality of things - not how things should be. """ - nodeconstants = interfaceutil.Attribute( - """Constant nodes matching the hash function used by the repository.""" - ) - nullid = interfaceutil.Attribute( - """null revision for the hash function used by the repository.""" - ) - - supported = interfaceutil.Attribute( - """Set of requirements that this repo is capable of opening.""" - ) - - requirements = interfaceutil.Attribute( - """Set of requirements this repo uses.""" - ) - - features = interfaceutil.Attribute( - """Set of "features" this repository supports. - - A "feature" is a loosely-defined term. It can refer to a feature - in the classical sense or can describe an implementation detail - of the repository. For example, a ``readonly`` feature may denote - the repository as read-only. Or a ``revlogfilestore`` feature may - denote that the repository is using revlogs for file storage. - - The intent of features is to provide a machine-queryable mechanism - for repo consumers to test for various repository characteristics. - - Features are similar to ``requirements``. The main difference is that - requirements are stored on-disk and represent requirements to open the - repository. Features are more run-time capabilities of the repository - and more granular capabilities (which may be derived from requirements). - """ - ) - - filtername = interfaceutil.Attribute( - """Name of the repoview that is active on this repo.""" - ) - - vfs_map = interfaceutil.Attribute( - """a bytes-key → vfs mapping used by transaction and others""" - ) - - wvfs = interfaceutil.Attribute( - """VFS used to access the working directory.""" - ) - - vfs = interfaceutil.Attribute( - """VFS rooted at the .hg directory. - - Used to access repository data not in the store. - """ - ) - - svfs = interfaceutil.Attribute( - """VFS rooted at the store. - - Used to access repository data in the store. Typically .hg/store. - But can point elsewhere if the store is shared. - """ - ) - - root = interfaceutil.Attribute( - """Path to the root of the working directory.""" - ) - - path = interfaceutil.Attribute("""Path to the .hg directory.""") - - origroot = interfaceutil.Attribute( - """The filesystem path that was used to construct the repo.""" - ) - - auditor = interfaceutil.Attribute( - """A pathauditor for the working directory. - - This checks if a path refers to a nested repository. - - Operates on the filesystem. - """ - ) - - nofsauditor = interfaceutil.Attribute( - """A pathauditor for the working directory. - - This is like ``auditor`` except it doesn't do filesystem checks. - """ - ) - - baseui = interfaceutil.Attribute( - """Original ui instance passed into constructor.""" - ) - - ui = interfaceutil.Attribute("""Main ui instance for this instance.""") - - sharedpath = interfaceutil.Attribute( - """Path to the .hg directory of the repo this repo was shared from.""" - ) - - store = interfaceutil.Attribute("""A store instance.""") - - spath = interfaceutil.Attribute("""Path to the store.""") - - sjoin = interfaceutil.Attribute("""Alias to self.store.join.""") - - cachevfs = interfaceutil.Attribute( - """A VFS used to access the cache directory. - - Typically .hg/cache. - """ - ) - - wcachevfs = interfaceutil.Attribute( - """A VFS used to access the cache directory dedicated to working copy - - Typically .hg/wcache. - """ - ) - - filteredrevcache = interfaceutil.Attribute( - """Holds sets of revisions to be filtered.""" - ) - - names = interfaceutil.Attribute("""A ``namespaces`` instance.""") - - filecopiesmode = interfaceutil.Attribute( - """The way files copies should be dealt with in this repo.""" - ) + nodeconstants: NodeConstants + """Constant nodes matching the hash function used by the repository.""" + + nullid: bytes + """null revision for the hash function used by the repository.""" + + supported: set[bytes] + """Set of requirements that this repo is capable of opening.""" + + requirements: set[bytes] + """Set of requirements this repo uses.""" + + features: set[bytes] + """Set of "features" this repository supports. + + A "feature" is a loosely-defined term. It can refer to a feature + in the classical sense or can describe an implementation detail + of the repository. For example, a ``readonly`` feature may denote + the repository as read-only. Or a ``revlogfilestore`` feature may + denote that the repository is using revlogs for file storage. + + The intent of features is to provide a machine-queryable mechanism + for repo consumers to test for various repository characteristics. + + Features are similar to ``requirements``. The main difference is that + requirements are stored on-disk and represent requirements to open the + repository. Features are more run-time capabilities of the repository + and more granular capabilities (which may be derived from requirements). + """ + + filtername: bytes + """Name of the repoview that is active on this repo.""" + + vfs_map: Mapping[bytes, Vfs] + """a bytes-key → vfs mapping used by transaction and others""" + + wvfs: Vfs + """VFS used to access the working directory.""" + + vfs: Vfs + """VFS rooted at the .hg directory. + + Used to access repository data not in the store. + """ + + svfs: Vfs + """VFS rooted at the store. + + Used to access repository data in the store. Typically .hg/store. + But can point elsewhere if the store is shared. + """ + + root: bytes + """Path to the root of the working directory.""" + + path: bytes + """Path to the .hg directory.""" + + origroot: bytes + """The filesystem path that was used to construct the repo.""" + + auditor: Any + """A pathauditor for the working directory. + + This checks if a path refers to a nested repository. + + Operates on the filesystem. + """ + + nofsauditor: Any # TODO: add type hints + """A pathauditor for the working directory. + + This is like ``auditor`` except it doesn't do filesystem checks. + """ + + baseui: Ui + """Original ui instance passed into constructor.""" + + ui: Ui + """Main ui instance for this instance.""" + + sharedpath: bytes + """Path to the .hg directory of the repo this repo was shared from.""" + + store: Any # TODO: add type hints + """A store instance.""" + + spath: bytes + """Path to the store.""" + + sjoin: Callable # TODO: add type hints + """Alias to self.store.join.""" + + cachevfs: Vfs + """A VFS used to access the cache directory. + + Typically .hg/cache. + """ + + wcachevfs: Vfs + """A VFS used to access the cache directory dedicated to working copy + + Typically .hg/wcache. + """ + + filteredrevcache: Any # TODO: add type hints + """Holds sets of revisions to be filtered.""" + + names: Any # TODO: add type hints + """A ``namespaces`` instance.""" + + filecopiesmode: Any # TODO: add type hints + """The way files copies should be dealt with in this repo.""" def close(self): """Close the handle on this repository.""" @@ -1771,22 +1764,23 @@ def filtered(self, name, visibilityexceptions=None): """Obtain a named view of this repository.""" - obsstore = interfaceutil.Attribute("""A store of obsolescence data.""") - - changelog = interfaceutil.Attribute("""A handle on the changelog revlog.""") - - manifestlog = interfaceutil.Attribute( - """An instance conforming to the ``imanifestlog`` interface. - - Provides access to manifests for the repository. - """ - ) - - dirstate = interfaceutil.Attribute("""Working directory state.""") - - narrowpats = interfaceutil.Attribute( - """Matcher patterns for this repository's narrowspec.""" - ) + obsstore: Any # TODO: add type hints + """A store of obsolescence data.""" + + changelog: Any # TODO: add type hints + """A handle on the changelog revlog.""" + + manifestlog: imanifestlog + """An instance conforming to the ``imanifestlog`` interface. + + Provides access to manifests for the repository. + """ + + dirstate: intdirstate.idirstate + """Working directory state.""" + + narrowpats: Any # TODO: add type hints + """Matcher patterns for this repository's narrowspec.""" def narrowmatch(self, match=None, includeexact=False): """Obtain a matcher for the narrowspec.""" @@ -2025,7 +2019,8 @@ def checkpush(self, pushop): pass - prepushoutgoinghooks = interfaceutil.Attribute("""util.hooks instance.""") + prepushoutgoinghooks: util.hooks + """util.hooks instance.""" def pushkey(self, namespace, key, old, new): pass