Mercurial > public > mercurial-scm > hg
diff mercurial/repository.py @ 39850:d89d5bc06eaa
localrepo: define "features" on repository instances (API)
There are a handful of attributes/methods on repository instances that
describe the behavior of the repository. Furthermore, there is
an unbound set of repository descriptors that we may wish to expose.
For example, an extension may wish to add a descriptor and have
monkeypatched functions look for the presence of an attribute before
taking actions.
This commit introduces a "features" mechanism to allow repositories
to self-advertise an arbitrary set of strings that describe repository
behavior or capabilities.
We implement basic support for advertising a few features to give an
idea of what I want to use this for.
Differential Revision: https://phab.mercurial-scm.org/D4709
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Wed, 19 Sep 2018 14:36:57 -0700 |
parents | 0cb3e02e1d1b |
children | 1f7b3b980af8 |
line wrap: on
line diff
--- a/mercurial/repository.py Wed Sep 19 17:27:37 2018 -0700 +++ b/mercurial/repository.py Wed Sep 19 14:36:57 2018 -0700 @@ -19,6 +19,13 @@ # we should move this to just "narrow" or similar. NARROW_REQUIREMENT = 'narrowhg-experimental' +# Local repository feature string. + +# Revlogs are being used for file storage. +REPO_FEATURE_REVLOG_FILE_STORAGE = b'revlogfilestorage' +# The storage part of the repository is shared from an external source. +REPO_FEATURE_SHARED_STORAGE = b'sharedstore' + class ipeerconnection(interfaceutil.Interface): """Represents a "connection" to a repository. @@ -1275,6 +1282,24 @@ 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.""")