Mercurial > public > mercurial-scm > hg
comparison 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 |
comparison
equal
deleted
inserted
replaced
39849:d3d4b4b5f725 | 39850:d89d5bc06eaa |
---|---|
16 ) | 16 ) |
17 | 17 |
18 # When narrowing is finalized and no longer subject to format changes, | 18 # When narrowing is finalized and no longer subject to format changes, |
19 # we should move this to just "narrow" or similar. | 19 # we should move this to just "narrow" or similar. |
20 NARROW_REQUIREMENT = 'narrowhg-experimental' | 20 NARROW_REQUIREMENT = 'narrowhg-experimental' |
21 | |
22 # Local repository feature string. | |
23 | |
24 # Revlogs are being used for file storage. | |
25 REPO_FEATURE_REVLOG_FILE_STORAGE = b'revlogfilestorage' | |
26 # The storage part of the repository is shared from an external source. | |
27 REPO_FEATURE_SHARED_STORAGE = b'sharedstore' | |
21 | 28 |
22 class ipeerconnection(interfaceutil.Interface): | 29 class ipeerconnection(interfaceutil.Interface): |
23 """Represents a "connection" to a repository. | 30 """Represents a "connection" to a repository. |
24 | 31 |
25 This is the base interface for representing a connection to a repository. | 32 This is the base interface for representing a connection to a repository. |
1273 """Set of requirements that this repo is capable of opening.""") | 1280 """Set of requirements that this repo is capable of opening.""") |
1274 | 1281 |
1275 requirements = interfaceutil.Attribute( | 1282 requirements = interfaceutil.Attribute( |
1276 """Set of requirements this repo uses.""") | 1283 """Set of requirements this repo uses.""") |
1277 | 1284 |
1285 features = interfaceutil.Attribute( | |
1286 """Set of "features" this repository supports. | |
1287 | |
1288 A "feature" is a loosely-defined term. It can refer to a feature | |
1289 in the classical sense or can describe an implementation detail | |
1290 of the repository. For example, a ``readonly`` feature may denote | |
1291 the repository as read-only. Or a ``revlogfilestore`` feature may | |
1292 denote that the repository is using revlogs for file storage. | |
1293 | |
1294 The intent of features is to provide a machine-queryable mechanism | |
1295 for repo consumers to test for various repository characteristics. | |
1296 | |
1297 Features are similar to ``requirements``. The main difference is that | |
1298 requirements are stored on-disk and represent requirements to open the | |
1299 repository. Features are more run-time capabilities of the repository | |
1300 and more granular capabilities (which may be derived from requirements). | |
1301 """) | |
1302 | |
1278 filtername = interfaceutil.Attribute( | 1303 filtername = interfaceutil.Attribute( |
1279 """Name of the repoview that is active on this repo.""") | 1304 """Name of the repoview that is active on this repo.""") |
1280 | 1305 |
1281 wvfs = interfaceutil.Attribute( | 1306 wvfs = interfaceutil.Attribute( |
1282 """VFS used to access the working directory.""") | 1307 """VFS used to access the working directory.""") |