annotate mercurial/interfaces/repository.py @ 52741:5c48fd4c0e68

typing: introduce a `types` module and a MatcherT alias This is a proposal to formalise the way we do typing and do more of it. The initial motivation to make progress is to help break the 100+ module cycle that is slowing pytype a lot.
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Thu, 30 Jan 2025 18:22:01 +0100
parents 0f2268783c11
children 483b0bb23085
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
33800
f257943e47ab repository: formalize peer interface with abstract base class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
1 # repository.py - Interfaces and base classes for repositories and peers.
f257943e47ab repository: formalize peer interface with abstract base class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
2 #
f257943e47ab repository: formalize peer interface with abstract base class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
3 # Copyright 2017 Gregory Szorc <gregory.szorc@gmail.com>
f257943e47ab repository: formalize peer interface with abstract base class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
4 #
f257943e47ab repository: formalize peer interface with abstract base class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
5 # This software may be used and distributed according to the terms of the
f257943e47ab repository: formalize peer interface with abstract base class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
6 # GNU General Public License version 2 or any later version.
f257943e47ab repository: formalize peer interface with abstract base class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
7
51859
f4733654f144 typing: add `from __future__ import annotations` to most files
Matt Harbison <matt_harbison@yahoo.com>
parents: 51781
diff changeset
8 from __future__ import annotations
33800
f257943e47ab repository: formalize peer interface with abstract base class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
9
52475
cdd4bc69bfc1 interfaces: convert `imanifestrevisionstored` to a Protocol class
Matt Harbison <matt_harbison@yahoo.com>
parents: 52474
diff changeset
10 import abc
52463
0cfcc276b796 interfaces: convert `repository.ipeerconnection` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52462
diff changeset
11 import typing
0cfcc276b796 interfaces: convert `repository.ipeerconnection` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52462
diff changeset
12
52445
26dd402c3497 interfaces: convert the repository zope interfaces to Protocol classes
Matt Harbison <matt_harbison@yahoo.com>
parents: 52432
diff changeset
13 from typing import (
52463
0cfcc276b796 interfaces: convert `repository.ipeerconnection` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52462
diff changeset
14 Any,
52485
dfb60fb155da interfaces: convert `ilocalrepositorymain` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52483
diff changeset
15 Callable,
52474
048c11993d6a typing: (mostly) align the signatures of `imanifestrevisionstored` overrides
Matt Harbison <matt_harbison@yahoo.com>
parents: 52473
diff changeset
16 Collection,
52487
3daaa5195a30 typing: align the signatures of `repository.ifilestorage` overrides
Matt Harbison <matt_harbison@yahoo.com>
parents: 52486
diff changeset
17 Iterable,
3daaa5195a30 typing: align the signatures of `repository.ifilestorage` overrides
Matt Harbison <matt_harbison@yahoo.com>
parents: 52486
diff changeset
18 Iterator,
52485
dfb60fb155da interfaces: convert `ilocalrepositorymain` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52483
diff changeset
19 Mapping,
52445
26dd402c3497 interfaces: convert the repository zope interfaces to Protocol classes
Matt Harbison <matt_harbison@yahoo.com>
parents: 52432
diff changeset
20 Protocol,
52492
48cdbd4d5443 typing: align the signatures of `repository.imanifestdict` overrides
Matt Harbison <matt_harbison@yahoo.com>
parents: 52490
diff changeset
21 Set,
52445
26dd402c3497 interfaces: convert the repository zope interfaces to Protocol classes
Matt Harbison <matt_harbison@yahoo.com>
parents: 52432
diff changeset
22 )
26dd402c3497 interfaces: convert the repository zope interfaces to Protocol classes
Matt Harbison <matt_harbison@yahoo.com>
parents: 52432
diff changeset
23
42813
268662aac075 interfaces: create a new folder for interfaces and move repository.py in it
Pulkit Goyal <pulkit@yandex-team.ru>
parents: 42779
diff changeset
24 from ..i18n import _
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43032
diff changeset
25 from .. import error
33802
a0aad86b3b6a repository: implement generic capability methods on peer class
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33801
diff changeset
26
52463
0cfcc276b796 interfaces: convert `repository.ipeerconnection` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52462
diff changeset
27 if typing.TYPE_CHECKING:
52492
48cdbd4d5443 typing: align the signatures of `repository.imanifestdict` overrides
Matt Harbison <matt_harbison@yahoo.com>
parents: 52490
diff changeset
28 from typing import (
48cdbd4d5443 typing: align the signatures of `repository.imanifestdict` overrides
Matt Harbison <matt_harbison@yahoo.com>
parents: 52490
diff changeset
29 ByteString, # TODO: change to Buffer for 3.14
48cdbd4d5443 typing: align the signatures of `repository.imanifestdict` overrides
Matt Harbison <matt_harbison@yahoo.com>
parents: 52490
diff changeset
30 )
48cdbd4d5443 typing: align the signatures of `repository.imanifestdict` overrides
Matt Harbison <matt_harbison@yahoo.com>
parents: 52490
diff changeset
31
52463
0cfcc276b796 interfaces: convert `repository.ipeerconnection` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52462
diff changeset
32 # Almost all mercurial modules are only imported in the type checking phase
0cfcc276b796 interfaces: convert `repository.ipeerconnection` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52462
diff changeset
33 # to avoid circular imports
52485
dfb60fb155da interfaces: convert `ilocalrepositorymain` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52483
diff changeset
34 from .. import (
52492
48cdbd4d5443 typing: align the signatures of `repository.imanifestdict` overrides
Matt Harbison <matt_harbison@yahoo.com>
parents: 52490
diff changeset
35 pathutil,
52485
dfb60fb155da interfaces: convert `ilocalrepositorymain` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52483
diff changeset
36 util,
dfb60fb155da interfaces: convert `ilocalrepositorymain` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52483
diff changeset
37 )
52463
0cfcc276b796 interfaces: convert `repository.ipeerconnection` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52462
diff changeset
38 from ..utils import (
0cfcc276b796 interfaces: convert `repository.ipeerconnection` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52462
diff changeset
39 urlutil,
0cfcc276b796 interfaces: convert `repository.ipeerconnection` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52462
diff changeset
40 )
0cfcc276b796 interfaces: convert `repository.ipeerconnection` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52462
diff changeset
41
52741
5c48fd4c0e68 typing: introduce a `types` module and a MatcherT alias
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 52725
diff changeset
42 from . import (
5c48fd4c0e68 typing: introduce a `types` module and a MatcherT alias
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 52725
diff changeset
43 dirstate as intdirstate,
5c48fd4c0e68 typing: introduce a `types` module and a MatcherT alias
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 52725
diff changeset
44 matcher,
5c48fd4c0e68 typing: introduce a `types` module and a MatcherT alias
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 52725
diff changeset
45 )
52485
dfb60fb155da interfaces: convert `ilocalrepositorymain` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52483
diff changeset
46
52478
d01af74e67b4 interfaces: convert `repository.imanifeststorage` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52476
diff changeset
47 # TODO: make a protocol class for this
d01af74e67b4 interfaces: convert `repository.imanifeststorage` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52476
diff changeset
48 NodeConstants = Any
d01af74e67b4 interfaces: convert `repository.imanifeststorage` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52476
diff changeset
49
52463
0cfcc276b796 interfaces: convert `repository.ipeerconnection` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52462
diff changeset
50 # TODO: create a Protocol class, since importing uimod here causes a cycle
0cfcc276b796 interfaces: convert `repository.ipeerconnection` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52462
diff changeset
51 # that confuses pytype.
0cfcc276b796 interfaces: convert `repository.ipeerconnection` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52462
diff changeset
52 Ui = Any
0cfcc276b796 interfaces: convert `repository.ipeerconnection` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52462
diff changeset
53
52478
d01af74e67b4 interfaces: convert `repository.imanifeststorage` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52476
diff changeset
54 # TODO: make a protocol class for this
d01af74e67b4 interfaces: convert `repository.imanifeststorage` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52476
diff changeset
55 Vfs = Any
d01af74e67b4 interfaces: convert `repository.imanifeststorage` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52476
diff changeset
56
39850
d89d5bc06eaa localrepo: define "features" on repository instances (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39844
diff changeset
57 # Local repository feature string.
d89d5bc06eaa localrepo: define "features" on repository instances (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39844
diff changeset
58
d89d5bc06eaa localrepo: define "features" on repository instances (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39844
diff changeset
59 # Revlogs are being used for file storage.
d89d5bc06eaa localrepo: define "features" on repository instances (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39844
diff changeset
60 REPO_FEATURE_REVLOG_FILE_STORAGE = b'revlogfilestorage'
d89d5bc06eaa localrepo: define "features" on repository instances (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39844
diff changeset
61 # The storage part of the repository is shared from an external source.
d89d5bc06eaa localrepo: define "features" on repository instances (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39844
diff changeset
62 REPO_FEATURE_SHARED_STORAGE = b'sharedstore'
39851
1f7b3b980af8 lfs: add repository feature denoting the use of LFS
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39850
diff changeset
63 # LFS supported for backing file storage.
1f7b3b980af8 lfs: add repository feature denoting the use of LFS
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39850
diff changeset
64 REPO_FEATURE_LFS = b'lfs'
40027
83146d176c03 localrepo: add repository feature when repo can be stream cloned
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40021
diff changeset
65 # Repository supports being stream cloned.
83146d176c03 localrepo: add repository feature when repo can be stream cloned
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40021
diff changeset
66 REPO_FEATURE_STREAM_CLONE = b'streamclone'
47226
19d4802cb304 sidedata: add a 'side-data' repository feature and use it
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47146
diff changeset
67 # Repository supports (at least) some sidedata to be stored
19d4802cb304 sidedata: add a 'side-data' repository feature and use it
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47146
diff changeset
68 REPO_FEATURE_SIDE_DATA = b'side-data'
40390
7e3b6c4f01a2 localrepo: support marking repos as having shallow file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40389
diff changeset
69 # Files storage may lack data for all ancestors.
7e3b6c4f01a2 localrepo: support marking repos as having shallow file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40389
diff changeset
70 REPO_FEATURE_SHALLOW_FILE_STORAGE = b'shallowfilestorage'
39850
d89d5bc06eaa localrepo: define "features" on repository instances (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39844
diff changeset
71
40047
8e398628a3f2 repository: define and use revision flag constants
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40027
diff changeset
72 REVISION_FLAG_CENSORED = 1 << 15
8e398628a3f2 repository: define and use revision flag constants
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40027
diff changeset
73 REVISION_FLAG_ELLIPSIS = 1 << 14
8e398628a3f2 repository: define and use revision flag constants
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40027
diff changeset
74 REVISION_FLAG_EXTSTORED = 1 << 13
47077
119790e1c67c cg4: introduce protocol flag to signify the presence of sidedata
Rapha?l Gom?s <rgomes@octobus.net>
parents: 46780
diff changeset
75 REVISION_FLAG_HASCOPIESINFO = 1 << 12
40047
8e398628a3f2 repository: define and use revision flag constants
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40027
diff changeset
76
8e398628a3f2 repository: define and use revision flag constants
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40027
diff changeset
77 REVISION_FLAGS_KNOWN = (
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43032
diff changeset
78 REVISION_FLAG_CENSORED
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43032
diff changeset
79 | REVISION_FLAG_ELLIPSIS
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43032
diff changeset
80 | REVISION_FLAG_EXTSTORED
45671
2d6aea053153 copies: add a HASCOPIESINFO flag to highlight rev with useful data
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 45372
diff changeset
81 | REVISION_FLAG_HASCOPIESINFO
43032
a12a9af7536c sidedata: add a new revision flag constant for side data
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42814
diff changeset
82 )
40047
8e398628a3f2 repository: define and use revision flag constants
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40027
diff changeset
83
40427
59a870a4ad6e changegroup: refactor emitrevision to use a `deltamode` argument
Boris Feld <boris.feld@octobus.net>
parents: 40390
diff changeset
84 CG_DELTAMODE_STD = b'default'
59a870a4ad6e changegroup: refactor emitrevision to use a `deltamode` argument
Boris Feld <boris.feld@octobus.net>
parents: 40390
diff changeset
85 CG_DELTAMODE_PREV = b'previous'
59a870a4ad6e changegroup: refactor emitrevision to use a `deltamode` argument
Boris Feld <boris.feld@octobus.net>
parents: 40390
diff changeset
86 CG_DELTAMODE_FULL = b'fulltext'
40432
968dd7e02ac5 changegroup: allow to force delta to be against p1
Boris Feld <boris.feld@octobus.net>
parents: 40430
diff changeset
87 CG_DELTAMODE_P1 = b'p1'
40427
59a870a4ad6e changegroup: refactor emitrevision to use a `deltamode` argument
Boris Feld <boris.feld@octobus.net>
parents: 40390
diff changeset
88
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43032
diff changeset
89
47296
d1589957fdcb updatecaches: introduce a set of constants to control which are updated
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47226
diff changeset
90 ## Cache related constants:
d1589957fdcb updatecaches: introduce a set of constants to control which are updated
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47226
diff changeset
91 #
d1589957fdcb updatecaches: introduce a set of constants to control which are updated
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47226
diff changeset
92 # Used to control which cache should be warmed in a repo.updatecaches(…) call.
d1589957fdcb updatecaches: introduce a set of constants to control which are updated
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47226
diff changeset
93
d1589957fdcb updatecaches: introduce a set of constants to control which are updated
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47226
diff changeset
94 # Warm branchmaps of all known repoview's filter-level
d1589957fdcb updatecaches: introduce a set of constants to control which are updated
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47226
diff changeset
95 CACHE_BRANCHMAP_ALL = b"branchmap-all"
d1589957fdcb updatecaches: introduce a set of constants to control which are updated
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47226
diff changeset
96 # Warm branchmaps of repoview's filter-level used by server
d1589957fdcb updatecaches: introduce a set of constants to control which are updated
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47226
diff changeset
97 CACHE_BRANCHMAP_SERVED = b"branchmap-served"
d1589957fdcb updatecaches: introduce a set of constants to control which are updated
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47226
diff changeset
98 # Warm internal changelog cache (eg: persistent nodemap)
d1589957fdcb updatecaches: introduce a set of constants to control which are updated
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47226
diff changeset
99 CACHE_CHANGELOG_CACHE = b"changelog-cache"
51534
4a8bb136ee77 branchcache: allow to detect "pure topological case" for branchmap
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51044
diff changeset
100 # check of a branchmap can use the "pure topo" mode
4a8bb136ee77 branchcache: allow to detect "pure topological case" for branchmap
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51044
diff changeset
101 CACHE_BRANCHMAP_DETECT_PURE_TOPO = b"branchmap-detect-pure-topo"
47296
d1589957fdcb updatecaches: introduce a set of constants to control which are updated
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47226
diff changeset
102 # Warm full manifest cache
d1589957fdcb updatecaches: introduce a set of constants to control which are updated
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47226
diff changeset
103 CACHE_FULL_MANIFEST = b"full-manifest"
d1589957fdcb updatecaches: introduce a set of constants to control which are updated
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47226
diff changeset
104 # Warm file-node-tags cache
d1589957fdcb updatecaches: introduce a set of constants to control which are updated
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47226
diff changeset
105 CACHE_FILE_NODE_TAGS = b"file-node-tags"
d1589957fdcb updatecaches: introduce a set of constants to control which are updated
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47226
diff changeset
106 # Warm internal manifestlog cache (eg: persistent nodemap)
d1589957fdcb updatecaches: introduce a set of constants to control which are updated
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47226
diff changeset
107 CACHE_MANIFESTLOG_CACHE = b"manifestlog-cache"
d1589957fdcb updatecaches: introduce a set of constants to control which are updated
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47226
diff changeset
108 # Warn rev branch cache
d1589957fdcb updatecaches: introduce a set of constants to control which are updated
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47226
diff changeset
109 CACHE_REV_BRANCH = b"rev-branch-cache"
d1589957fdcb updatecaches: introduce a set of constants to control which are updated
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47226
diff changeset
110 # Warm tags' cache for default repoview'
d1589957fdcb updatecaches: introduce a set of constants to control which are updated
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47226
diff changeset
111 CACHE_TAGS_DEFAULT = b"tags-default"
d1589957fdcb updatecaches: introduce a set of constants to control which are updated
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47226
diff changeset
112 # Warm tags' cache for repoview's filter-level used by server
d1589957fdcb updatecaches: introduce a set of constants to control which are updated
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47226
diff changeset
113 CACHE_TAGS_SERVED = b"tags-served"
d1589957fdcb updatecaches: introduce a set of constants to control which are updated
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47226
diff changeset
114
d1589957fdcb updatecaches: introduce a set of constants to control which are updated
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47226
diff changeset
115 # the cache to warm by default after a simple transaction
d1589957fdcb updatecaches: introduce a set of constants to control which are updated
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47226
diff changeset
116 # (this is a mutable set to let extension update it)
d1589957fdcb updatecaches: introduce a set of constants to control which are updated
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47226
diff changeset
117 CACHES_DEFAULT = {
d1589957fdcb updatecaches: introduce a set of constants to control which are updated
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47226
diff changeset
118 CACHE_BRANCHMAP_SERVED,
d1589957fdcb updatecaches: introduce a set of constants to control which are updated
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47226
diff changeset
119 }
d1589957fdcb updatecaches: introduce a set of constants to control which are updated
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47226
diff changeset
120
d1589957fdcb updatecaches: introduce a set of constants to control which are updated
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47226
diff changeset
121 # the caches to warm when warming all of them
d1589957fdcb updatecaches: introduce a set of constants to control which are updated
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47226
diff changeset
122 # (this is a mutable set to let extension update it)
d1589957fdcb updatecaches: introduce a set of constants to control which are updated
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47226
diff changeset
123 CACHES_ALL = {
d1589957fdcb updatecaches: introduce a set of constants to control which are updated
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47226
diff changeset
124 CACHE_BRANCHMAP_SERVED,
d1589957fdcb updatecaches: introduce a set of constants to control which are updated
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47226
diff changeset
125 CACHE_BRANCHMAP_ALL,
51534
4a8bb136ee77 branchcache: allow to detect "pure topological case" for branchmap
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51044
diff changeset
126 CACHE_BRANCHMAP_DETECT_PURE_TOPO,
51905
e51161b12c7e rev-branch-cache: have debugupdatecache warm rbc too
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51868
diff changeset
127 CACHE_REV_BRANCH,
47296
d1589957fdcb updatecaches: introduce a set of constants to control which are updated
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47226
diff changeset
128 CACHE_CHANGELOG_CACHE,
d1589957fdcb updatecaches: introduce a set of constants to control which are updated
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47226
diff changeset
129 CACHE_FILE_NODE_TAGS,
d1589957fdcb updatecaches: introduce a set of constants to control which are updated
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47226
diff changeset
130 CACHE_FULL_MANIFEST,
d1589957fdcb updatecaches: introduce a set of constants to control which are updated
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47226
diff changeset
131 CACHE_MANIFESTLOG_CACHE,
d1589957fdcb updatecaches: introduce a set of constants to control which are updated
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47226
diff changeset
132 CACHE_TAGS_DEFAULT,
d1589957fdcb updatecaches: introduce a set of constants to control which are updated
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47226
diff changeset
133 CACHE_TAGS_SERVED,
d1589957fdcb updatecaches: introduce a set of constants to control which are updated
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47226
diff changeset
134 }
d1589957fdcb updatecaches: introduce a set of constants to control which are updated
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47226
diff changeset
135
47299
7edaf91c7886 updatecaches: use the `caches` argument instead of a special `full` value
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47296
diff changeset
136 # the cache to warm by default on simple call
7edaf91c7886 updatecaches: use the `caches` argument instead of a special `full` value
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47296
diff changeset
137 # (this is a mutable set to let extension update it)
7edaf91c7886 updatecaches: use the `caches` argument instead of a special `full` value
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47296
diff changeset
138 CACHES_POST_CLONE = CACHES_ALL.copy()
7edaf91c7886 updatecaches: use the `caches` argument instead of a special `full` value
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47296
diff changeset
139 CACHES_POST_CLONE.discard(CACHE_FILE_NODE_TAGS)
52241
d57d1606049c clone: properly exclude rev-branch-cache from post clone cache warming
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51905
diff changeset
140 CACHES_POST_CLONE.discard(CACHE_REV_BRANCH)
47299
7edaf91c7886 updatecaches: use the `caches` argument instead of a special `full` value
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47296
diff changeset
141
47296
d1589957fdcb updatecaches: introduce a set of constants to control which are updated
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47226
diff changeset
142
52464
73a46cef57c9 interfaces: rename `repository.ipeerconnection` to reflect it being private
Matt Harbison <matt_harbison@yahoo.com>
parents: 52463
diff changeset
143 class _ipeerconnection(Protocol):
33800
f257943e47ab repository: formalize peer interface with abstract base class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
144 """Represents a "connection" to a repository.
f257943e47ab repository: formalize peer interface with abstract base class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
145
f257943e47ab repository: formalize peer interface with abstract base class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
146 This is the base interface for representing a connection to a repository.
f257943e47ab repository: formalize peer interface with abstract base class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
147 It holds basic properties and methods applicable to all peer types.
f257943e47ab repository: formalize peer interface with abstract base class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
148
f257943e47ab repository: formalize peer interface with abstract base class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
149 This is not a complete interface definition and should not be used
f257943e47ab repository: formalize peer interface with abstract base class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
150 outside of this module.
f257943e47ab repository: formalize peer interface with abstract base class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
151 """
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43032
diff changeset
152
52463
0cfcc276b796 interfaces: convert `repository.ipeerconnection` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52462
diff changeset
153 ui: Ui
0cfcc276b796 interfaces: convert `repository.ipeerconnection` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52462
diff changeset
154 """ui.ui instance"""
0cfcc276b796 interfaces: convert `repository.ipeerconnection` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52462
diff changeset
155
0cfcc276b796 interfaces: convert `repository.ipeerconnection` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52462
diff changeset
156 path: urlutil.path | None
0cfcc276b796 interfaces: convert `repository.ipeerconnection` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52462
diff changeset
157 """a urlutil.path instance or None"""
33800
f257943e47ab repository: formalize peer interface with abstract base class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
158
52499
9358d786af24 interfaces: make all methods on any repository Protocol class abstract
Matt Harbison <matt_harbison@yahoo.com>
parents: 52497
diff changeset
159 @abc.abstractmethod
52446
c1674551c109 interfaces: add the missing `self` arg to the repository Protocol classes
Matt Harbison <matt_harbison@yahoo.com>
parents: 52445
diff changeset
160 def url(self):
33800
f257943e47ab repository: formalize peer interface with abstract base class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
161 """Returns a URL string representing this peer.
f257943e47ab repository: formalize peer interface with abstract base class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
162
f257943e47ab repository: formalize peer interface with abstract base class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
163 Currently, implementations expose the raw URL used to construct the
f257943e47ab repository: formalize peer interface with abstract base class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
164 instance. It may contain credentials as part of the URL. The
f257943e47ab repository: formalize peer interface with abstract base class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
165 expectations of the value aren't well-defined and this could lead to
f257943e47ab repository: formalize peer interface with abstract base class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
166 data leakage.
f257943e47ab repository: formalize peer interface with abstract base class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
167
f257943e47ab repository: formalize peer interface with abstract base class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
168 TODO audit/clean consumers and more clearly define the contents of this
f257943e47ab repository: formalize peer interface with abstract base class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
169 value.
f257943e47ab repository: formalize peer interface with abstract base class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
170 """
f257943e47ab repository: formalize peer interface with abstract base class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
171
52499
9358d786af24 interfaces: make all methods on any repository Protocol class abstract
Matt Harbison <matt_harbison@yahoo.com>
parents: 52497
diff changeset
172 @abc.abstractmethod
52446
c1674551c109 interfaces: add the missing `self` arg to the repository Protocol classes
Matt Harbison <matt_harbison@yahoo.com>
parents: 52445
diff changeset
173 def local(self):
33800
f257943e47ab repository: formalize peer interface with abstract base class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
174 """Returns a local repository instance.
f257943e47ab repository: formalize peer interface with abstract base class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
175
f257943e47ab repository: formalize peer interface with abstract base class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
176 If the peer represents a local repository, returns an object that
f257943e47ab repository: formalize peer interface with abstract base class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
177 can be used to interface with it. Otherwise returns ``None``.
f257943e47ab repository: formalize peer interface with abstract base class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
178 """
f257943e47ab repository: formalize peer interface with abstract base class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
179
52499
9358d786af24 interfaces: make all methods on any repository Protocol class abstract
Matt Harbison <matt_harbison@yahoo.com>
parents: 52497
diff changeset
180 @abc.abstractmethod
52446
c1674551c109 interfaces: add the missing `self` arg to the repository Protocol classes
Matt Harbison <matt_harbison@yahoo.com>
parents: 52445
diff changeset
181 def canpush(self):
33800
f257943e47ab repository: formalize peer interface with abstract base class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
182 """Returns a boolean indicating if this peer can be pushed to."""
f257943e47ab repository: formalize peer interface with abstract base class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
183
52499
9358d786af24 interfaces: make all methods on any repository Protocol class abstract
Matt Harbison <matt_harbison@yahoo.com>
parents: 52497
diff changeset
184 @abc.abstractmethod
52446
c1674551c109 interfaces: add the missing `self` arg to the repository Protocol classes
Matt Harbison <matt_harbison@yahoo.com>
parents: 52445
diff changeset
185 def close(self):
33800
f257943e47ab repository: formalize peer interface with abstract base class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
186 """Close the connection to this peer.
f257943e47ab repository: formalize peer interface with abstract base class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
187
f257943e47ab repository: formalize peer interface with abstract base class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
188 This is called when the peer will no longer be used. Resources
f257943e47ab repository: formalize peer interface with abstract base class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
189 associated with the peer should be cleaned up.
f257943e47ab repository: formalize peer interface with abstract base class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
190 """
f257943e47ab repository: formalize peer interface with abstract base class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
191
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43032
diff changeset
192
52445
26dd402c3497 interfaces: convert the repository zope interfaces to Protocol classes
Matt Harbison <matt_harbison@yahoo.com>
parents: 52432
diff changeset
193 class ipeercapabilities(Protocol):
37610
98861a2298b5 repository: split capabilities methods into separate interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37440
diff changeset
194 """Peer sub-interface related to capabilities."""
98861a2298b5 repository: split capabilities methods into separate interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37440
diff changeset
195
52499
9358d786af24 interfaces: make all methods on any repository Protocol class abstract
Matt Harbison <matt_harbison@yahoo.com>
parents: 52497
diff changeset
196 @abc.abstractmethod
52518
5a924cb07768 typing: add annotations to the `repository.peer` mixin class
Matt Harbison <matt_harbison@yahoo.com>
parents: 52506
diff changeset
197 def capable(self, name: bytes) -> bool | bytes:
37610
98861a2298b5 repository: split capabilities methods into separate interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37440
diff changeset
198 """Determine support for a named capability.
98861a2298b5 repository: split capabilities methods into separate interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37440
diff changeset
199
98861a2298b5 repository: split capabilities methods into separate interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37440
diff changeset
200 Returns ``False`` if capability not supported.
98861a2298b5 repository: split capabilities methods into separate interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37440
diff changeset
201
98861a2298b5 repository: split capabilities methods into separate interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37440
diff changeset
202 Returns ``True`` if boolean capability is supported. Returns a string
98861a2298b5 repository: split capabilities methods into separate interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37440
diff changeset
203 if capability support is non-boolean.
98861a2298b5 repository: split capabilities methods into separate interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37440
diff changeset
204
98861a2298b5 repository: split capabilities methods into separate interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37440
diff changeset
205 Capability strings may or may not map to wire protocol capabilities.
98861a2298b5 repository: split capabilities methods into separate interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37440
diff changeset
206 """
98861a2298b5 repository: split capabilities methods into separate interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37440
diff changeset
207
52499
9358d786af24 interfaces: make all methods on any repository Protocol class abstract
Matt Harbison <matt_harbison@yahoo.com>
parents: 52497
diff changeset
208 @abc.abstractmethod
52521
b52f2b365eff typing: add type hints to `ipeercapabilities.capabilities()`
Matt Harbison <matt_harbison@yahoo.com>
parents: 52520
diff changeset
209 def capabilities(self) -> Set[bytes]:
52520
1554bd50a1af interfaces: move peer `capabilities()` to the `ipeercapabilities` interface
Matt Harbison <matt_harbison@yahoo.com>
parents: 52518
diff changeset
210 """Obtain capabilities of the peer.
1554bd50a1af interfaces: move peer `capabilities()` to the `ipeercapabilities` interface
Matt Harbison <matt_harbison@yahoo.com>
parents: 52518
diff changeset
211
1554bd50a1af interfaces: move peer `capabilities()` to the `ipeercapabilities` interface
Matt Harbison <matt_harbison@yahoo.com>
parents: 52518
diff changeset
212 Returns a set of string capabilities.
1554bd50a1af interfaces: move peer `capabilities()` to the `ipeercapabilities` interface
Matt Harbison <matt_harbison@yahoo.com>
parents: 52518
diff changeset
213 """
1554bd50a1af interfaces: move peer `capabilities()` to the `ipeercapabilities` interface
Matt Harbison <matt_harbison@yahoo.com>
parents: 52518
diff changeset
214
1554bd50a1af interfaces: move peer `capabilities()` to the `ipeercapabilities` interface
Matt Harbison <matt_harbison@yahoo.com>
parents: 52518
diff changeset
215 @abc.abstractmethod
52518
5a924cb07768 typing: add annotations to the `repository.peer` mixin class
Matt Harbison <matt_harbison@yahoo.com>
parents: 52506
diff changeset
216 def requirecap(self, name: bytes, purpose: bytes) -> None:
37610
98861a2298b5 repository: split capabilities methods into separate interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37440
diff changeset
217 """Require a capability to be present.
98861a2298b5 repository: split capabilities methods into separate interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37440
diff changeset
218
98861a2298b5 repository: split capabilities methods into separate interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37440
diff changeset
219 Raises a ``CapabilityError`` if the capability isn't present.
98861a2298b5 repository: split capabilities methods into separate interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37440
diff changeset
220 """
98861a2298b5 repository: split capabilities methods into separate interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37440
diff changeset
221
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43032
diff changeset
222
52445
26dd402c3497 interfaces: convert the repository zope interfaces to Protocol classes
Matt Harbison <matt_harbison@yahoo.com>
parents: 52432
diff changeset
223 class ipeercommands(Protocol):
33801
558f5b2ee10e repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33800
diff changeset
224 """Client-side interface for communicating over the wire protocol.
558f5b2ee10e repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33800
diff changeset
225
558f5b2ee10e repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33800
diff changeset
226 This interface is used as a gateway to the Mercurial wire protocol.
558f5b2ee10e repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33800
diff changeset
227 methods commonly call wire protocol commands of the same name.
558f5b2ee10e repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33800
diff changeset
228 """
558f5b2ee10e repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33800
diff changeset
229
52497
61f70a6ab645 wirepeer: subclass new `repository.ipeer{,legacy}commands` Proctocol classes
Matt Harbison <matt_harbison@yahoo.com>
parents: 52496
diff changeset
230 @abc.abstractmethod
52446
c1674551c109 interfaces: add the missing `self` arg to the repository Protocol classes
Matt Harbison <matt_harbison@yahoo.com>
parents: 52445
diff changeset
231 def branchmap(self):
33801
558f5b2ee10e repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33800
diff changeset
232 """Obtain heads in named branches.
558f5b2ee10e repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33800
diff changeset
233
558f5b2ee10e repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33800
diff changeset
234 Returns a dict mapping branch name to an iterable of nodes that are
558f5b2ee10e repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33800
diff changeset
235 heads on that branch.
558f5b2ee10e repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33800
diff changeset
236 """
558f5b2ee10e repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33800
diff changeset
237
52497
61f70a6ab645 wirepeer: subclass new `repository.ipeer{,legacy}commands` Proctocol classes
Matt Harbison <matt_harbison@yahoo.com>
parents: 52496
diff changeset
238 @abc.abstractmethod
52446
c1674551c109 interfaces: add the missing `self` arg to the repository Protocol classes
Matt Harbison <matt_harbison@yahoo.com>
parents: 52445
diff changeset
239 def get_cached_bundle_inline(self, path):
50696
2aaabd8f4471 clone-bundle: rename the methods and wireprotole command
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 50663
diff changeset
240 """Retrieve a clonebundle across the wire.
50663
60f9602b413e clonebundles: add support for inline (streaming) clonebundles
Mathias De Mare <mathias.de_mare@nokia.com>
parents: 50634
diff changeset
241
60f9602b413e clonebundles: add support for inline (streaming) clonebundles
Mathias De Mare <mathias.de_mare@nokia.com>
parents: 50634
diff changeset
242 Returns a chunkbuffer
60f9602b413e clonebundles: add support for inline (streaming) clonebundles
Mathias De Mare <mathias.de_mare@nokia.com>
parents: 50634
diff changeset
243 """
60f9602b413e clonebundles: add support for inline (streaming) clonebundles
Mathias De Mare <mathias.de_mare@nokia.com>
parents: 50634
diff changeset
244
52497
61f70a6ab645 wirepeer: subclass new `repository.ipeer{,legacy}commands` Proctocol classes
Matt Harbison <matt_harbison@yahoo.com>
parents: 52496
diff changeset
245 @abc.abstractmethod
52446
c1674551c109 interfaces: add the missing `self` arg to the repository Protocol classes
Matt Harbison <matt_harbison@yahoo.com>
parents: 52445
diff changeset
246 def clonebundles(self):
37649
a168799687e5 wireproto: properly call clonebundles command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37635
diff changeset
247 """Obtains the clone bundles manifest for the repo.
a168799687e5 wireproto: properly call clonebundles command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37635
diff changeset
248
a168799687e5 wireproto: properly call clonebundles command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37635
diff changeset
249 Returns the manifest as unparsed bytes.
a168799687e5 wireproto: properly call clonebundles command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37635
diff changeset
250 """
a168799687e5 wireproto: properly call clonebundles command
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37635
diff changeset
251
52497
61f70a6ab645 wirepeer: subclass new `repository.ipeer{,legacy}commands` Proctocol classes
Matt Harbison <matt_harbison@yahoo.com>
parents: 52496
diff changeset
252 @abc.abstractmethod
52446
c1674551c109 interfaces: add the missing `self` arg to the repository Protocol classes
Matt Harbison <matt_harbison@yahoo.com>
parents: 52445
diff changeset
253 def debugwireargs(self, one, two, three=None, four=None, five=None):
33801
558f5b2ee10e repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33800
diff changeset
254 """Used to facilitate debugging of arguments passed over the wire."""
558f5b2ee10e repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33800
diff changeset
255
52497
61f70a6ab645 wirepeer: subclass new `repository.ipeer{,legacy}commands` Proctocol classes
Matt Harbison <matt_harbison@yahoo.com>
parents: 52496
diff changeset
256 @abc.abstractmethod
52446
c1674551c109 interfaces: add the missing `self` arg to the repository Protocol classes
Matt Harbison <matt_harbison@yahoo.com>
parents: 52445
diff changeset
257 def getbundle(self, source, **kwargs):
33801
558f5b2ee10e repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33800
diff changeset
258 """Obtain remote repository data as a bundle.
558f5b2ee10e repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33800
diff changeset
259
558f5b2ee10e repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33800
diff changeset
260 This command is how the bulk of repository data is transferred from
558f5b2ee10e repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33800
diff changeset
261 the peer to the local repository
558f5b2ee10e repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33800
diff changeset
262
558f5b2ee10e repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33800
diff changeset
263 Returns a generator of bundle data.
558f5b2ee10e repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33800
diff changeset
264 """
558f5b2ee10e repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33800
diff changeset
265
52497
61f70a6ab645 wirepeer: subclass new `repository.ipeer{,legacy}commands` Proctocol classes
Matt Harbison <matt_harbison@yahoo.com>
parents: 52496
diff changeset
266 @abc.abstractmethod
52446
c1674551c109 interfaces: add the missing `self` arg to the repository Protocol classes
Matt Harbison <matt_harbison@yahoo.com>
parents: 52445
diff changeset
267 def heads(self):
33801
558f5b2ee10e repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33800
diff changeset
268 """Determine all known head revisions in the peer.
558f5b2ee10e repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33800
diff changeset
269
558f5b2ee10e repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33800
diff changeset
270 Returns an iterable of binary nodes.
558f5b2ee10e repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33800
diff changeset
271 """
558f5b2ee10e repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33800
diff changeset
272
52497
61f70a6ab645 wirepeer: subclass new `repository.ipeer{,legacy}commands` Proctocol classes
Matt Harbison <matt_harbison@yahoo.com>
parents: 52496
diff changeset
273 @abc.abstractmethod
52446
c1674551c109 interfaces: add the missing `self` arg to the repository Protocol classes
Matt Harbison <matt_harbison@yahoo.com>
parents: 52445
diff changeset
274 def known(self, nodes):
33801
558f5b2ee10e repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33800
diff changeset
275 """Determine whether multiple nodes are known.
558f5b2ee10e repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33800
diff changeset
276
558f5b2ee10e repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33800
diff changeset
277 Accepts an iterable of nodes whose presence to check for.
558f5b2ee10e repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33800
diff changeset
278
558f5b2ee10e repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33800
diff changeset
279 Returns an iterable of booleans indicating of the corresponding node
558f5b2ee10e repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33800
diff changeset
280 at that index is known to the peer.
558f5b2ee10e repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33800
diff changeset
281 """
558f5b2ee10e repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33800
diff changeset
282
52497
61f70a6ab645 wirepeer: subclass new `repository.ipeer{,legacy}commands` Proctocol classes
Matt Harbison <matt_harbison@yahoo.com>
parents: 52496
diff changeset
283 @abc.abstractmethod
52446
c1674551c109 interfaces: add the missing `self` arg to the repository Protocol classes
Matt Harbison <matt_harbison@yahoo.com>
parents: 52445
diff changeset
284 def listkeys(self, namespace):
33801
558f5b2ee10e repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33800
diff changeset
285 """Obtain all keys in a pushkey namespace.
558f5b2ee10e repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33800
diff changeset
286
558f5b2ee10e repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33800
diff changeset
287 Returns an iterable of key names.
558f5b2ee10e repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33800
diff changeset
288 """
558f5b2ee10e repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33800
diff changeset
289
52497
61f70a6ab645 wirepeer: subclass new `repository.ipeer{,legacy}commands` Proctocol classes
Matt Harbison <matt_harbison@yahoo.com>
parents: 52496
diff changeset
290 @abc.abstractmethod
52446
c1674551c109 interfaces: add the missing `self` arg to the repository Protocol classes
Matt Harbison <matt_harbison@yahoo.com>
parents: 52445
diff changeset
291 def lookup(self, key):
33801
558f5b2ee10e repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33800
diff changeset
292 """Resolve a value to a known revision.
558f5b2ee10e repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33800
diff changeset
293
558f5b2ee10e repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33800
diff changeset
294 Returns a binary node of the resolved revision on success.
558f5b2ee10e repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33800
diff changeset
295 """
558f5b2ee10e repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33800
diff changeset
296
52497
61f70a6ab645 wirepeer: subclass new `repository.ipeer{,legacy}commands` Proctocol classes
Matt Harbison <matt_harbison@yahoo.com>
parents: 52496
diff changeset
297 @abc.abstractmethod
52446
c1674551c109 interfaces: add the missing `self` arg to the repository Protocol classes
Matt Harbison <matt_harbison@yahoo.com>
parents: 52445
diff changeset
298 def pushkey(self, namespace, key, old, new):
33801
558f5b2ee10e repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33800
diff changeset
299 """Set a value using the ``pushkey`` protocol.
558f5b2ee10e repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33800
diff changeset
300
558f5b2ee10e repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33800
diff changeset
301 Arguments correspond to the pushkey namespace and key to operate on and
558f5b2ee10e repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33800
diff changeset
302 the old and new values for that key.
558f5b2ee10e repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33800
diff changeset
303
558f5b2ee10e repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33800
diff changeset
304 Returns a string with the peer result. The value inside varies by the
558f5b2ee10e repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33800
diff changeset
305 namespace.
558f5b2ee10e repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33800
diff changeset
306 """
558f5b2ee10e repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33800
diff changeset
307
52497
61f70a6ab645 wirepeer: subclass new `repository.ipeer{,legacy}commands` Proctocol classes
Matt Harbison <matt_harbison@yahoo.com>
parents: 52496
diff changeset
308 @abc.abstractmethod
52446
c1674551c109 interfaces: add the missing `self` arg to the repository Protocol classes
Matt Harbison <matt_harbison@yahoo.com>
parents: 52445
diff changeset
309 def stream_out(self):
33801
558f5b2ee10e repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33800
diff changeset
310 """Obtain streaming clone data.
558f5b2ee10e repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33800
diff changeset
311
558f5b2ee10e repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33800
diff changeset
312 Successful result should be a generator of data chunks.
558f5b2ee10e repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33800
diff changeset
313 """
558f5b2ee10e repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33800
diff changeset
314
52497
61f70a6ab645 wirepeer: subclass new `repository.ipeer{,legacy}commands` Proctocol classes
Matt Harbison <matt_harbison@yahoo.com>
parents: 52496
diff changeset
315 @abc.abstractmethod
52446
c1674551c109 interfaces: add the missing `self` arg to the repository Protocol classes
Matt Harbison <matt_harbison@yahoo.com>
parents: 52445
diff changeset
316 def unbundle(self, bundle, heads, url):
33801
558f5b2ee10e repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33800
diff changeset
317 """Transfer repository data to the peer.
558f5b2ee10e repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33800
diff changeset
318
558f5b2ee10e repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33800
diff changeset
319 This is how the bulk of data during a push is transferred.
558f5b2ee10e repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33800
diff changeset
320
558f5b2ee10e repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33800
diff changeset
321 Returns the integer number of heads added to the peer.
558f5b2ee10e repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33800
diff changeset
322 """
558f5b2ee10e repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33800
diff changeset
323
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43032
diff changeset
324
52445
26dd402c3497 interfaces: convert the repository zope interfaces to Protocol classes
Matt Harbison <matt_harbison@yahoo.com>
parents: 52432
diff changeset
325 class ipeerlegacycommands(Protocol):
33801
558f5b2ee10e repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33800
diff changeset
326 """Interface for implementing support for legacy wire protocol commands.
558f5b2ee10e repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33800
diff changeset
327
558f5b2ee10e repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33800
diff changeset
328 Wire protocol commands transition to legacy status when they are no longer
558f5b2ee10e repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33800
diff changeset
329 used by modern clients. To facilitate identifying which commands are
558f5b2ee10e repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33800
diff changeset
330 legacy, the interfaces are split.
558f5b2ee10e repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33800
diff changeset
331 """
558f5b2ee10e repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33800
diff changeset
332
52497
61f70a6ab645 wirepeer: subclass new `repository.ipeer{,legacy}commands` Proctocol classes
Matt Harbison <matt_harbison@yahoo.com>
parents: 52496
diff changeset
333 @abc.abstractmethod
52446
c1674551c109 interfaces: add the missing `self` arg to the repository Protocol classes
Matt Harbison <matt_harbison@yahoo.com>
parents: 52445
diff changeset
334 def between(self, pairs):
33801
558f5b2ee10e repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33800
diff changeset
335 """Obtain nodes between pairs of nodes.
558f5b2ee10e repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33800
diff changeset
336
558f5b2ee10e repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33800
diff changeset
337 ``pairs`` is an iterable of node pairs.
558f5b2ee10e repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33800
diff changeset
338
558f5b2ee10e repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33800
diff changeset
339 Returns an iterable of iterables of nodes corresponding to each
558f5b2ee10e repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33800
diff changeset
340 requested pair.
558f5b2ee10e repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33800
diff changeset
341 """
558f5b2ee10e repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33800
diff changeset
342
52497
61f70a6ab645 wirepeer: subclass new `repository.ipeer{,legacy}commands` Proctocol classes
Matt Harbison <matt_harbison@yahoo.com>
parents: 52496
diff changeset
343 @abc.abstractmethod
52446
c1674551c109 interfaces: add the missing `self` arg to the repository Protocol classes
Matt Harbison <matt_harbison@yahoo.com>
parents: 52445
diff changeset
344 def branches(self, nodes):
33801
558f5b2ee10e repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33800
diff changeset
345 """Obtain ancestor changesets of specific nodes back to a branch point.
558f5b2ee10e repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33800
diff changeset
346
558f5b2ee10e repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33800
diff changeset
347 For each requested node, the peer finds the first ancestor node that is
558f5b2ee10e repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33800
diff changeset
348 a DAG root or is a merge.
558f5b2ee10e repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33800
diff changeset
349
558f5b2ee10e repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33800
diff changeset
350 Returns an iterable of iterables with the resolved values for each node.
558f5b2ee10e repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33800
diff changeset
351 """
558f5b2ee10e repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33800
diff changeset
352
52497
61f70a6ab645 wirepeer: subclass new `repository.ipeer{,legacy}commands` Proctocol classes
Matt Harbison <matt_harbison@yahoo.com>
parents: 52496
diff changeset
353 @abc.abstractmethod
52446
c1674551c109 interfaces: add the missing `self` arg to the repository Protocol classes
Matt Harbison <matt_harbison@yahoo.com>
parents: 52445
diff changeset
354 def changegroup(self, nodes, source):
33801
558f5b2ee10e repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33800
diff changeset
355 """Obtain a changegroup with data for descendants of specified nodes."""
558f5b2ee10e repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33800
diff changeset
356
52497
61f70a6ab645 wirepeer: subclass new `repository.ipeer{,legacy}commands` Proctocol classes
Matt Harbison <matt_harbison@yahoo.com>
parents: 52496
diff changeset
357 @abc.abstractmethod
52446
c1674551c109 interfaces: add the missing `self` arg to the repository Protocol classes
Matt Harbison <matt_harbison@yahoo.com>
parents: 52445
diff changeset
358 def changegroupsubset(self, bases, heads, source):
33801
558f5b2ee10e repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33800
diff changeset
359 pass
558f5b2ee10e repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33800
diff changeset
360
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43032
diff changeset
361
52445
26dd402c3497 interfaces: convert the repository zope interfaces to Protocol classes
Matt Harbison <matt_harbison@yahoo.com>
parents: 52432
diff changeset
362 class ipeercommandexecutor(Protocol):
37629
fa0382088993 repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37610
diff changeset
363 """Represents a mechanism to execute remote commands.
fa0382088993 repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37610
diff changeset
364
fa0382088993 repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37610
diff changeset
365 This is the primary interface for requesting that wire protocol commands
fa0382088993 repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37610
diff changeset
366 be executed. Instances of this interface are active in a context manager
fa0382088993 repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37610
diff changeset
367 and have a well-defined lifetime. When the context manager exits, all
fa0382088993 repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37610
diff changeset
368 outstanding requests are waited on.
fa0382088993 repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37610
diff changeset
369 """
fa0382088993 repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37610
diff changeset
370
52496
e123c8a26a70 localrepo: subclass the new `repository.ipeercommandexecutor` Protocol class
Matt Harbison <matt_harbison@yahoo.com>
parents: 52493
diff changeset
371 @abc.abstractmethod
52446
c1674551c109 interfaces: add the missing `self` arg to the repository Protocol classes
Matt Harbison <matt_harbison@yahoo.com>
parents: 52445
diff changeset
372 def callcommand(self, name, args):
37629
fa0382088993 repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37610
diff changeset
373 """Request that a named command be executed.
fa0382088993 repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37610
diff changeset
374
fa0382088993 repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37610
diff changeset
375 Receives the command name and a dictionary of command arguments.
fa0382088993 repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37610
diff changeset
376
fa0382088993 repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37610
diff changeset
377 Returns a ``concurrent.futures.Future`` that will resolve to the
fa0382088993 repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37610
diff changeset
378 result of that command request. That exact value is left up to
fa0382088993 repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37610
diff changeset
379 the implementation and possibly varies by command.
fa0382088993 repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37610
diff changeset
380
fa0382088993 repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37610
diff changeset
381 Not all commands can coexist with other commands in an executor
fa0382088993 repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37610
diff changeset
382 instance: it depends on the underlying wire protocol transport being
fa0382088993 repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37610
diff changeset
383 used and the command itself.
fa0382088993 repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37610
diff changeset
384
fa0382088993 repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37610
diff changeset
385 Implementations MAY call ``sendcommands()`` automatically if the
fa0382088993 repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37610
diff changeset
386 requested command can not coexist with other commands in this executor.
fa0382088993 repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37610
diff changeset
387
fa0382088993 repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37610
diff changeset
388 Implementations MAY call ``sendcommands()`` automatically when the
fa0382088993 repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37610
diff changeset
389 future's ``result()`` is called. So, consumers using multiple
fa0382088993 repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37610
diff changeset
390 commands with an executor MUST ensure that ``result()`` is not called
fa0382088993 repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37610
diff changeset
391 until all command requests have been issued.
fa0382088993 repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37610
diff changeset
392 """
fa0382088993 repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37610
diff changeset
393
52496
e123c8a26a70 localrepo: subclass the new `repository.ipeercommandexecutor` Protocol class
Matt Harbison <matt_harbison@yahoo.com>
parents: 52493
diff changeset
394 @abc.abstractmethod
52446
c1674551c109 interfaces: add the missing `self` arg to the repository Protocol classes
Matt Harbison <matt_harbison@yahoo.com>
parents: 52445
diff changeset
395 def sendcommands(self):
37629
fa0382088993 repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37610
diff changeset
396 """Trigger submission of queued command requests.
fa0382088993 repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37610
diff changeset
397
fa0382088993 repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37610
diff changeset
398 Not all transports submit commands as soon as they are requested to
fa0382088993 repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37610
diff changeset
399 run. When called, this method forces queued command requests to be
fa0382088993 repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37610
diff changeset
400 issued. It will no-op if all commands have already been sent.
fa0382088993 repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37610
diff changeset
401
fa0382088993 repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37610
diff changeset
402 When called, no more new commands may be issued with this executor.
fa0382088993 repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37610
diff changeset
403 """
fa0382088993 repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37610
diff changeset
404
52496
e123c8a26a70 localrepo: subclass the new `repository.ipeercommandexecutor` Protocol class
Matt Harbison <matt_harbison@yahoo.com>
parents: 52493
diff changeset
405 @abc.abstractmethod
52446
c1674551c109 interfaces: add the missing `self` arg to the repository Protocol classes
Matt Harbison <matt_harbison@yahoo.com>
parents: 52445
diff changeset
406 def close(self):
37629
fa0382088993 repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37610
diff changeset
407 """Signal that this command request is finished.
fa0382088993 repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37610
diff changeset
408
fa0382088993 repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37610
diff changeset
409 When called, no more new commands may be issued. All outstanding
fa0382088993 repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37610
diff changeset
410 commands that have previously been issued are waited on before
fa0382088993 repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37610
diff changeset
411 returning. This not only includes waiting for the futures to resolve,
fa0382088993 repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37610
diff changeset
412 but also waiting for all response data to arrive. In other words,
fa0382088993 repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37610
diff changeset
413 calling this waits for all on-wire state for issued command requests
fa0382088993 repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37610
diff changeset
414 to finish.
fa0382088993 repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37610
diff changeset
415
fa0382088993 repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37610
diff changeset
416 When used as a context manager, this method is called when exiting the
fa0382088993 repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37610
diff changeset
417 context manager.
fa0382088993 repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37610
diff changeset
418
fa0382088993 repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37610
diff changeset
419 This method may call ``sendcommands()`` if there are buffered commands.
fa0382088993 repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37610
diff changeset
420 """
fa0382088993 repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37610
diff changeset
421
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43032
diff changeset
422
52445
26dd402c3497 interfaces: convert the repository zope interfaces to Protocol classes
Matt Harbison <matt_harbison@yahoo.com>
parents: 52432
diff changeset
423 class ipeerrequests(Protocol):
37629
fa0382088993 repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37610
diff changeset
424 """Interface for executing commands on a peer."""
fa0382088993 repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37610
diff changeset
425
52465
4cc186255672 interfaces: convert `repository.ipeerrequests` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52464
diff changeset
426 limitedarguments: bool
4cc186255672 interfaces: convert `repository.ipeerrequests` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52464
diff changeset
427 """True if the peer cannot receive large argument value for commands."""
42158
69921d02daaf peer: introduce a limitedarguments attributes
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 41315
diff changeset
428
52499
9358d786af24 interfaces: make all methods on any repository Protocol class abstract
Matt Harbison <matt_harbison@yahoo.com>
parents: 52497
diff changeset
429 @abc.abstractmethod
52446
c1674551c109 interfaces: add the missing `self` arg to the repository Protocol classes
Matt Harbison <matt_harbison@yahoo.com>
parents: 52445
diff changeset
430 def commandexecutor(self):
37629
fa0382088993 repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37610
diff changeset
431 """A context manager that resolves to an ipeercommandexecutor.
fa0382088993 repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37610
diff changeset
432
fa0382088993 repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37610
diff changeset
433 The object this resolves to can be used to issue command requests
fa0382088993 repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37610
diff changeset
434 to the peer.
fa0382088993 repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37610
diff changeset
435
fa0382088993 repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37610
diff changeset
436 Callers should call its ``callcommand`` method to issue command
fa0382088993 repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37610
diff changeset
437 requests.
fa0382088993 repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37610
diff changeset
438
fa0382088993 repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37610
diff changeset
439 A new executor should be obtained for each distinct set of commands
fa0382088993 repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37610
diff changeset
440 (possibly just a single command) that the consumer wants to execute
fa0382088993 repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37610
diff changeset
441 as part of a single operation or round trip. This is because some
fa0382088993 repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37610
diff changeset
442 peers are half-duplex and/or don't support persistent connections.
fa0382088993 repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37610
diff changeset
443 e.g. in the case of HTTP peers, commands sent to an executor represent
fa0382088993 repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37610
diff changeset
444 a single HTTP request. While some peers may support multiple command
fa0382088993 repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37610
diff changeset
445 sends over the wire per executor, consumers need to code to the least
fa0382088993 repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37610
diff changeset
446 capable peer. So it should be assumed that command executors buffer
fa0382088993 repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37610
diff changeset
447 called commands until they are told to send them and that each
fa0382088993 repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37610
diff changeset
448 command executor could result in a new connection or wire-level request
fa0382088993 repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37610
diff changeset
449 being issued.
fa0382088993 repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37610
diff changeset
450 """
fa0382088993 repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37610
diff changeset
451
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43032
diff changeset
452
52506
199b0e62b403 interfaces: make the `peer` mixin not a Protocol to fix Python 3.10 failures
Matt Harbison <matt_harbison@yahoo.com>
parents: 52500
diff changeset
453 # TODO: make this a Protocol class when 3.11 is the minimum supported version?
199b0e62b403 interfaces: make the `peer` mixin not a Protocol to fix Python 3.10 failures
Matt Harbison <matt_harbison@yahoo.com>
parents: 52500
diff changeset
454 class peer(_ipeerconnection, ipeercapabilities, ipeerrequests):
37320
39f7d4ee8bcd repository: port peer interfaces to zope.interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37316
diff changeset
455 """Unified interface for peer repositories.
33800
f257943e47ab repository: formalize peer interface with abstract base class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
456
37320
39f7d4ee8bcd repository: port peer interfaces to zope.interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37316
diff changeset
457 All peer instances must conform to this interface.
33800
f257943e47ab repository: formalize peer interface with abstract base class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
458 """
33801
558f5b2ee10e repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33800
diff changeset
459
52466
1df97507c6b8 interfaces: convert `repository.peer` to a Protocol class
Matt Harbison <matt_harbison@yahoo.com>
parents: 52465
diff changeset
460 limitedarguments: bool = False
52518
5a924cb07768 typing: add annotations to the `repository.peer` mixin class
Matt Harbison <matt_harbison@yahoo.com>
parents: 52506
diff changeset
461 path: urlutil.path | None
5a924cb07768 typing: add annotations to the `repository.peer` mixin class
Matt Harbison <matt_harbison@yahoo.com>
parents: 52506
diff changeset
462 ui: Ui
5a924cb07768 typing: add annotations to the `repository.peer` mixin class
Matt Harbison <matt_harbison@yahoo.com>
parents: 52506
diff changeset
463
5a924cb07768 typing: add annotations to the `repository.peer` mixin class
Matt Harbison <matt_harbison@yahoo.com>
parents: 52506
diff changeset
464 def __init__(
5a924cb07768 typing: add annotations to the `repository.peer` mixin class
Matt Harbison <matt_harbison@yahoo.com>
parents: 52506
diff changeset
465 self,
5a924cb07768 typing: add annotations to the `repository.peer` mixin class
Matt Harbison <matt_harbison@yahoo.com>
parents: 52506
diff changeset
466 ui: Ui,
5a924cb07768 typing: add annotations to the `repository.peer` mixin class
Matt Harbison <matt_harbison@yahoo.com>
parents: 52506
diff changeset
467 path: urlutil.path | None = None,
5a924cb07768 typing: add annotations to the `repository.peer` mixin class
Matt Harbison <matt_harbison@yahoo.com>
parents: 52506
diff changeset
468 remotehidden: bool = False,
5a924cb07768 typing: add annotations to the `repository.peer` mixin class
Matt Harbison <matt_harbison@yahoo.com>
parents: 52506
diff changeset
469 ) -> None:
49751
a6e2a668c746 peer: have a common constructor and use it
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49748
diff changeset
470 self.ui = ui
49752
611ccb631cbc peer: add a `path` attribute to peer
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49751
diff changeset
471 self.path = path
49751
a6e2a668c746 peer: have a common constructor and use it
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 49748
diff changeset
472
52518
5a924cb07768 typing: add annotations to the `repository.peer` mixin class
Matt Harbison <matt_harbison@yahoo.com>
parents: 52506
diff changeset
473 def capable(self, name: bytes) -> bool | bytes:
52520
1554bd50a1af interfaces: move peer `capabilities()` to the `ipeercapabilities` interface
Matt Harbison <matt_harbison@yahoo.com>
parents: 52518
diff changeset
474 caps = self.capabilities()
33802
a0aad86b3b6a repository: implement generic capability methods on peer class
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33801
diff changeset
475 if name in caps:
a0aad86b3b6a repository: implement generic capability methods on peer class
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33801
diff changeset
476 return True
a0aad86b3b6a repository: implement generic capability methods on peer class
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33801
diff changeset
477
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
478 name = b'%s=' % name
33802
a0aad86b3b6a repository: implement generic capability methods on peer class
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33801
diff changeset
479 for cap in caps:
a0aad86b3b6a repository: implement generic capability methods on peer class
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33801
diff changeset
480 if cap.startswith(name):
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43032
diff changeset
481 return cap[len(name) :]
33802
a0aad86b3b6a repository: implement generic capability methods on peer class
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33801
diff changeset
482
a0aad86b3b6a repository: implement generic capability methods on peer class
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33801
diff changeset
483 return False
a0aad86b3b6a repository: implement generic capability methods on peer class
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33801
diff changeset
484
52518
5a924cb07768 typing: add annotations to the `repository.peer` mixin class
Matt Harbison <matt_harbison@yahoo.com>
parents: 52506
diff changeset
485 def requirecap(self, name: bytes, purpose: bytes) -> None:
33802
a0aad86b3b6a repository: implement generic capability methods on peer class
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33801
diff changeset
486 if self.capable(name):
a0aad86b3b6a repository: implement generic capability methods on peer class
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33801
diff changeset
487 return
a0aad86b3b6a repository: implement generic capability methods on peer class
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33801
diff changeset
488
a0aad86b3b6a repository: implement generic capability methods on peer class
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33801
diff changeset
489 raise error.CapabilityError(
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43032
diff changeset
490 _(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
491 b'cannot %s; remote repository does not support the '
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
492 b'\'%s\' capability'
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43032
diff changeset
493 )
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43032
diff changeset
494 % (purpose, name)
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43032
diff changeset
495 )
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43032
diff changeset
496
33802
a0aad86b3b6a repository: implement generic capability methods on peer class
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33801
diff changeset
497
52445
26dd402c3497 interfaces: convert the repository zope interfaces to Protocol classes
Matt Harbison <matt_harbison@yahoo.com>
parents: 52432
diff changeset
498 class iverifyproblem(Protocol):
39842
97986c9c69d3 verify: start to abstract file verification
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39785
diff changeset
499 """Represents a problem with the integrity of the repository.
97986c9c69d3 verify: start to abstract file verification
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39785
diff changeset
500
97986c9c69d3 verify: start to abstract file verification
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39785
diff changeset
501 Instances of this interface are emitted to describe an integrity issue
97986c9c69d3 verify: start to abstract file verification
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39785
diff changeset
502 with a repository (e.g. corrupt storage, missing data, etc).
97986c9c69d3 verify: start to abstract file verification
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39785
diff changeset
503
97986c9c69d3 verify: start to abstract file verification
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39785
diff changeset
504 Instances are essentially messages associated with severity.
97986c9c69d3 verify: start to abstract file verification
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39785
diff changeset
505 """
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43032
diff changeset
506
52467
f968926a4207 interfaces: convert `repository.iverifyproblem` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52466
diff changeset
507 warning: bytes | None
f968926a4207 interfaces: convert `repository.iverifyproblem` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52466
diff changeset
508 """Message indicating a non-fatal problem."""
f968926a4207 interfaces: convert `repository.iverifyproblem` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52466
diff changeset
509
f968926a4207 interfaces: convert `repository.iverifyproblem` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52466
diff changeset
510 error: bytes | None
f968926a4207 interfaces: convert `repository.iverifyproblem` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52466
diff changeset
511 """Message indicating a fatal problem."""
f968926a4207 interfaces: convert `repository.iverifyproblem` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52466
diff changeset
512
f968926a4207 interfaces: convert `repository.iverifyproblem` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52466
diff changeset
513 node: bytes | None
f968926a4207 interfaces: convert `repository.iverifyproblem` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52466
diff changeset
514 """Revision encountering the problem.
f968926a4207 interfaces: convert `repository.iverifyproblem` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52466
diff changeset
515
f968926a4207 interfaces: convert `repository.iverifyproblem` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52466
diff changeset
516 ``None`` means the problem doesn't apply to a single revision.
f968926a4207 interfaces: convert `repository.iverifyproblem` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52466
diff changeset
517 """
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43032
diff changeset
518
39872
733db72f0f54 revlog: move revision verification out of verify
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39869
diff changeset
519
52445
26dd402c3497 interfaces: convert the repository zope interfaces to Protocol classes
Matt Harbison <matt_harbison@yahoo.com>
parents: 52432
diff changeset
520 class irevisiondelta(Protocol):
39230
b518d495a560 repository: formalize interfaces for revision deltas and requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38835
diff changeset
521 """Represents a delta between one revision and another.
b518d495a560 repository: formalize interfaces for revision deltas and requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38835
diff changeset
522
b518d495a560 repository: formalize interfaces for revision deltas and requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38835
diff changeset
523 Instances convey enough information to allow a revision to be exchanged
b518d495a560 repository: formalize interfaces for revision deltas and requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38835
diff changeset
524 with another repository.
b518d495a560 repository: formalize interfaces for revision deltas and requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38835
diff changeset
525
b518d495a560 repository: formalize interfaces for revision deltas and requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38835
diff changeset
526 Instances represent the fulltext revision data or a delta against
b518d495a560 repository: formalize interfaces for revision deltas and requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38835
diff changeset
527 another revision. Therefore the ``revision`` and ``delta`` attributes
b518d495a560 repository: formalize interfaces for revision deltas and requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38835
diff changeset
528 are mutually exclusive.
b518d495a560 repository: formalize interfaces for revision deltas and requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38835
diff changeset
529
b518d495a560 repository: formalize interfaces for revision deltas and requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38835
diff changeset
530 Typically used for changegroup generation.
b518d495a560 repository: formalize interfaces for revision deltas and requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38835
diff changeset
531 """
b518d495a560 repository: formalize interfaces for revision deltas and requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38835
diff changeset
532
52469
2aada52e80d6 interfaces: convert `repository.irevisiondelta` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52467
diff changeset
533 node: bytes
2aada52e80d6 interfaces: convert `repository.irevisiondelta` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52467
diff changeset
534 """20 byte node of this revision."""
2aada52e80d6 interfaces: convert `repository.irevisiondelta` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52467
diff changeset
535
2aada52e80d6 interfaces: convert `repository.irevisiondelta` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52467
diff changeset
536 p1node: bytes
2aada52e80d6 interfaces: convert `repository.irevisiondelta` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52467
diff changeset
537 """20 byte node of 1st parent of this revision."""
2aada52e80d6 interfaces: convert `repository.irevisiondelta` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52467
diff changeset
538
2aada52e80d6 interfaces: convert `repository.irevisiondelta` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52467
diff changeset
539 p2node: bytes
2aada52e80d6 interfaces: convert `repository.irevisiondelta` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52467
diff changeset
540 """20 byte node of 2nd parent of this revision."""
2aada52e80d6 interfaces: convert `repository.irevisiondelta` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52467
diff changeset
541
2aada52e80d6 interfaces: convert `repository.irevisiondelta` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52467
diff changeset
542 # TODO: is this really optional? revlog.revlogrevisiondelta defaults to None
2aada52e80d6 interfaces: convert `repository.irevisiondelta` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52467
diff changeset
543 linknode: bytes | None
2aada52e80d6 interfaces: convert `repository.irevisiondelta` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52467
diff changeset
544 """20 byte node of the changelog revision this node is linked to."""
2aada52e80d6 interfaces: convert `repository.irevisiondelta` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52467
diff changeset
545
2aada52e80d6 interfaces: convert `repository.irevisiondelta` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52467
diff changeset
546 flags: int
2aada52e80d6 interfaces: convert `repository.irevisiondelta` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52467
diff changeset
547 """2 bytes of integer flags that apply to this revision.
2aada52e80d6 interfaces: convert `repository.irevisiondelta` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52467
diff changeset
548
2aada52e80d6 interfaces: convert `repository.irevisiondelta` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52467
diff changeset
549 This is a bitwise composition of the ``REVISION_FLAG_*`` constants.
2aada52e80d6 interfaces: convert `repository.irevisiondelta` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52467
diff changeset
550 """
2aada52e80d6 interfaces: convert `repository.irevisiondelta` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52467
diff changeset
551
2aada52e80d6 interfaces: convert `repository.irevisiondelta` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52467
diff changeset
552 basenode: bytes
2aada52e80d6 interfaces: convert `repository.irevisiondelta` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52467
diff changeset
553 """20 byte node of the revision this data is a delta against.
2aada52e80d6 interfaces: convert `repository.irevisiondelta` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52467
diff changeset
554
2aada52e80d6 interfaces: convert `repository.irevisiondelta` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52467
diff changeset
555 ``nullid`` indicates that the revision is a full revision and not
2aada52e80d6 interfaces: convert `repository.irevisiondelta` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52467
diff changeset
556 a delta.
2aada52e80d6 interfaces: convert `repository.irevisiondelta` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52467
diff changeset
557 """
2aada52e80d6 interfaces: convert `repository.irevisiondelta` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52467
diff changeset
558
2aada52e80d6 interfaces: convert `repository.irevisiondelta` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52467
diff changeset
559 baserevisionsize: int | None
2aada52e80d6 interfaces: convert `repository.irevisiondelta` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52467
diff changeset
560 """Size of base revision this delta is against.
2aada52e80d6 interfaces: convert `repository.irevisiondelta` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52467
diff changeset
561
2aada52e80d6 interfaces: convert `repository.irevisiondelta` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52467
diff changeset
562 May be ``None`` if ``basenode`` is ``nullid``.
2aada52e80d6 interfaces: convert `repository.irevisiondelta` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52467
diff changeset
563 """
2aada52e80d6 interfaces: convert `repository.irevisiondelta` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52467
diff changeset
564
2aada52e80d6 interfaces: convert `repository.irevisiondelta` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52467
diff changeset
565 # TODO: is this really optional? (Seems possible in
2aada52e80d6 interfaces: convert `repository.irevisiondelta` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52467
diff changeset
566 # storageutil.emitrevisions()).
2aada52e80d6 interfaces: convert `repository.irevisiondelta` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52467
diff changeset
567 revision: bytes | None
2aada52e80d6 interfaces: convert `repository.irevisiondelta` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52467
diff changeset
568 """Raw fulltext of revision data for this node."""
2aada52e80d6 interfaces: convert `repository.irevisiondelta` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52467
diff changeset
569
2aada52e80d6 interfaces: convert `repository.irevisiondelta` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52467
diff changeset
570 delta: bytes | None
2aada52e80d6 interfaces: convert `repository.irevisiondelta` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52467
diff changeset
571 """Delta between ``basenode`` and ``node``.
2aada52e80d6 interfaces: convert `repository.irevisiondelta` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52467
diff changeset
572
2aada52e80d6 interfaces: convert `repository.irevisiondelta` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52467
diff changeset
573 Stored in the bdiff delta format.
2aada52e80d6 interfaces: convert `repository.irevisiondelta` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52467
diff changeset
574 """
2aada52e80d6 interfaces: convert `repository.irevisiondelta` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52467
diff changeset
575
2aada52e80d6 interfaces: convert `repository.irevisiondelta` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52467
diff changeset
576 sidedata: bytes | None
2aada52e80d6 interfaces: convert `repository.irevisiondelta` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52467
diff changeset
577 """Raw sidedata bytes for the given revision."""
2aada52e80d6 interfaces: convert `repository.irevisiondelta` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52467
diff changeset
578
2aada52e80d6 interfaces: convert `repository.irevisiondelta` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52467
diff changeset
579 protocol_flags: int
2aada52e80d6 interfaces: convert `repository.irevisiondelta` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52467
diff changeset
580 """Single byte of integer flags that can influence the protocol.
2aada52e80d6 interfaces: convert `repository.irevisiondelta` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52467
diff changeset
581
2aada52e80d6 interfaces: convert `repository.irevisiondelta` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52467
diff changeset
582 This is a bitwise composition of the ``storageutil.CG_FLAG*`` constants.
2aada52e80d6 interfaces: convert `repository.irevisiondelta` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52467
diff changeset
583 """
47077
119790e1c67c cg4: introduce protocol flag to signify the presence of sidedata
Rapha?l Gom?s <rgomes@octobus.net>
parents: 46780
diff changeset
584
39230
b518d495a560 repository: formalize interfaces for revision deltas and requests
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38835
diff changeset
585
52445
26dd402c3497 interfaces: convert the repository zope interfaces to Protocol classes
Matt Harbison <matt_harbison@yahoo.com>
parents: 52432
diff changeset
586 class ifilerevisionssequence(Protocol):
37440
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
587 """Contains index data for all revisions of a file.
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
588
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
589 Types implementing this behave like lists of tuples. The index
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
590 in the list corresponds to the revision number. The values contain
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
591 index metadata.
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
592
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
593 The *null* revision (revision number -1) is always the last item
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
594 in the index.
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
595 """
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
596
52499
9358d786af24 interfaces: make all methods on any repository Protocol class abstract
Matt Harbison <matt_harbison@yahoo.com>
parents: 52497
diff changeset
597 @abc.abstractmethod
52446
c1674551c109 interfaces: add the missing `self` arg to the repository Protocol classes
Matt Harbison <matt_harbison@yahoo.com>
parents: 52445
diff changeset
598 def __len__(self):
37440
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
599 """The total number of revisions."""
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
600
52499
9358d786af24 interfaces: make all methods on any repository Protocol class abstract
Matt Harbison <matt_harbison@yahoo.com>
parents: 52497
diff changeset
601 @abc.abstractmethod
52446
c1674551c109 interfaces: add the missing `self` arg to the repository Protocol classes
Matt Harbison <matt_harbison@yahoo.com>
parents: 52445
diff changeset
602 def __getitem__(self, rev):
37440
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
603 """Returns the object having a specific revision number.
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
604
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
605 Returns an 8-tuple with the following fields:
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
606
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
607 offset+flags
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
608 Contains the offset and flags for the revision. 64-bit unsigned
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
609 integer where first 6 bytes are the offset and the next 2 bytes
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
610 are flags. The offset can be 0 if it is not used by the store.
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
611 compressed size
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
612 Size of the revision data in the store. It can be 0 if it isn't
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
613 needed by the store.
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
614 uncompressed size
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
615 Fulltext size. It can be 0 if it isn't needed by the store.
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
616 base revision
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
617 Revision number of revision the delta for storage is encoded
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
618 against. -1 indicates not encoded against a base revision.
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
619 link revision
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
620 Revision number of changelog revision this entry is related to.
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
621 p1 revision
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
622 Revision number of 1st parent. -1 if no 1st parent.
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
623 p2 revision
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
624 Revision number of 2nd parent. -1 if no 1st parent.
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
625 node
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
626 Binary node value for this revision number.
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
627
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
628 Negative values should index off the end of the sequence. ``-1``
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
629 should return the null revision. ``-2`` should return the most
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
630 recent revision.
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
631 """
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
632
52499
9358d786af24 interfaces: make all methods on any repository Protocol class abstract
Matt Harbison <matt_harbison@yahoo.com>
parents: 52497
diff changeset
633 @abc.abstractmethod
52446
c1674551c109 interfaces: add the missing `self` arg to the repository Protocol classes
Matt Harbison <matt_harbison@yahoo.com>
parents: 52445
diff changeset
634 def __contains__(self, rev):
37440
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
635 """Whether a revision number exists."""
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
636
52499
9358d786af24 interfaces: make all methods on any repository Protocol class abstract
Matt Harbison <matt_harbison@yahoo.com>
parents: 52497
diff changeset
637 @abc.abstractmethod
37440
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
638 def insert(self, i, entry):
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
639 """Add an item to the index at specific revision."""
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
640
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43032
diff changeset
641
52445
26dd402c3497 interfaces: convert the repository zope interfaces to Protocol classes
Matt Harbison <matt_harbison@yahoo.com>
parents: 52432
diff changeset
642 class ifileindex(Protocol):
37440
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
643 """Storage interface for index data of a single file.
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
644
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
645 File storage data is divided into index metadata and data storage.
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
646 This interface defines the index portion of the interface.
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
647
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
648 The index logically consists of:
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
649
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
650 * A mapping between revision numbers and nodes.
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
651 * DAG data (storing and querying the relationship between nodes).
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
652 * Metadata to facilitate storage.
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
653 """
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43032
diff changeset
654
52472
0d4ead4d88bd interfaces: convert `repository.ifileindex` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52469
diff changeset
655 nullid: bytes
0d4ead4d88bd interfaces: convert `repository.ifileindex` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52469
diff changeset
656 """node for the null revision for use as delta base."""
46780
6266d19556ad node: introduce nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents: 46713
diff changeset
657
52488
8c89e978375c interfaces: convert `repository.ifilestorage` to a Protocol class
Matt Harbison <matt_harbison@yahoo.com>
parents: 52487
diff changeset
658 @abc.abstractmethod
52487
3daaa5195a30 typing: align the signatures of `repository.ifilestorage` overrides
Matt Harbison <matt_harbison@yahoo.com>
parents: 52486
diff changeset
659 def __len__(self) -> int:
37440
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
660 """Obtain the number of revisions stored for this file."""
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
661
52488
8c89e978375c interfaces: convert `repository.ifilestorage` to a Protocol class
Matt Harbison <matt_harbison@yahoo.com>
parents: 52487
diff changeset
662 @abc.abstractmethod
52487
3daaa5195a30 typing: align the signatures of `repository.ifilestorage` overrides
Matt Harbison <matt_harbison@yahoo.com>
parents: 52486
diff changeset
663 def __iter__(self) -> Iterator[int]:
37440
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
664 """Iterate over revision numbers for this file."""
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
665
52488
8c89e978375c interfaces: convert `repository.ifilestorage` to a Protocol class
Matt Harbison <matt_harbison@yahoo.com>
parents: 52487
diff changeset
666 @abc.abstractmethod
52446
c1674551c109 interfaces: add the missing `self` arg to the repository Protocol classes
Matt Harbison <matt_harbison@yahoo.com>
parents: 52445
diff changeset
667 def hasnode(self, node):
40387
f1a39128da95 filelog: add a hasnode() method (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40279
diff changeset
668 """Returns a bool indicating if a node is known to this store.
f1a39128da95 filelog: add a hasnode() method (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40279
diff changeset
669
f1a39128da95 filelog: add a hasnode() method (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40279
diff changeset
670 Implementations must only return True for full, binary node values:
f1a39128da95 filelog: add a hasnode() method (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40279
diff changeset
671 hex nodes, revision numbers, and partial node matches must be
f1a39128da95 filelog: add a hasnode() method (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40279
diff changeset
672 rejected.
f1a39128da95 filelog: add a hasnode() method (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40279
diff changeset
673
f1a39128da95 filelog: add a hasnode() method (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40279
diff changeset
674 The null node is never present.
f1a39128da95 filelog: add a hasnode() method (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40279
diff changeset
675 """
f1a39128da95 filelog: add a hasnode() method (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40279
diff changeset
676
52488
8c89e978375c interfaces: convert `repository.ifilestorage` to a Protocol class
Matt Harbison <matt_harbison@yahoo.com>
parents: 52487
diff changeset
677 @abc.abstractmethod
52446
c1674551c109 interfaces: add the missing `self` arg to the repository Protocol classes
Matt Harbison <matt_harbison@yahoo.com>
parents: 52445
diff changeset
678 def revs(self, start=0, stop=None):
37440
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
679 """Iterate over revision numbers for this file, with control."""
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
680
52488
8c89e978375c interfaces: convert `repository.ifilestorage` to a Protocol class
Matt Harbison <matt_harbison@yahoo.com>
parents: 52487
diff changeset
681 @abc.abstractmethod
52446
c1674551c109 interfaces: add the missing `self` arg to the repository Protocol classes
Matt Harbison <matt_harbison@yahoo.com>
parents: 52445
diff changeset
682 def parents(self, node):
37440
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
683 """Returns a 2-tuple of parent nodes for a revision.
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
684
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
685 Values will be ``nullid`` if the parent is empty.
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
686 """
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
687
52488
8c89e978375c interfaces: convert `repository.ifilestorage` to a Protocol class
Matt Harbison <matt_harbison@yahoo.com>
parents: 52487
diff changeset
688 @abc.abstractmethod
52446
c1674551c109 interfaces: add the missing `self` arg to the repository Protocol classes
Matt Harbison <matt_harbison@yahoo.com>
parents: 52445
diff changeset
689 def parentrevs(self, rev):
37440
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
690 """Like parents() but operates on revision numbers."""
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
691
52488
8c89e978375c interfaces: convert `repository.ifilestorage` to a Protocol class
Matt Harbison <matt_harbison@yahoo.com>
parents: 52487
diff changeset
692 @abc.abstractmethod
52446
c1674551c109 interfaces: add the missing `self` arg to the repository Protocol classes
Matt Harbison <matt_harbison@yahoo.com>
parents: 52445
diff changeset
693 def rev(self, node):
37440
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
694 """Obtain the revision number given a node.
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
695
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
696 Raises ``error.LookupError`` if the node is not known.
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
697 """
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
698
52488
8c89e978375c interfaces: convert `repository.ifilestorage` to a Protocol class
Matt Harbison <matt_harbison@yahoo.com>
parents: 52487
diff changeset
699 @abc.abstractmethod
52446
c1674551c109 interfaces: add the missing `self` arg to the repository Protocol classes
Matt Harbison <matt_harbison@yahoo.com>
parents: 52445
diff changeset
700 def node(self, rev):
37440
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
701 """Obtain the node value given a revision number.
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
702
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
703 Raises ``IndexError`` if the node is not known.
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
704 """
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
705
52488
8c89e978375c interfaces: convert `repository.ifilestorage` to a Protocol class
Matt Harbison <matt_harbison@yahoo.com>
parents: 52487
diff changeset
706 @abc.abstractmethod
52446
c1674551c109 interfaces: add the missing `self` arg to the repository Protocol classes
Matt Harbison <matt_harbison@yahoo.com>
parents: 52445
diff changeset
707 def lookup(self, node):
37440
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
708 """Attempt to resolve a value to a node.
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
709
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
710 Value can be a binary node, hex node, revision number, or a string
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
711 that can be converted to an integer.
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
712
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
713 Raises ``error.LookupError`` if a node could not be resolved.
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
714 """
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
715
52488
8c89e978375c interfaces: convert `repository.ifilestorage` to a Protocol class
Matt Harbison <matt_harbison@yahoo.com>
parents: 52487
diff changeset
716 @abc.abstractmethod
52446
c1674551c109 interfaces: add the missing `self` arg to the repository Protocol classes
Matt Harbison <matt_harbison@yahoo.com>
parents: 52445
diff changeset
717 def linkrev(self, rev):
37440
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
718 """Obtain the changeset revision number a revision is linked to."""
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
719
52488
8c89e978375c interfaces: convert `repository.ifilestorage` to a Protocol class
Matt Harbison <matt_harbison@yahoo.com>
parents: 52487
diff changeset
720 @abc.abstractmethod
52446
c1674551c109 interfaces: add the missing `self` arg to the repository Protocol classes
Matt Harbison <matt_harbison@yahoo.com>
parents: 52445
diff changeset
721 def iscensored(self, rev):
37440
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
722 """Return whether a revision's content has been censored."""
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
723
52488
8c89e978375c interfaces: convert `repository.ifilestorage` to a Protocol class
Matt Harbison <matt_harbison@yahoo.com>
parents: 52487
diff changeset
724 @abc.abstractmethod
52446
c1674551c109 interfaces: add the missing `self` arg to the repository Protocol classes
Matt Harbison <matt_harbison@yahoo.com>
parents: 52445
diff changeset
725 def commonancestorsheads(self, node1, node2):
37440
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
726 """Obtain an iterable of nodes containing heads of common ancestors.
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
727
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
728 See ``ancestor.commonancestorsheads()``.
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
729 """
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
730
52488
8c89e978375c interfaces: convert `repository.ifilestorage` to a Protocol class
Matt Harbison <matt_harbison@yahoo.com>
parents: 52487
diff changeset
731 @abc.abstractmethod
52446
c1674551c109 interfaces: add the missing `self` arg to the repository Protocol classes
Matt Harbison <matt_harbison@yahoo.com>
parents: 52445
diff changeset
732 def descendants(self, revs):
37440
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
733 """Obtain descendant revision numbers for a set of revision numbers.
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
734
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
735 If ``nullrev`` is in the set, this is equivalent to ``revs()``.
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
736 """
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
737
52488
8c89e978375c interfaces: convert `repository.ifilestorage` to a Protocol class
Matt Harbison <matt_harbison@yahoo.com>
parents: 52487
diff changeset
738 @abc.abstractmethod
52446
c1674551c109 interfaces: add the missing `self` arg to the repository Protocol classes
Matt Harbison <matt_harbison@yahoo.com>
parents: 52445
diff changeset
739 def heads(self, start=None, stop=None):
37440
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
740 """Obtain a list of nodes that are DAG heads, with control.
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
741
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
742 The set of revisions examined can be limited by specifying
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
743 ``start`` and ``stop``. ``start`` is a node. ``stop`` is an
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
744 iterable of nodes. DAG traversal starts at earlier revision
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
745 ``start`` and iterates forward until any node in ``stop`` is
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
746 encountered.
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
747 """
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
748
52488
8c89e978375c interfaces: convert `repository.ifilestorage` to a Protocol class
Matt Harbison <matt_harbison@yahoo.com>
parents: 52487
diff changeset
749 @abc.abstractmethod
52446
c1674551c109 interfaces: add the missing `self` arg to the repository Protocol classes
Matt Harbison <matt_harbison@yahoo.com>
parents: 52445
diff changeset
750 def children(self, node):
37440
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
751 """Obtain nodes that are children of a node.
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
752
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
753 Returns a list of nodes.
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
754 """
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
755
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43032
diff changeset
756
52445
26dd402c3497 interfaces: convert the repository zope interfaces to Protocol classes
Matt Harbison <matt_harbison@yahoo.com>
parents: 52432
diff changeset
757 class ifiledata(Protocol):
37440
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
758 """Storage interface for data storage of a specific file.
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
759
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
760 This complements ``ifileindex`` and provides an interface for accessing
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
761 data for a tracked file.
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
762 """
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43032
diff changeset
763
52488
8c89e978375c interfaces: convert `repository.ifilestorage` to a Protocol class
Matt Harbison <matt_harbison@yahoo.com>
parents: 52487
diff changeset
764 @abc.abstractmethod
52446
c1674551c109 interfaces: add the missing `self` arg to the repository Protocol classes
Matt Harbison <matt_harbison@yahoo.com>
parents: 52445
diff changeset
765 def size(self, rev):
37440
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
766 """Obtain the fulltext size of file data.
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
767
39875
d909c44d29e1 filelog: stop proxying rawsize() (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39873
diff changeset
768 Any metadata is excluded from size measurements.
37440
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
769 """
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
770
52488
8c89e978375c interfaces: convert `repository.ifilestorage` to a Protocol class
Matt Harbison <matt_harbison@yahoo.com>
parents: 52487
diff changeset
771 @abc.abstractmethod
52446
c1674551c109 interfaces: add the missing `self` arg to the repository Protocol classes
Matt Harbison <matt_harbison@yahoo.com>
parents: 52445
diff changeset
772 def revision(self, node):
45946
464539c305aa formatting: drop a few extra double quotes in docstrings
Matt Harbison <matt_harbison@yahoo.com>
parents: 45942
diff changeset
773 """Obtain fulltext data for a node.
37440
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
774
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
775 By default, any storage transformations are applied before the data
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
776 is returned. If ``raw`` is True, non-raw storage transformations
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
777 are not applied.
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
778
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
779 The fulltext data may contain a header containing metadata. Most
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
780 consumers should use ``read()`` to obtain the actual file data.
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
781 """
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
782
52488
8c89e978375c interfaces: convert `repository.ifilestorage` to a Protocol class
Matt Harbison <matt_harbison@yahoo.com>
parents: 52487
diff changeset
783 @abc.abstractmethod
52446
c1674551c109 interfaces: add the missing `self` arg to the repository Protocol classes
Matt Harbison <matt_harbison@yahoo.com>
parents: 52445
diff changeset
784 def rawdata(self, node):
45942
89a2afe31e82 formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents: 45788
diff changeset
785 """Obtain raw data for a node."""
42727
bbe71b5afd02 rawdata: register the method for `ifiledata`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42723
diff changeset
786
52488
8c89e978375c interfaces: convert `repository.ifilestorage` to a Protocol class
Matt Harbison <matt_harbison@yahoo.com>
parents: 52487
diff changeset
787 @abc.abstractmethod
52446
c1674551c109 interfaces: add the missing `self` arg to the repository Protocol classes
Matt Harbison <matt_harbison@yahoo.com>
parents: 52445
diff changeset
788 def read(self, node):
37440
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
789 """Resolve file fulltext data.
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
790
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
791 This is similar to ``revision()`` except any metadata in the data
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
792 headers is stripped.
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
793 """
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
794
52488
8c89e978375c interfaces: convert `repository.ifilestorage` to a Protocol class
Matt Harbison <matt_harbison@yahoo.com>
parents: 52487
diff changeset
795 @abc.abstractmethod
52446
c1674551c109 interfaces: add the missing `self` arg to the repository Protocol classes
Matt Harbison <matt_harbison@yahoo.com>
parents: 52445
diff changeset
796 def renamed(self, node):
37440
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
797 """Obtain copy metadata for a node.
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
798
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
799 Returns ``False`` if no copy metadata is stored or a 2-tuple of
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
800 (path, node) from which this revision was copied.
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
801 """
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
802
52488
8c89e978375c interfaces: convert `repository.ifilestorage` to a Protocol class
Matt Harbison <matt_harbison@yahoo.com>
parents: 52487
diff changeset
803 @abc.abstractmethod
52446
c1674551c109 interfaces: add the missing `self` arg to the repository Protocol classes
Matt Harbison <matt_harbison@yahoo.com>
parents: 52445
diff changeset
804 def cmp(self, node, fulltext):
37440
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
805 """Compare fulltext to another revision.
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
806
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
807 Returns True if the fulltext is different from what is stored.
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
808
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
809 This takes copy metadata into account.
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
810
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
811 TODO better document the copy metadata and censoring logic.
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
812 """
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
813
52488
8c89e978375c interfaces: convert `repository.ifilestorage` to a Protocol class
Matt Harbison <matt_harbison@yahoo.com>
parents: 52487
diff changeset
814 @abc.abstractmethod
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43032
diff changeset
815 def emitrevisions(
52446
c1674551c109 interfaces: add the missing `self` arg to the repository Protocol classes
Matt Harbison <matt_harbison@yahoo.com>
parents: 52445
diff changeset
816 self,
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43032
diff changeset
817 nodes,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43032
diff changeset
818 nodesorder=None,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43032
diff changeset
819 revisiondata=False,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43032
diff changeset
820 assumehaveparentrevisions=False,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43032
diff changeset
821 deltamode=CG_DELTAMODE_STD,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43032
diff changeset
822 ):
39862
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39860
diff changeset
823 """Produce ``irevisiondelta`` for revisions.
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39860
diff changeset
824
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39860
diff changeset
825 Given an iterable of nodes, emits objects conforming to the
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39860
diff changeset
826 ``irevisiondelta`` interface that describe revisions in storage.
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39860
diff changeset
827
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39860
diff changeset
828 This method is a generator.
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39860
diff changeset
829
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39860
diff changeset
830 The input nodes may be unordered. Implementations must ensure that a
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39860
diff changeset
831 node's parents are emitted before the node itself. Transitively, this
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39860
diff changeset
832 means that a node may only be emitted once all its ancestors in
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39860
diff changeset
833 ``nodes`` have also been emitted.
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39860
diff changeset
834
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39860
diff changeset
835 By default, emits "index" data (the ``node``, ``p1node``, and
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39860
diff changeset
836 ``p2node`` attributes). If ``revisiondata`` is set, revision data
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39860
diff changeset
837 will also be present on the emitted objects.
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39860
diff changeset
838
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39860
diff changeset
839 With default argument values, implementations can choose to emit
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39860
diff changeset
840 either fulltext revision data or a delta. When emitting deltas,
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39860
diff changeset
841 implementations must consider whether the delta's base revision
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39860
diff changeset
842 fulltext is available to the receiver.
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39860
diff changeset
843
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39860
diff changeset
844 The base revision fulltext is guaranteed to be available if any of
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39860
diff changeset
845 the following are met:
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39860
diff changeset
846
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39860
diff changeset
847 * Its fulltext revision was emitted by this method call.
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39860
diff changeset
848 * A delta for that revision was emitted by this method call.
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39860
diff changeset
849 * ``assumehaveparentrevisions`` is True and the base revision is a
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39860
diff changeset
850 parent of the node.
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39860
diff changeset
851
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39860
diff changeset
852 ``nodesorder`` can be used to control the order that revisions are
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39860
diff changeset
853 emitted. By default, revisions can be reordered as long as they are
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39860
diff changeset
854 in DAG topological order (see above). If the value is ``nodes``,
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39860
diff changeset
855 the iteration order from ``nodes`` should be used. If the value is
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39860
diff changeset
856 ``storage``, then the native order from the backing storage layer
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39860
diff changeset
857 is used. (Not all storage layers will have strong ordering and behavior
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39860
diff changeset
858 of this mode is storage-dependent.) ``nodes`` ordering can force
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39860
diff changeset
859 revisions to be emitted before their ancestors, so consumers should
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39860
diff changeset
860 use it with care.
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39860
diff changeset
861
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39860
diff changeset
862 The ``linknode`` attribute on the returned ``irevisiondelta`` may not
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39860
diff changeset
863 be set and it is the caller's responsibility to resolve it, if needed.
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39860
diff changeset
864
40430
6a917075535a storage: also use `deltamode argument` for ifiledata
Boris Feld <boris.feld@octobus.net>
parents: 40427
diff changeset
865 If ``deltamode`` is CG_DELTAMODE_PREV and revision data is requested,
6a917075535a storage: also use `deltamode argument` for ifiledata
Boris Feld <boris.feld@octobus.net>
parents: 40427
diff changeset
866 all revision data should be emitted as deltas against the revision
6a917075535a storage: also use `deltamode argument` for ifiledata
Boris Feld <boris.feld@octobus.net>
parents: 40427
diff changeset
867 emitted just prior. The initial revision should be a delta against its
6a917075535a storage: also use `deltamode argument` for ifiledata
Boris Feld <boris.feld@octobus.net>
parents: 40427
diff changeset
868 1st parent.
39862
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39860
diff changeset
869 """
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39860
diff changeset
870
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43032
diff changeset
871
52445
26dd402c3497 interfaces: convert the repository zope interfaces to Protocol classes
Matt Harbison <matt_harbison@yahoo.com>
parents: 52432
diff changeset
872 class ifilemutation(Protocol):
37440
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
873 """Storage interface for mutation events of a tracked file."""
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
874
52488
8c89e978375c interfaces: convert `repository.ifilestorage` to a Protocol class
Matt Harbison <matt_harbison@yahoo.com>
parents: 52487
diff changeset
875 @abc.abstractmethod
52446
c1674551c109 interfaces: add the missing `self` arg to the repository Protocol classes
Matt Harbison <matt_harbison@yahoo.com>
parents: 52445
diff changeset
876 def add(self, filedata, meta, transaction, linkrev, p1, p2):
37440
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
877 """Add a new revision to the store.
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
878
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
879 Takes file data, dictionary of metadata, a transaction, linkrev,
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
880 and parent nodes.
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
881
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
882 Returns the node that was added.
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
883
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
884 May no-op if a revision matching the supplied data is already stored.
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
885 """
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
886
52488
8c89e978375c interfaces: convert `repository.ifilestorage` to a Protocol class
Matt Harbison <matt_harbison@yahoo.com>
parents: 52487
diff changeset
887 @abc.abstractmethod
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43032
diff changeset
888 def addrevision(
52446
c1674551c109 interfaces: add the missing `self` arg to the repository Protocol classes
Matt Harbison <matt_harbison@yahoo.com>
parents: 52445
diff changeset
889 self,
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43032
diff changeset
890 revisiondata,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43032
diff changeset
891 transaction,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43032
diff changeset
892 linkrev,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43032
diff changeset
893 p1,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43032
diff changeset
894 p2,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43032
diff changeset
895 node=None,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43032
diff changeset
896 flags=0,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43032
diff changeset
897 cachedelta=None,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43032
diff changeset
898 ):
46508
f7b61ad3c64a revlog: change addrevision to return the new revision, not node
Joerg Sonnenberger <joerg@bec.de>
parents: 46373
diff changeset
899 """Add a new revision to the store and return its number.
37440
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
900
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
901 This is similar to ``add()`` except it operates at a lower level.
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
902
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
903 The data passed in already contains a metadata header, if any.
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
904
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
905 ``node`` and ``flags`` can be used to define the expected node and
40047
8e398628a3f2 repository: define and use revision flag constants
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40027
diff changeset
906 the flags to use with storage. ``flags`` is a bitwise value composed
8e398628a3f2 repository: define and use revision flag constants
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40027
diff changeset
907 of the various ``REVISION_FLAG_*`` constants.
37440
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
908
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
909 ``add()`` is usually called when adding files from e.g. the working
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
910 directory. ``addrevision()`` is often called by ``add()`` and for
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
911 scenarios where revision data has already been computed, such as when
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
912 applying raw data from a peer repo.
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
913 """
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
914
52488
8c89e978375c interfaces: convert `repository.ifilestorage` to a Protocol class
Matt Harbison <matt_harbison@yahoo.com>
parents: 52487
diff changeset
915 @abc.abstractmethod
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43032
diff changeset
916 def addgroup(
52446
c1674551c109 interfaces: add the missing `self` arg to the repository Protocol classes
Matt Harbison <matt_harbison@yahoo.com>
parents: 52445
diff changeset
917 self,
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43032
diff changeset
918 deltas,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43032
diff changeset
919 linkmapper,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43032
diff changeset
920 transaction,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43032
diff changeset
921 addrevisioncb=None,
45788
a5206e71c536 revlog: extend addgroup() with callback for duplicates
Joerg Sonnenberger <joerg@bec.de>
parents: 45671
diff changeset
922 duplicaterevisioncb=None,
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43032
diff changeset
923 maybemissingparents=False,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43032
diff changeset
924 ):
37440
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
925 """Process a series of deltas for storage.
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
926
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
927 ``deltas`` is an iterable of 7-tuples of
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
928 (node, p1, p2, linknode, deltabase, delta, flags) defining revisions
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
929 to add.
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
930
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
931 The ``delta`` field contains ``mpatch`` data to apply to a base
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
932 revision, identified by ``deltabase``. The base node can be
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
933 ``nullid``, in which case the header from the delta can be ignored
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
934 and the delta used as the fulltext.
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
935
46373
711ba0f1057e revlog: decouple caching from addrevision callback for addgroup
Joerg Sonnenberger <joerg@bec.de>
parents: 46371
diff changeset
936 ``alwayscache`` instructs the lower layers to cache the content of the
711ba0f1057e revlog: decouple caching from addrevision callback for addgroup
Joerg Sonnenberger <joerg@bec.de>
parents: 46371
diff changeset
937 newly added revision, even if it needs to be explicitly computed.
711ba0f1057e revlog: decouple caching from addrevision callback for addgroup
Joerg Sonnenberger <joerg@bec.de>
parents: 46371
diff changeset
938 This used to be the default when ``addrevisioncb`` was provided up to
711ba0f1057e revlog: decouple caching from addrevision callback for addgroup
Joerg Sonnenberger <joerg@bec.de>
parents: 46371
diff changeset
939 Mercurial 5.8.
711ba0f1057e revlog: decouple caching from addrevision callback for addgroup
Joerg Sonnenberger <joerg@bec.de>
parents: 46371
diff changeset
940
46509
7a93b7b3dc2d revlog: change addgroup callbacks to take revision numbers
Joerg Sonnenberger <joerg@bec.de>
parents: 46508
diff changeset
941 ``addrevisioncb`` should be called for each new rev as it is committed.
7a93b7b3dc2d revlog: change addgroup callbacks to take revision numbers
Joerg Sonnenberger <joerg@bec.de>
parents: 46508
diff changeset
942 ``duplicaterevisioncb`` should be called for all revs with a
7a93b7b3dc2d revlog: change addgroup callbacks to take revision numbers
Joerg Sonnenberger <joerg@bec.de>
parents: 46508
diff changeset
943 pre-existing node.
37440
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
944
40389
1b183edbb68e repository: teach addgroup() to receive data with missing parents
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40387
diff changeset
945 ``maybemissingparents`` is a bool indicating whether the incoming
1b183edbb68e repository: teach addgroup() to receive data with missing parents
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40387
diff changeset
946 data may reference parents/ancestor revisions that aren't present.
1b183edbb68e repository: teach addgroup() to receive data with missing parents
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40387
diff changeset
947 This flag is set when receiving data into a "shallow" store that
1b183edbb68e repository: teach addgroup() to receive data with missing parents
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40387
diff changeset
948 doesn't hold all history.
1b183edbb68e repository: teach addgroup() to receive data with missing parents
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40387
diff changeset
949
37440
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
950 Returns a list of nodes that were processed. A node will be in the list
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
951 even if it existed in the store previously.
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
952 """
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
953
52488
8c89e978375c interfaces: convert `repository.ifilestorage` to a Protocol class
Matt Harbison <matt_harbison@yahoo.com>
parents: 52487
diff changeset
954 @abc.abstractmethod
52446
c1674551c109 interfaces: add the missing `self` arg to the repository Protocol classes
Matt Harbison <matt_harbison@yahoo.com>
parents: 52445
diff changeset
955 def censorrevision(self, tr, node, tombstone=b''):
39778
a6b3c4c1019f revlog: move censor logic out of censor extension
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39776
diff changeset
956 """Remove the content of a single revision.
a6b3c4c1019f revlog: move censor logic out of censor extension
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39776
diff changeset
957
a6b3c4c1019f revlog: move censor logic out of censor extension
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39776
diff changeset
958 The specified ``node`` will have its content purged from storage.
a6b3c4c1019f revlog: move censor logic out of censor extension
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39776
diff changeset
959 Future attempts to access the revision data for this node will
a6b3c4c1019f revlog: move censor logic out of censor extension
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39776
diff changeset
960 result in failure.
a6b3c4c1019f revlog: move censor logic out of censor extension
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39776
diff changeset
961
a6b3c4c1019f revlog: move censor logic out of censor extension
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39776
diff changeset
962 A ``tombstone`` message can optionally be stored. This message may be
a6b3c4c1019f revlog: move censor logic out of censor extension
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39776
diff changeset
963 displayed to users when they attempt to access the missing revision
a6b3c4c1019f revlog: move censor logic out of censor extension
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39776
diff changeset
964 data.
a6b3c4c1019f revlog: move censor logic out of censor extension
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39776
diff changeset
965
a6b3c4c1019f revlog: move censor logic out of censor extension
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39776
diff changeset
966 Storage backends may have stored deltas against the previous content
a6b3c4c1019f revlog: move censor logic out of censor extension
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39776
diff changeset
967 in this revision. As part of censoring a revision, these storage
a6b3c4c1019f revlog: move censor logic out of censor extension
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39776
diff changeset
968 backends are expected to rewrite any internally stored deltas such
a6b3c4c1019f revlog: move censor logic out of censor extension
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39776
diff changeset
969 that they no longer reference the deleted content.
a6b3c4c1019f revlog: move censor logic out of censor extension
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39776
diff changeset
970 """
a6b3c4c1019f revlog: move censor logic out of censor extension
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39776
diff changeset
971
52488
8c89e978375c interfaces: convert `repository.ifilestorage` to a Protocol class
Matt Harbison <matt_harbison@yahoo.com>
parents: 52487
diff changeset
972 @abc.abstractmethod
52446
c1674551c109 interfaces: add the missing `self` arg to the repository Protocol classes
Matt Harbison <matt_harbison@yahoo.com>
parents: 52445
diff changeset
973 def getstrippoint(self, minlink):
37440
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
974 """Find the minimum revision that must be stripped to strip a linkrev.
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
975
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
976 Returns a 2-tuple containing the minimum revision number and a set
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
977 of all revisions numbers that would be broken by this strip.
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
978
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
979 TODO this is highly revlog centric and should be abstracted into
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
980 a higher-level deletion API. ``repair.strip()`` relies on this.
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
981 """
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
982
52488
8c89e978375c interfaces: convert `repository.ifilestorage` to a Protocol class
Matt Harbison <matt_harbison@yahoo.com>
parents: 52487
diff changeset
983 @abc.abstractmethod
52446
c1674551c109 interfaces: add the missing `self` arg to the repository Protocol classes
Matt Harbison <matt_harbison@yahoo.com>
parents: 52445
diff changeset
984 def strip(self, minlink, transaction):
37440
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
985 """Remove storage of items starting at a linkrev.
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
986
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
987 This uses ``getstrippoint()`` to determine the first node to remove.
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
988 Then it effectively truncates storage for all revisions after that.
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
989
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
990 TODO this is highly revlog centric and should be abstracted into a
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
991 higher-level deletion API.
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
992 """
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
993
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43032
diff changeset
994
52488
8c89e978375c interfaces: convert `repository.ifilestorage` to a Protocol class
Matt Harbison <matt_harbison@yahoo.com>
parents: 52487
diff changeset
995 class ifilestorage(ifileindex, ifiledata, ifilemutation, Protocol):
37440
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
996 """Complete storage interface for a single tracked file."""
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
997
52488
8c89e978375c interfaces: convert `repository.ifilestorage` to a Protocol class
Matt Harbison <matt_harbison@yahoo.com>
parents: 52487
diff changeset
998 @abc.abstractmethod
52446
c1674551c109 interfaces: add the missing `self` arg to the repository Protocol classes
Matt Harbison <matt_harbison@yahoo.com>
parents: 52445
diff changeset
999 def files(self):
37440
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
1000 """Obtain paths that are backing storage for this file.
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
1001
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
1002 TODO this is used heavily by verify code and there should probably
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
1003 be a better API for that.
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
1004 """
4335a75f0bd0 repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37351
diff changeset
1005
52488
8c89e978375c interfaces: convert `repository.ifilestorage` to a Protocol class
Matt Harbison <matt_harbison@yahoo.com>
parents: 52487
diff changeset
1006 @abc.abstractmethod
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43032
diff changeset
1007 def storageinfo(
52446
c1674551c109 interfaces: add the missing `self` arg to the repository Protocol classes
Matt Harbison <matt_harbison@yahoo.com>
parents: 52445
diff changeset
1008 self,
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43032
diff changeset
1009 exclusivefiles=False,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43032
diff changeset
1010 sharedfiles=False,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43032
diff changeset
1011 revisionscount=False,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43032
diff changeset
1012 trackedsize=False,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43032
diff changeset
1013 storedsize=False,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43032
diff changeset
1014 ):
39869
14e500b58263 revlog: add method for obtaining storage info (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39867
diff changeset
1015 """Obtain information about storage for this file's data.
14e500b58263 revlog: add method for obtaining storage info (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39867
diff changeset
1016
14e500b58263 revlog: add method for obtaining storage info (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39867
diff changeset
1017 Returns a dict describing storage for this tracked path. The keys
14e500b58263 revlog: add method for obtaining storage info (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39867
diff changeset
1018 in the dict map to arguments of the same. The arguments are bools
14e500b58263 revlog: add method for obtaining storage info (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39867
diff changeset
1019 indicating whether to calculate and obtain that data.
14e500b58263 revlog: add method for obtaining storage info (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39867
diff changeset
1020
14e500b58263 revlog: add method for obtaining storage info (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39867
diff changeset
1021 exclusivefiles
14e500b58263 revlog: add method for obtaining storage info (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39867
diff changeset
1022 Iterable of (vfs, path) describing files that are exclusively
14e500b58263 revlog: add method for obtaining storage info (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39867
diff changeset
1023 used to back storage for this tracked path.
14e500b58263 revlog: add method for obtaining storage info (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39867
diff changeset
1024
14e500b58263 revlog: add method for obtaining storage info (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39867
diff changeset
1025 sharedfiles
14e500b58263 revlog: add method for obtaining storage info (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39867
diff changeset
1026 Iterable of (vfs, path) describing files that are used to back
14e500b58263 revlog: add method for obtaining storage info (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39867
diff changeset
1027 storage for this tracked path. Those files may also provide storage
14e500b58263 revlog: add method for obtaining storage info (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39867
diff changeset
1028 for other stored entities.
14e500b58263 revlog: add method for obtaining storage info (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39867
diff changeset
1029
14e500b58263 revlog: add method for obtaining storage info (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39867
diff changeset
1030 revisionscount
14e500b58263 revlog: add method for obtaining storage info (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39867
diff changeset
1031 Number of revisions available for retrieval.
14e500b58263 revlog: add method for obtaining storage info (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39867
diff changeset
1032
14e500b58263 revlog: add method for obtaining storage info (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39867
diff changeset
1033 trackedsize
14e500b58263 revlog: add method for obtaining storage info (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39867
diff changeset
1034 Total size in bytes of all tracked revisions. This is a sum of the
14e500b58263 revlog: add method for obtaining storage info (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39867
diff changeset
1035 length of the fulltext of all revisions.
14e500b58263 revlog: add method for obtaining storage info (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39867
diff changeset
1036
14e500b58263 revlog: add method for obtaining storage info (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39867
diff changeset
1037 storedsize
14e500b58263 revlog: add method for obtaining storage info (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39867
diff changeset
1038 Total size in bytes used to store data for all tracked revisions.
14e500b58263 revlog: add method for obtaining storage info (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39867
diff changeset
1039 This is commonly less than ``trackedsize`` due to internal usage
14e500b58263 revlog: add method for obtaining storage info (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39867
diff changeset
1040 of deltas rather than fulltext revisions.
14e500b58263 revlog: add method for obtaining storage info (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39867
diff changeset
1041
14e500b58263 revlog: add method for obtaining storage info (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39867
diff changeset
1042 Not all storage backends may support all queries are have a reasonable
14e500b58263 revlog: add method for obtaining storage info (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39867
diff changeset
1043 value to use. In that case, the value should be set to ``None`` and
14e500b58263 revlog: add method for obtaining storage info (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39867
diff changeset
1044 callers are expected to handle this special value.
14e500b58263 revlog: add method for obtaining storage info (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39867
diff changeset
1045 """
14e500b58263 revlog: add method for obtaining storage info (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39867
diff changeset
1046
52488
8c89e978375c interfaces: convert `repository.ifilestorage` to a Protocol class
Matt Harbison <matt_harbison@yahoo.com>
parents: 52487
diff changeset
1047 @abc.abstractmethod
52487
3daaa5195a30 typing: align the signatures of `repository.ifilestorage` overrides
Matt Harbison <matt_harbison@yahoo.com>
parents: 52486
diff changeset
1048 def verifyintegrity(self, state) -> Iterable[iverifyproblem]:
39842
97986c9c69d3 verify: start to abstract file verification
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39785
diff changeset
1049 """Verifies the integrity of file storage.
97986c9c69d3 verify: start to abstract file verification
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39785
diff changeset
1050
97986c9c69d3 verify: start to abstract file verification
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39785
diff changeset
1051 ``state`` is a dict holding state of the verifier process. It can be
97986c9c69d3 verify: start to abstract file verification
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39785
diff changeset
1052 used to communicate data between invocations of multiple storage
97986c9c69d3 verify: start to abstract file verification
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39785
diff changeset
1053 primitives.
97986c9c69d3 verify: start to abstract file verification
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39785
diff changeset
1054
39872
733db72f0f54 revlog: move revision verification out of verify
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39869
diff changeset
1055 If individual revisions cannot have their revision content resolved,
733db72f0f54 revlog: move revision verification out of verify
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39869
diff changeset
1056 the method is expected to set the ``skipread`` key to a set of nodes
44073
b9e174d4ed11 verify: allow the storage to signal when renames can be tested on `skipread`
Matt Harbison <matt_harbison@yahoo.com>
parents: 43712
diff changeset
1057 that encountered problems. If set, the method can also add the node(s)
b9e174d4ed11 verify: allow the storage to signal when renames can be tested on `skipread`
Matt Harbison <matt_harbison@yahoo.com>
parents: 43712
diff changeset
1058 to ``safe_renamed`` in order to indicate nodes that may perform the
b9e174d4ed11 verify: allow the storage to signal when renames can be tested on `skipread`
Matt Harbison <matt_harbison@yahoo.com>
parents: 43712
diff changeset
1059 rename checks with currently accessible data.
39872
733db72f0f54 revlog: move revision verification out of verify
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39869
diff changeset
1060
39842
97986c9c69d3 verify: start to abstract file verification
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39785
diff changeset
1061 The method yields objects conforming to the ``iverifyproblem``
97986c9c69d3 verify: start to abstract file verification
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39785
diff changeset
1062 interface.
97986c9c69d3 verify: start to abstract file verification
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39785
diff changeset
1063 """
97986c9c69d3 verify: start to abstract file verification
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39785
diff changeset
1064
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43032
diff changeset
1065
52445
26dd402c3497 interfaces: convert the repository zope interfaces to Protocol classes
Matt Harbison <matt_harbison@yahoo.com>
parents: 52432
diff changeset
1066 class idirs(Protocol):
38530
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
1067 """Interface representing a collection of directories from paths.
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
1068
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
1069 This interface is essentially a derived data structure representing
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
1070 directories from a collection of paths.
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
1071 """
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
1072
52499
9358d786af24 interfaces: make all methods on any repository Protocol class abstract
Matt Harbison <matt_harbison@yahoo.com>
parents: 52497
diff changeset
1073 @abc.abstractmethod
52446
c1674551c109 interfaces: add the missing `self` arg to the repository Protocol classes
Matt Harbison <matt_harbison@yahoo.com>
parents: 52445
diff changeset
1074 def addpath(self, path):
38530
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
1075 """Add a path to the collection.
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
1076
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
1077 All directories in the path will be added to the collection.
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
1078 """
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
1079
52499
9358d786af24 interfaces: make all methods on any repository Protocol class abstract
Matt Harbison <matt_harbison@yahoo.com>
parents: 52497
diff changeset
1080 @abc.abstractmethod
52446
c1674551c109 interfaces: add the missing `self` arg to the repository Protocol classes
Matt Harbison <matt_harbison@yahoo.com>
parents: 52445
diff changeset
1081 def delpath(self, path):
38530
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
1082 """Remove a path from the collection.
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
1083
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
1084 If the removal was the last path in a particular directory, the
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
1085 directory is removed from the collection.
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
1086 """
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
1087
52499
9358d786af24 interfaces: make all methods on any repository Protocol class abstract
Matt Harbison <matt_harbison@yahoo.com>
parents: 52497
diff changeset
1088 @abc.abstractmethod
52446
c1674551c109 interfaces: add the missing `self` arg to the repository Protocol classes
Matt Harbison <matt_harbison@yahoo.com>
parents: 52445
diff changeset
1089 def __iter__(self):
38530
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
1090 """Iterate over the directories in this collection of paths."""
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
1091
52499
9358d786af24 interfaces: make all methods on any repository Protocol class abstract
Matt Harbison <matt_harbison@yahoo.com>
parents: 52497
diff changeset
1092 @abc.abstractmethod
52446
c1674551c109 interfaces: add the missing `self` arg to the repository Protocol classes
Matt Harbison <matt_harbison@yahoo.com>
parents: 52445
diff changeset
1093 def __contains__(self, path):
38530
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
1094 """Whether a specific directory is in this collection."""
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
1095
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43032
diff changeset
1096
52445
26dd402c3497 interfaces: convert the repository zope interfaces to Protocol classes
Matt Harbison <matt_harbison@yahoo.com>
parents: 52432
diff changeset
1097 class imanifestdict(Protocol):
38530
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
1098 """Interface representing a manifest data structure.
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
1099
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
1100 A manifest is effectively a dict mapping paths to entries. Each entry
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
1101 consists of a binary node and extra flags affecting that entry.
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
1102 """
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
1103
52493
3913f9509476 interfaces: make `repository.imanifestdict` methods abstract
Matt Harbison <matt_harbison@yahoo.com>
parents: 52492
diff changeset
1104 @abc.abstractmethod
52492
48cdbd4d5443 typing: align the signatures of `repository.imanifestdict` overrides
Matt Harbison <matt_harbison@yahoo.com>
parents: 52490
diff changeset
1105 def __getitem__(self, key: bytes) -> bytes:
38530
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
1106 """Returns the binary node value for a path in the manifest.
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
1107
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
1108 Raises ``KeyError`` if the path does not exist in the manifest.
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
1109
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
1110 Equivalent to ``self.find(path)[0]``.
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
1111 """
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
1112
52493
3913f9509476 interfaces: make `repository.imanifestdict` methods abstract
Matt Harbison <matt_harbison@yahoo.com>
parents: 52492
diff changeset
1113 @abc.abstractmethod
52492
48cdbd4d5443 typing: align the signatures of `repository.imanifestdict` overrides
Matt Harbison <matt_harbison@yahoo.com>
parents: 52490
diff changeset
1114 def find(self, path: bytes) -> tuple[bytes, bytes]:
38530
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
1115 """Returns the entry for a path in the manifest.
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
1116
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
1117 Returns a 2-tuple of (node, flags).
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
1118
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
1119 Raises ``KeyError`` if the path does not exist in the manifest.
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
1120 """
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
1121
52493
3913f9509476 interfaces: make `repository.imanifestdict` methods abstract
Matt Harbison <matt_harbison@yahoo.com>
parents: 52492
diff changeset
1122 @abc.abstractmethod
52492
48cdbd4d5443 typing: align the signatures of `repository.imanifestdict` overrides
Matt Harbison <matt_harbison@yahoo.com>
parents: 52490
diff changeset
1123 def __len__(self) -> int:
38530
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
1124 """Return the number of entries in the manifest."""
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
1125
52493
3913f9509476 interfaces: make `repository.imanifestdict` methods abstract
Matt Harbison <matt_harbison@yahoo.com>
parents: 52492
diff changeset
1126 @abc.abstractmethod
52492
48cdbd4d5443 typing: align the signatures of `repository.imanifestdict` overrides
Matt Harbison <matt_harbison@yahoo.com>
parents: 52490
diff changeset
1127 def __nonzero__(self) -> bool:
38530
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
1128 """Returns True if the manifest has entries, False otherwise."""
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
1129
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
1130 __bool__ = __nonzero__
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
1131
52493
3913f9509476 interfaces: make `repository.imanifestdict` methods abstract
Matt Harbison <matt_harbison@yahoo.com>
parents: 52492
diff changeset
1132 @abc.abstractmethod
52492
48cdbd4d5443 typing: align the signatures of `repository.imanifestdict` overrides
Matt Harbison <matt_harbison@yahoo.com>
parents: 52490
diff changeset
1133 def set(self, path: bytes, node: bytes, flags: bytes) -> None:
51754
421c9b3f2f4e commit: set whole manifest entries at once (node with its associated flags)
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents: 51534
diff changeset
1134 """Define the node value and flags for a path in the manifest.
421c9b3f2f4e commit: set whole manifest entries at once (node with its associated flags)
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents: 51534
diff changeset
1135
421c9b3f2f4e commit: set whole manifest entries at once (node with its associated flags)
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents: 51534
diff changeset
1136 Equivalent to __setitem__ followed by setflag, but can be more efficient.
421c9b3f2f4e commit: set whole manifest entries at once (node with its associated flags)
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents: 51534
diff changeset
1137 """
421c9b3f2f4e commit: set whole manifest entries at once (node with its associated flags)
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents: 51534
diff changeset
1138
52493
3913f9509476 interfaces: make `repository.imanifestdict` methods abstract
Matt Harbison <matt_harbison@yahoo.com>
parents: 52492
diff changeset
1139 @abc.abstractmethod
52492
48cdbd4d5443 typing: align the signatures of `repository.imanifestdict` overrides
Matt Harbison <matt_harbison@yahoo.com>
parents: 52490
diff changeset
1140 def __setitem__(self, path: bytes, node: bytes) -> None:
38530
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
1141 """Define the node value for a path in the manifest.
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
1142
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
1143 If the path is already in the manifest, its flags will be copied to
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
1144 the new entry.
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
1145 """
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
1146
52493
3913f9509476 interfaces: make `repository.imanifestdict` methods abstract
Matt Harbison <matt_harbison@yahoo.com>
parents: 52492
diff changeset
1147 @abc.abstractmethod
52492
48cdbd4d5443 typing: align the signatures of `repository.imanifestdict` overrides
Matt Harbison <matt_harbison@yahoo.com>
parents: 52490
diff changeset
1148 def __contains__(self, path: bytes) -> bool:
38530
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
1149 """Whether a path exists in the manifest."""
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
1150
52493
3913f9509476 interfaces: make `repository.imanifestdict` methods abstract
Matt Harbison <matt_harbison@yahoo.com>
parents: 52492
diff changeset
1151 @abc.abstractmethod
52492
48cdbd4d5443 typing: align the signatures of `repository.imanifestdict` overrides
Matt Harbison <matt_harbison@yahoo.com>
parents: 52490
diff changeset
1152 def __delitem__(self, path: bytes) -> None:
38530
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
1153 """Remove a path from the manifest.
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
1154
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
1155 Raises ``KeyError`` if the path is not in the manifest.
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
1156 """
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
1157
52493
3913f9509476 interfaces: make `repository.imanifestdict` methods abstract
Matt Harbison <matt_harbison@yahoo.com>
parents: 52492
diff changeset
1158 @abc.abstractmethod
52492
48cdbd4d5443 typing: align the signatures of `repository.imanifestdict` overrides
Matt Harbison <matt_harbison@yahoo.com>
parents: 52490
diff changeset
1159 def __iter__(self) -> Iterator[bytes]:
38530
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
1160 """Iterate over paths in the manifest."""
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
1161
52493
3913f9509476 interfaces: make `repository.imanifestdict` methods abstract
Matt Harbison <matt_harbison@yahoo.com>
parents: 52492
diff changeset
1162 @abc.abstractmethod
52492
48cdbd4d5443 typing: align the signatures of `repository.imanifestdict` overrides
Matt Harbison <matt_harbison@yahoo.com>
parents: 52490
diff changeset
1163 def iterkeys(self) -> Iterator[bytes]:
38530
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
1164 """Iterate over paths in the manifest."""
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
1165
52493
3913f9509476 interfaces: make `repository.imanifestdict` methods abstract
Matt Harbison <matt_harbison@yahoo.com>
parents: 52492
diff changeset
1166 @abc.abstractmethod
52492
48cdbd4d5443 typing: align the signatures of `repository.imanifestdict` overrides
Matt Harbison <matt_harbison@yahoo.com>
parents: 52490
diff changeset
1167 def keys(self) -> list[bytes]:
38530
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
1168 """Obtain a list of paths in the manifest."""
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
1169
52493
3913f9509476 interfaces: make `repository.imanifestdict` methods abstract
Matt Harbison <matt_harbison@yahoo.com>
parents: 52492
diff changeset
1170 @abc.abstractmethod
52492
48cdbd4d5443 typing: align the signatures of `repository.imanifestdict` overrides
Matt Harbison <matt_harbison@yahoo.com>
parents: 52490
diff changeset
1171 def filesnotin(self, other, match=None) -> Set[bytes]:
38530
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
1172 """Obtain the set of paths in this manifest but not in another.
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
1173
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
1174 ``match`` is an optional matcher function to be applied to both
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
1175 manifests.
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
1176
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
1177 Returns a set of paths.
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
1178 """
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
1179
52493
3913f9509476 interfaces: make `repository.imanifestdict` methods abstract
Matt Harbison <matt_harbison@yahoo.com>
parents: 52492
diff changeset
1180 @abc.abstractmethod
52492
48cdbd4d5443 typing: align the signatures of `repository.imanifestdict` overrides
Matt Harbison <matt_harbison@yahoo.com>
parents: 52490
diff changeset
1181 def dirs(self) -> pathutil.dirs:
38530
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
1182 """Returns an object implementing the ``idirs`` interface."""
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
1183
52493
3913f9509476 interfaces: make `repository.imanifestdict` methods abstract
Matt Harbison <matt_harbison@yahoo.com>
parents: 52492
diff changeset
1184 @abc.abstractmethod
52492
48cdbd4d5443 typing: align the signatures of `repository.imanifestdict` overrides
Matt Harbison <matt_harbison@yahoo.com>
parents: 52490
diff changeset
1185 def hasdir(self, dir: bytes) -> bool:
38530
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
1186 """Returns a bool indicating if a directory is in this manifest."""
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
1187
52493
3913f9509476 interfaces: make `repository.imanifestdict` methods abstract
Matt Harbison <matt_harbison@yahoo.com>
parents: 52492
diff changeset
1188 @abc.abstractmethod
52741
5c48fd4c0e68 typing: introduce a `types` module and a MatcherT alias
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 52725
diff changeset
1189 def walk(self, match: matcher.IMatcher) -> Iterator[bytes]:
38530
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
1190 """Generator of paths in manifest satisfying a matcher.
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
1191
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
1192 If the matcher has explicit files listed and they don't exist in
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
1193 the manifest, ``match.bad()`` is called for each missing file.
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
1194 """
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
1195
52493
3913f9509476 interfaces: make `repository.imanifestdict` methods abstract
Matt Harbison <matt_harbison@yahoo.com>
parents: 52492
diff changeset
1196 @abc.abstractmethod
52492
48cdbd4d5443 typing: align the signatures of `repository.imanifestdict` overrides
Matt Harbison <matt_harbison@yahoo.com>
parents: 52490
diff changeset
1197 def diff(
48cdbd4d5443 typing: align the signatures of `repository.imanifestdict` overrides
Matt Harbison <matt_harbison@yahoo.com>
parents: 52490
diff changeset
1198 self,
48cdbd4d5443 typing: align the signatures of `repository.imanifestdict` overrides
Matt Harbison <matt_harbison@yahoo.com>
parents: 52490
diff changeset
1199 other: Any, # TODO: 'manifestdict' or (better) equivalent interface
52741
5c48fd4c0e68 typing: introduce a `types` module and a MatcherT alias
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 52725
diff changeset
1200 match: matcher.IMatcher | None = None,
52492
48cdbd4d5443 typing: align the signatures of `repository.imanifestdict` overrides
Matt Harbison <matt_harbison@yahoo.com>
parents: 52490
diff changeset
1201 clean: bool = False,
48cdbd4d5443 typing: align the signatures of `repository.imanifestdict` overrides
Matt Harbison <matt_harbison@yahoo.com>
parents: 52490
diff changeset
1202 ) -> dict[
48cdbd4d5443 typing: align the signatures of `repository.imanifestdict` overrides
Matt Harbison <matt_harbison@yahoo.com>
parents: 52490
diff changeset
1203 bytes,
48cdbd4d5443 typing: align the signatures of `repository.imanifestdict` overrides
Matt Harbison <matt_harbison@yahoo.com>
parents: 52490
diff changeset
1204 tuple[tuple[bytes | None, bytes], tuple[bytes | None, bytes]] | None,
48cdbd4d5443 typing: align the signatures of `repository.imanifestdict` overrides
Matt Harbison <matt_harbison@yahoo.com>
parents: 52490
diff changeset
1205 ]:
38530
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
1206 """Find differences between this manifest and another.
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
1207
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
1208 This manifest is compared to ``other``.
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
1209
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
1210 If ``match`` is provided, the two manifests are filtered against this
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
1211 matcher and only entries satisfying the matcher are compared.
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
1212
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
1213 If ``clean`` is True, unchanged files are included in the returned
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
1214 object.
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
1215
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
1216 Returns a dict with paths as keys and values of 2-tuples of 2-tuples of
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
1217 the form ``((node1, flag1), (node2, flag2))`` where ``(node1, flag1)``
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
1218 represents the node and flags for this manifest and ``(node2, flag2)``
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
1219 are the same for the other manifest.
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
1220 """
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
1221
52493
3913f9509476 interfaces: make `repository.imanifestdict` methods abstract
Matt Harbison <matt_harbison@yahoo.com>
parents: 52492
diff changeset
1222 @abc.abstractmethod
52492
48cdbd4d5443 typing: align the signatures of `repository.imanifestdict` overrides
Matt Harbison <matt_harbison@yahoo.com>
parents: 52490
diff changeset
1223 def setflag(self, path: bytes, flag: bytes) -> None:
38530
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
1224 """Set the flag value for a given path.
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
1225
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
1226 Raises ``KeyError`` if the path is not already in the manifest.
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
1227 """
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
1228
52493
3913f9509476 interfaces: make `repository.imanifestdict` methods abstract
Matt Harbison <matt_harbison@yahoo.com>
parents: 52492
diff changeset
1229 @abc.abstractmethod
52492
48cdbd4d5443 typing: align the signatures of `repository.imanifestdict` overrides
Matt Harbison <matt_harbison@yahoo.com>
parents: 52490
diff changeset
1230 def get(self, path: bytes, default=None) -> bytes | None:
38530
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
1231 """Obtain the node value for a path or a default value if missing."""
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
1232
52493
3913f9509476 interfaces: make `repository.imanifestdict` methods abstract
Matt Harbison <matt_harbison@yahoo.com>
parents: 52492
diff changeset
1233 @abc.abstractmethod
52492
48cdbd4d5443 typing: align the signatures of `repository.imanifestdict` overrides
Matt Harbison <matt_harbison@yahoo.com>
parents: 52490
diff changeset
1234 def flags(self, path: bytes) -> bytes:
44257
dbbae122f5e4 manifest: remove optional default= argument on flags(path)
Augie Fackler <augie@google.com>
parents: 44073
diff changeset
1235 """Return the flags value for a path (default: empty bytestring)."""
38530
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
1236
52493
3913f9509476 interfaces: make `repository.imanifestdict` methods abstract
Matt Harbison <matt_harbison@yahoo.com>
parents: 52492
diff changeset
1237 @abc.abstractmethod
52645
4cb75772818d pyupgrade: drop the quoting around type annotations
Matt Harbison <matt_harbison@yahoo.com>
parents: 52521
diff changeset
1238 def copy(self) -> imanifestdict:
38530
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
1239 """Return a copy of this manifest."""
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
1240
52493
3913f9509476 interfaces: make `repository.imanifestdict` methods abstract
Matt Harbison <matt_harbison@yahoo.com>
parents: 52492
diff changeset
1241 @abc.abstractmethod
52492
48cdbd4d5443 typing: align the signatures of `repository.imanifestdict` overrides
Matt Harbison <matt_harbison@yahoo.com>
parents: 52490
diff changeset
1242 def items(self) -> Iterator[tuple[bytes, bytes]]:
38530
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
1243 """Returns an iterable of (path, node) for items in this manifest."""
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
1244
52493
3913f9509476 interfaces: make `repository.imanifestdict` methods abstract
Matt Harbison <matt_harbison@yahoo.com>
parents: 52492
diff changeset
1245 @abc.abstractmethod
52492
48cdbd4d5443 typing: align the signatures of `repository.imanifestdict` overrides
Matt Harbison <matt_harbison@yahoo.com>
parents: 52490
diff changeset
1246 def iteritems(self) -> Iterator[tuple[bytes, bytes]]:
38530
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
1247 """Identical to items()."""
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
1248
52493
3913f9509476 interfaces: make `repository.imanifestdict` methods abstract
Matt Harbison <matt_harbison@yahoo.com>
parents: 52492
diff changeset
1249 @abc.abstractmethod
52492
48cdbd4d5443 typing: align the signatures of `repository.imanifestdict` overrides
Matt Harbison <matt_harbison@yahoo.com>
parents: 52490
diff changeset
1250 def iterentries(self) -> Iterator[tuple[bytes, bytes, bytes]]:
38530
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
1251 """Returns an iterable of (path, node, flags) for this manifest.
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
1252
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
1253 Similar to ``iteritems()`` except items are a 3-tuple and include
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
1254 flags.
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
1255 """
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
1256
52493
3913f9509476 interfaces: make `repository.imanifestdict` methods abstract
Matt Harbison <matt_harbison@yahoo.com>
parents: 52492
diff changeset
1257 @abc.abstractmethod
52492
48cdbd4d5443 typing: align the signatures of `repository.imanifestdict` overrides
Matt Harbison <matt_harbison@yahoo.com>
parents: 52490
diff changeset
1258 def text(self) -> ByteString:
38530
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
1259 """Obtain the raw data representation for this manifest.
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
1260
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
1261 Result is used to create a manifest revision.
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
1262 """
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
1263
52493
3913f9509476 interfaces: make `repository.imanifestdict` methods abstract
Matt Harbison <matt_harbison@yahoo.com>
parents: 52492
diff changeset
1264 @abc.abstractmethod
52492
48cdbd4d5443 typing: align the signatures of `repository.imanifestdict` overrides
Matt Harbison <matt_harbison@yahoo.com>
parents: 52490
diff changeset
1265 def fastdelta(
48cdbd4d5443 typing: align the signatures of `repository.imanifestdict` overrides
Matt Harbison <matt_harbison@yahoo.com>
parents: 52490
diff changeset
1266 self, base: ByteString, changes: Iterable[tuple[bytes, bool]]
48cdbd4d5443 typing: align the signatures of `repository.imanifestdict` overrides
Matt Harbison <matt_harbison@yahoo.com>
parents: 52490
diff changeset
1267 ) -> tuple[ByteString, ByteString]:
38530
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
1268 """Obtain a delta between this manifest and another given changes.
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
1269
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
1270 ``base`` in the raw data representation for another manifest.
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
1271
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
1272 ``changes`` is an iterable of ``(path, to_delete)``.
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
1273
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
1274 Returns a 2-tuple containing ``bytearray(self.text())`` and the
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
1275 delta between ``base`` and this manifest.
44663
948fac24bc39 manifest: introduce new exception to signal unavailability of fastdelta()
Augie Fackler <augie@google.com>
parents: 44352
diff changeset
1276
948fac24bc39 manifest: introduce new exception to signal unavailability of fastdelta()
Augie Fackler <augie@google.com>
parents: 44352
diff changeset
1277 If this manifest implementation can't support ``fastdelta()``,
948fac24bc39 manifest: introduce new exception to signal unavailability of fastdelta()
Augie Fackler <augie@google.com>
parents: 44352
diff changeset
1278 raise ``mercurial.manifest.FastdeltaUnavailable``.
38530
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
1279 """
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
1280
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43032
diff changeset
1281
52445
26dd402c3497 interfaces: convert the repository zope interfaces to Protocol classes
Matt Harbison <matt_harbison@yahoo.com>
parents: 52432
diff changeset
1282 class imanifestrevisionbase(Protocol):
38530
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
1283 """Base interface representing a single revision of a manifest.
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
1284
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
1285 Should not be used as a primary interface: should always be inherited
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
1286 as part of a larger interface.
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
1287 """
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
1288
52499
9358d786af24 interfaces: make all methods on any repository Protocol class abstract
Matt Harbison <matt_harbison@yahoo.com>
parents: 52497
diff changeset
1289 @abc.abstractmethod
52446
c1674551c109 interfaces: add the missing `self` arg to the repository Protocol classes
Matt Harbison <matt_harbison@yahoo.com>
parents: 52445
diff changeset
1290 def copy(self):
38530
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
1291 """Obtain a copy of this manifest instance.
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
1292
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
1293 Returns an object conforming to the ``imanifestrevisionwritable``
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
1294 interface. The instance will be associated with the same
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
1295 ``imanifestlog`` collection as this instance.
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
1296 """
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
1297
52499
9358d786af24 interfaces: make all methods on any repository Protocol class abstract
Matt Harbison <matt_harbison@yahoo.com>
parents: 52497
diff changeset
1298 @abc.abstractmethod
52446
c1674551c109 interfaces: add the missing `self` arg to the repository Protocol classes
Matt Harbison <matt_harbison@yahoo.com>
parents: 52445
diff changeset
1299 def read(self):
38530
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
1300 """Obtain the parsed manifest data structure.
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
1301
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
1302 The returned object conforms to the ``imanifestdict`` interface.
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
1303 """
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
1304
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43032
diff changeset
1305
52475
cdd4bc69bfc1 interfaces: convert `imanifestrevisionstored` to a Protocol class
Matt Harbison <matt_harbison@yahoo.com>
parents: 52474
diff changeset
1306 class imanifestrevisionstored(imanifestrevisionbase, Protocol):
38530
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
1307 """Interface representing a manifest revision committed to storage."""
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
1308
52475
cdd4bc69bfc1 interfaces: convert `imanifestrevisionstored` to a Protocol class
Matt Harbison <matt_harbison@yahoo.com>
parents: 52474
diff changeset
1309 @abc.abstractmethod
52474
048c11993d6a typing: (mostly) align the signatures of `imanifestrevisionstored` overrides
Matt Harbison <matt_harbison@yahoo.com>
parents: 52473
diff changeset
1310 def node(self) -> bytes:
38530
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
1311 """The binary node for this manifest."""
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
1312
52473
a1dd484bf33b interfaces: convert `imanifestrevisionstored` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52472
diff changeset
1313 parents: list[bytes]
a1dd484bf33b interfaces: convert `imanifestrevisionstored` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52472
diff changeset
1314 """List of binary nodes that are parents for this manifest revision."""
38530
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
1315
52475
cdd4bc69bfc1 interfaces: convert `imanifestrevisionstored` to a Protocol class
Matt Harbison <matt_harbison@yahoo.com>
parents: 52474
diff changeset
1316 @abc.abstractmethod
52474
048c11993d6a typing: (mostly) align the signatures of `imanifestrevisionstored` overrides
Matt Harbison <matt_harbison@yahoo.com>
parents: 52473
diff changeset
1317 def readdelta(self, shallow: bool = False):
38530
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
1318 """Obtain the manifest data structure representing changes from parent.
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
1319
51771
ca4208713875 manifest: introduce a `read_any_fast_delta` method
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51754
diff changeset
1320 This manifest is compared to its 1st parent. A new manifest
ca4208713875 manifest: introduce a `read_any_fast_delta` method
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51754
diff changeset
1321 representing those differences is constructed.
ca4208713875 manifest: introduce a `read_any_fast_delta` method
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51754
diff changeset
1322
ca4208713875 manifest: introduce a `read_any_fast_delta` method
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51754
diff changeset
1323 If `shallow` is True, this will read the delta for this directory,
ca4208713875 manifest: introduce a `read_any_fast_delta` method
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51754
diff changeset
1324 without recursively reading subdirectory manifests. Instead, any
ca4208713875 manifest: introduce a `read_any_fast_delta` method
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51754
diff changeset
1325 subdirectory entry will be reported as it appears in the manifest, i.e.
ca4208713875 manifest: introduce a `read_any_fast_delta` method
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51754
diff changeset
1326 the subdirectory will be reported among files and distinguished only by
ca4208713875 manifest: introduce a `read_any_fast_delta` method
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51754
diff changeset
1327 its 't' flag. This only apply if the underlying manifest support it.
ca4208713875 manifest: introduce a `read_any_fast_delta` method
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51754
diff changeset
1328
ca4208713875 manifest: introduce a `read_any_fast_delta` method
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51754
diff changeset
1329 The returned object conforms to the ``imanifestdict`` interface.
ca4208713875 manifest: introduce a `read_any_fast_delta` method
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51754
diff changeset
1330 """
ca4208713875 manifest: introduce a `read_any_fast_delta` method
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51754
diff changeset
1331
52475
cdd4bc69bfc1 interfaces: convert `imanifestrevisionstored` to a Protocol class
Matt Harbison <matt_harbison@yahoo.com>
parents: 52474
diff changeset
1332 @abc.abstractmethod
52474
048c11993d6a typing: (mostly) align the signatures of `imanifestrevisionstored` overrides
Matt Harbison <matt_harbison@yahoo.com>
parents: 52473
diff changeset
1333 def read_any_fast_delta(
048c11993d6a typing: (mostly) align the signatures of `imanifestrevisionstored` overrides
Matt Harbison <matt_harbison@yahoo.com>
parents: 52473
diff changeset
1334 self,
048c11993d6a typing: (mostly) align the signatures of `imanifestrevisionstored` overrides
Matt Harbison <matt_harbison@yahoo.com>
parents: 52473
diff changeset
1335 valid_bases: Collection[int] | None = None,
048c11993d6a typing: (mostly) align the signatures of `imanifestrevisionstored` overrides
Matt Harbison <matt_harbison@yahoo.com>
parents: 52473
diff changeset
1336 *,
048c11993d6a typing: (mostly) align the signatures of `imanifestrevisionstored` overrides
Matt Harbison <matt_harbison@yahoo.com>
parents: 52473
diff changeset
1337 shallow: bool = False,
048c11993d6a typing: (mostly) align the signatures of `imanifestrevisionstored` overrides
Matt Harbison <matt_harbison@yahoo.com>
parents: 52473
diff changeset
1338 ):
51771
ca4208713875 manifest: introduce a `read_any_fast_delta` method
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51754
diff changeset
1339 """read some manifest information as fast if possible
ca4208713875 manifest: introduce a `read_any_fast_delta` method
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51754
diff changeset
1340
ca4208713875 manifest: introduce a `read_any_fast_delta` method
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51754
diff changeset
1341 This might return a "delta", a manifest object containing only file
ca4208713875 manifest: introduce a `read_any_fast_delta` method
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51754
diff changeset
1342 changed compared to another revisions. The `valid_bases` argument
ca4208713875 manifest: introduce a `read_any_fast_delta` method
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51754
diff changeset
1343 control the set of revision that might be used as a base.
ca4208713875 manifest: introduce a `read_any_fast_delta` method
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51754
diff changeset
1344
ca4208713875 manifest: introduce a `read_any_fast_delta` method
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51754
diff changeset
1345 If no delta can be retrieved quickly, a full read of the manifest will
ca4208713875 manifest: introduce a `read_any_fast_delta` method
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51754
diff changeset
1346 be performed instead.
ca4208713875 manifest: introduce a `read_any_fast_delta` method
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51754
diff changeset
1347
ca4208713875 manifest: introduce a `read_any_fast_delta` method
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51754
diff changeset
1348 The function return a tuple with two elements. The first one is the
ca4208713875 manifest: introduce a `read_any_fast_delta` method
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51754
diff changeset
1349 delta base used (or None if we did a full read), the second one is the
ca4208713875 manifest: introduce a `read_any_fast_delta` method
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51754
diff changeset
1350 manifest information.
ca4208713875 manifest: introduce a `read_any_fast_delta` method
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51754
diff changeset
1351
ca4208713875 manifest: introduce a `read_any_fast_delta` method
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51754
diff changeset
1352 If `shallow` is True, this will read the delta for this directory,
ca4208713875 manifest: introduce a `read_any_fast_delta` method
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51754
diff changeset
1353 without recursively reading subdirectory manifests. Instead, any
ca4208713875 manifest: introduce a `read_any_fast_delta` method
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51754
diff changeset
1354 subdirectory entry will be reported as it appears in the manifest, i.e.
ca4208713875 manifest: introduce a `read_any_fast_delta` method
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51754
diff changeset
1355 the subdirectory will be reported among files and distinguished only by
ca4208713875 manifest: introduce a `read_any_fast_delta` method
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51754
diff changeset
1356 its 't' flag. This only apply if the underlying manifest support it.
38530
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
1357
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
1358 The returned object conforms to the ``imanifestdict`` interface.
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
1359 """
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
1360
52475
cdd4bc69bfc1 interfaces: convert `imanifestrevisionstored` to a Protocol class
Matt Harbison <matt_harbison@yahoo.com>
parents: 52474
diff changeset
1361 @abc.abstractmethod
52474
048c11993d6a typing: (mostly) align the signatures of `imanifestrevisionstored` overrides
Matt Harbison <matt_harbison@yahoo.com>
parents: 52473
diff changeset
1362 def read_delta_parents(self, *, shallow: bool = False, exact: bool = True):
51777
a891347058e7 manifest: introduce a `read_delta_parents` method
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51772
diff changeset
1363 """return a diff from this revision against both parents.
a891347058e7 manifest: introduce a `read_delta_parents` method
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51772
diff changeset
1364
a891347058e7 manifest: introduce a `read_delta_parents` method
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51772
diff changeset
1365 If `exact` is False, this might return a superset of the diff, containing
a891347058e7 manifest: introduce a `read_delta_parents` method
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51772
diff changeset
1366 files that are actually present as is in one of the parents.
a891347058e7 manifest: introduce a `read_delta_parents` method
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51772
diff changeset
1367
a891347058e7 manifest: introduce a `read_delta_parents` method
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51772
diff changeset
1368 If `shallow` is True, this will read the delta for this directory,
a891347058e7 manifest: introduce a `read_delta_parents` method
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51772
diff changeset
1369 without recursively reading subdirectory manifests. Instead, any
a891347058e7 manifest: introduce a `read_delta_parents` method
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51772
diff changeset
1370 subdirectory entry will be reported as it appears in the manifest, i.e.
a891347058e7 manifest: introduce a `read_delta_parents` method
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51772
diff changeset
1371 the subdirectory will be reported among files and distinguished only by
a891347058e7 manifest: introduce a `read_delta_parents` method
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51772
diff changeset
1372 its 't' flag. This only apply if the underlying manifest support it.
a891347058e7 manifest: introduce a `read_delta_parents` method
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51772
diff changeset
1373
a891347058e7 manifest: introduce a `read_delta_parents` method
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51772
diff changeset
1374 The returned object conforms to the ``imanifestdict`` interface."""
a891347058e7 manifest: introduce a `read_delta_parents` method
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51772
diff changeset
1375
52475
cdd4bc69bfc1 interfaces: convert `imanifestrevisionstored` to a Protocol class
Matt Harbison <matt_harbison@yahoo.com>
parents: 52474
diff changeset
1376 @abc.abstractmethod
52474
048c11993d6a typing: (mostly) align the signatures of `imanifestrevisionstored` overrides
Matt Harbison <matt_harbison@yahoo.com>
parents: 52473
diff changeset
1377 def read_delta_new_entries(self, *, shallow: bool = False):
51781
bcb825bf0c5e manifest: add a read_delta_new_entries method
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51777
diff changeset
1378 """Return a manifest containing just the entries that might be new to
bcb825bf0c5e manifest: add a read_delta_new_entries method
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51777
diff changeset
1379 the repository.
bcb825bf0c5e manifest: add a read_delta_new_entries method
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51777
diff changeset
1380
bcb825bf0c5e manifest: add a read_delta_new_entries method
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51777
diff changeset
1381 This is often equivalent to a diff against both parents, but without
bcb825bf0c5e manifest: add a read_delta_new_entries method
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51777
diff changeset
1382 garantee. For performance reason, It might contains more files in some cases.
bcb825bf0c5e manifest: add a read_delta_new_entries method
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51777
diff changeset
1383
bcb825bf0c5e manifest: add a read_delta_new_entries method
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51777
diff changeset
1384 If `shallow` is True, this will read the delta for this directory,
bcb825bf0c5e manifest: add a read_delta_new_entries method
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51777
diff changeset
1385 without recursively reading subdirectory manifests. Instead, any
bcb825bf0c5e manifest: add a read_delta_new_entries method
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51777
diff changeset
1386 subdirectory entry will be reported as it appears in the manifest, i.e.
bcb825bf0c5e manifest: add a read_delta_new_entries method
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51777
diff changeset
1387 the subdirectory will be reported among files and distinguished only by
bcb825bf0c5e manifest: add a read_delta_new_entries method
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51777
diff changeset
1388 its 't' flag. This only apply if the underlying manifest support it.
bcb825bf0c5e manifest: add a read_delta_new_entries method
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51777
diff changeset
1389
bcb825bf0c5e manifest: add a read_delta_new_entries method
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51777
diff changeset
1390 The returned object conforms to the ``imanifestdict`` interface."""
bcb825bf0c5e manifest: add a read_delta_new_entries method
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51777
diff changeset
1391
52475
cdd4bc69bfc1 interfaces: convert `imanifestrevisionstored` to a Protocol class
Matt Harbison <matt_harbison@yahoo.com>
parents: 52474
diff changeset
1392 @abc.abstractmethod
52474
048c11993d6a typing: (mostly) align the signatures of `imanifestrevisionstored` overrides
Matt Harbison <matt_harbison@yahoo.com>
parents: 52473
diff changeset
1393 def readfast(self, shallow: bool = False):
38530
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
1394 """Calls either ``read()`` or ``readdelta()``.
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
1395
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
1396 The faster of the two options is called.
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
1397 """
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
1398
52475
cdd4bc69bfc1 interfaces: convert `imanifestrevisionstored` to a Protocol class
Matt Harbison <matt_harbison@yahoo.com>
parents: 52474
diff changeset
1399 @abc.abstractmethod
52474
048c11993d6a typing: (mostly) align the signatures of `imanifestrevisionstored` overrides
Matt Harbison <matt_harbison@yahoo.com>
parents: 52473
diff changeset
1400 def find(self, key: bytes) -> tuple[bytes, bytes]:
52476
0c60be5e021a interfaces: fix a doc comment in `repository.imanifestrevisionstored.find()`
Matt Harbison <matt_harbison@yahoo.com>
parents: 52475
diff changeset
1401 """Calls ``self.read().find(key)``.
38530
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
1402
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
1403 Returns a 2-tuple of ``(node, flags)`` or raises ``KeyError``.
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
1404 """
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
1405
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43032
diff changeset
1406
52480
01818a59f463 interfaces: convert `imanifestrevisionwritable` to a Protocol class
Matt Harbison <matt_harbison@yahoo.com>
parents: 52479
diff changeset
1407 class imanifestrevisionwritable(imanifestrevisionbase, Protocol):
38530
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
1408 """Interface representing a manifest revision that can be committed."""
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
1409
52480
01818a59f463 interfaces: convert `imanifestrevisionwritable` to a Protocol class
Matt Harbison <matt_harbison@yahoo.com>
parents: 52479
diff changeset
1410 @abc.abstractmethod
52446
c1674551c109 interfaces: add the missing `self` arg to the repository Protocol classes
Matt Harbison <matt_harbison@yahoo.com>
parents: 52445
diff changeset
1411 def write(
c1674551c109 interfaces: add the missing `self` arg to the repository Protocol classes
Matt Harbison <matt_harbison@yahoo.com>
parents: 52445
diff changeset
1412 self, transaction, linkrev, p1node, p2node, added, removed, match=None
c1674551c109 interfaces: add the missing `self` arg to the repository Protocol classes
Matt Harbison <matt_harbison@yahoo.com>
parents: 52445
diff changeset
1413 ):
38530
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
1414 """Add this revision to storage.
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
1415
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
1416 Takes a transaction object, the changeset revision number it will
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
1417 be associated with, its parent nodes, and lists of added and
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
1418 removed paths.
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
1419
39668
24870f1be088 narrow: when writing treemanifests, skip inspecting directories outside narrow
spectral <spectral@google.com>
parents: 39315
diff changeset
1420 If match is provided, storage can choose not to inspect or write out
24870f1be088 narrow: when writing treemanifests, skip inspecting directories outside narrow
spectral <spectral@google.com>
parents: 39315
diff changeset
1421 items that do not match. Storage is still required to be able to provide
24870f1be088 narrow: when writing treemanifests, skip inspecting directories outside narrow
spectral <spectral@google.com>
parents: 39315
diff changeset
1422 the full manifest in the future for any directories written (these
24870f1be088 narrow: when writing treemanifests, skip inspecting directories outside narrow
spectral <spectral@google.com>
parents: 39315
diff changeset
1423 manifests should not be "narrowed on disk").
24870f1be088 narrow: when writing treemanifests, skip inspecting directories outside narrow
spectral <spectral@google.com>
parents: 39315
diff changeset
1424
38530
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
1425 Returns the binary node of the created revision.
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
1426 """
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
1427
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43032
diff changeset
1428
52445
26dd402c3497 interfaces: convert the repository zope interfaces to Protocol classes
Matt Harbison <matt_harbison@yahoo.com>
parents: 52432
diff changeset
1429 class imanifeststorage(Protocol):
39314
7f5e6d3e9032 manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39244
diff changeset
1430 """Storage interface for manifest data."""
7f5e6d3e9032 manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39244
diff changeset
1431
52478
d01af74e67b4 interfaces: convert `repository.imanifeststorage` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52476
diff changeset
1432 nodeconstants: NodeConstants
d01af74e67b4 interfaces: convert `repository.imanifeststorage` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52476
diff changeset
1433 """nodeconstants used by the current repository."""
d01af74e67b4 interfaces: convert `repository.imanifeststorage` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52476
diff changeset
1434
d01af74e67b4 interfaces: convert `repository.imanifeststorage` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52476
diff changeset
1435 tree: bytes
d01af74e67b4 interfaces: convert `repository.imanifeststorage` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52476
diff changeset
1436 """The path to the directory this manifest tracks.
d01af74e67b4 interfaces: convert `repository.imanifeststorage` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52476
diff changeset
1437
d01af74e67b4 interfaces: convert `repository.imanifeststorage` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52476
diff changeset
1438 The empty bytestring represents the root manifest.
d01af74e67b4 interfaces: convert `repository.imanifeststorage` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52476
diff changeset
1439 """
d01af74e67b4 interfaces: convert `repository.imanifeststorage` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52476
diff changeset
1440
d01af74e67b4 interfaces: convert `repository.imanifeststorage` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52476
diff changeset
1441 index: ifilerevisionssequence
d01af74e67b4 interfaces: convert `repository.imanifeststorage` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52476
diff changeset
1442 """An ``ifilerevisionssequence`` instance."""
d01af74e67b4 interfaces: convert `repository.imanifeststorage` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52476
diff changeset
1443
d01af74e67b4 interfaces: convert `repository.imanifeststorage` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52476
diff changeset
1444 opener: Vfs
d01af74e67b4 interfaces: convert `repository.imanifeststorage` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52476
diff changeset
1445 """VFS opener to use to access underlying files used for storage.
d01af74e67b4 interfaces: convert `repository.imanifeststorage` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52476
diff changeset
1446
d01af74e67b4 interfaces: convert `repository.imanifeststorage` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52476
diff changeset
1447 TODO this is revlog specific and should not be exposed.
d01af74e67b4 interfaces: convert `repository.imanifeststorage` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52476
diff changeset
1448 """
d01af74e67b4 interfaces: convert `repository.imanifeststorage` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52476
diff changeset
1449
d01af74e67b4 interfaces: convert `repository.imanifeststorage` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52476
diff changeset
1450 # TODO: finish type hints
d01af74e67b4 interfaces: convert `repository.imanifeststorage` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52476
diff changeset
1451 fulltextcache: dict
d01af74e67b4 interfaces: convert `repository.imanifeststorage` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52476
diff changeset
1452 """Dict with cache of fulltexts.
d01af74e67b4 interfaces: convert `repository.imanifeststorage` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52476
diff changeset
1453
d01af74e67b4 interfaces: convert `repository.imanifeststorage` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52476
diff changeset
1454 TODO this doesn't feel appropriate for the storage interface.
d01af74e67b4 interfaces: convert `repository.imanifeststorage` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52476
diff changeset
1455 """
39314
7f5e6d3e9032 manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39244
diff changeset
1456
52479
99ca58c7cd0d interfaces: make `repository.imanifeststorage` methods abstract
Matt Harbison <matt_harbison@yahoo.com>
parents: 52478
diff changeset
1457 @abc.abstractmethod
52446
c1674551c109 interfaces: add the missing `self` arg to the repository Protocol classes
Matt Harbison <matt_harbison@yahoo.com>
parents: 52445
diff changeset
1458 def __len__(self):
39314
7f5e6d3e9032 manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39244
diff changeset
1459 """Obtain the number of revisions stored for this manifest."""
7f5e6d3e9032 manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39244
diff changeset
1460
52479
99ca58c7cd0d interfaces: make `repository.imanifeststorage` methods abstract
Matt Harbison <matt_harbison@yahoo.com>
parents: 52478
diff changeset
1461 @abc.abstractmethod
52446
c1674551c109 interfaces: add the missing `self` arg to the repository Protocol classes
Matt Harbison <matt_harbison@yahoo.com>
parents: 52445
diff changeset
1462 def __iter__(self):
39314
7f5e6d3e9032 manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39244
diff changeset
1463 """Iterate over revision numbers for this manifest."""
7f5e6d3e9032 manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39244
diff changeset
1464
52479
99ca58c7cd0d interfaces: make `repository.imanifeststorage` methods abstract
Matt Harbison <matt_harbison@yahoo.com>
parents: 52478
diff changeset
1465 @abc.abstractmethod
52446
c1674551c109 interfaces: add the missing `self` arg to the repository Protocol classes
Matt Harbison <matt_harbison@yahoo.com>
parents: 52445
diff changeset
1466 def rev(self, node):
39314
7f5e6d3e9032 manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39244
diff changeset
1467 """Obtain the revision number given a binary node.
7f5e6d3e9032 manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39244
diff changeset
1468
7f5e6d3e9032 manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39244
diff changeset
1469 Raises ``error.LookupError`` if the node is not known.
7f5e6d3e9032 manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39244
diff changeset
1470 """
7f5e6d3e9032 manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39244
diff changeset
1471
52479
99ca58c7cd0d interfaces: make `repository.imanifeststorage` methods abstract
Matt Harbison <matt_harbison@yahoo.com>
parents: 52478
diff changeset
1472 @abc.abstractmethod
52446
c1674551c109 interfaces: add the missing `self` arg to the repository Protocol classes
Matt Harbison <matt_harbison@yahoo.com>
parents: 52445
diff changeset
1473 def node(self, rev):
39314
7f5e6d3e9032 manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39244
diff changeset
1474 """Obtain the node value given a revision number.
7f5e6d3e9032 manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39244
diff changeset
1475
7f5e6d3e9032 manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39244
diff changeset
1476 Raises ``error.LookupError`` if the revision is not known.
7f5e6d3e9032 manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39244
diff changeset
1477 """
7f5e6d3e9032 manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39244
diff changeset
1478
52479
99ca58c7cd0d interfaces: make `repository.imanifeststorage` methods abstract
Matt Harbison <matt_harbison@yahoo.com>
parents: 52478
diff changeset
1479 @abc.abstractmethod
52446
c1674551c109 interfaces: add the missing `self` arg to the repository Protocol classes
Matt Harbison <matt_harbison@yahoo.com>
parents: 52445
diff changeset
1480 def lookup(self, value):
39314
7f5e6d3e9032 manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39244
diff changeset
1481 """Attempt to resolve a value to a node.
7f5e6d3e9032 manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39244
diff changeset
1482
7f5e6d3e9032 manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39244
diff changeset
1483 Value can be a binary node, hex node, revision number, or a bytes
7f5e6d3e9032 manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39244
diff changeset
1484 that can be converted to an integer.
7f5e6d3e9032 manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39244
diff changeset
1485
7f5e6d3e9032 manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39244
diff changeset
1486 Raises ``error.LookupError`` if a ndoe could not be resolved.
7f5e6d3e9032 manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39244
diff changeset
1487 """
7f5e6d3e9032 manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39244
diff changeset
1488
52479
99ca58c7cd0d interfaces: make `repository.imanifeststorage` methods abstract
Matt Harbison <matt_harbison@yahoo.com>
parents: 52478
diff changeset
1489 @abc.abstractmethod
52446
c1674551c109 interfaces: add the missing `self` arg to the repository Protocol classes
Matt Harbison <matt_harbison@yahoo.com>
parents: 52445
diff changeset
1490 def parents(self, node):
39314
7f5e6d3e9032 manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39244
diff changeset
1491 """Returns a 2-tuple of parent nodes for a node.
7f5e6d3e9032 manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39244
diff changeset
1492
7f5e6d3e9032 manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39244
diff changeset
1493 Values will be ``nullid`` if the parent is empty.
7f5e6d3e9032 manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39244
diff changeset
1494 """
7f5e6d3e9032 manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39244
diff changeset
1495
52479
99ca58c7cd0d interfaces: make `repository.imanifeststorage` methods abstract
Matt Harbison <matt_harbison@yahoo.com>
parents: 52478
diff changeset
1496 @abc.abstractmethod
52446
c1674551c109 interfaces: add the missing `self` arg to the repository Protocol classes
Matt Harbison <matt_harbison@yahoo.com>
parents: 52445
diff changeset
1497 def parentrevs(self, rev):
39314
7f5e6d3e9032 manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39244
diff changeset
1498 """Like parents() but operates on revision numbers."""
7f5e6d3e9032 manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39244
diff changeset
1499
52479
99ca58c7cd0d interfaces: make `repository.imanifeststorage` methods abstract
Matt Harbison <matt_harbison@yahoo.com>
parents: 52478
diff changeset
1500 @abc.abstractmethod
52446
c1674551c109 interfaces: add the missing `self` arg to the repository Protocol classes
Matt Harbison <matt_harbison@yahoo.com>
parents: 52445
diff changeset
1501 def linkrev(self, rev):
39314
7f5e6d3e9032 manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39244
diff changeset
1502 """Obtain the changeset revision number a revision is linked to."""
7f5e6d3e9032 manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39244
diff changeset
1503
52479
99ca58c7cd0d interfaces: make `repository.imanifeststorage` methods abstract
Matt Harbison <matt_harbison@yahoo.com>
parents: 52478
diff changeset
1504 @abc.abstractmethod
52446
c1674551c109 interfaces: add the missing `self` arg to the repository Protocol classes
Matt Harbison <matt_harbison@yahoo.com>
parents: 52445
diff changeset
1505 def revision(self, node):
39314
7f5e6d3e9032 manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39244
diff changeset
1506 """Obtain fulltext data for a node."""
7f5e6d3e9032 manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39244
diff changeset
1507
52479
99ca58c7cd0d interfaces: make `repository.imanifeststorage` methods abstract
Matt Harbison <matt_harbison@yahoo.com>
parents: 52478
diff changeset
1508 @abc.abstractmethod
52446
c1674551c109 interfaces: add the missing `self` arg to the repository Protocol classes
Matt Harbison <matt_harbison@yahoo.com>
parents: 52445
diff changeset
1509 def rawdata(self, node):
42723
2128c76c8970 rawdata: forward `rawdata` call on `manifestlog`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42620
diff changeset
1510 """Obtain raw data for a node."""
2128c76c8970 rawdata: forward `rawdata` call on `manifestlog`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42620
diff changeset
1511
52479
99ca58c7cd0d interfaces: make `repository.imanifeststorage` methods abstract
Matt Harbison <matt_harbison@yahoo.com>
parents: 52478
diff changeset
1512 @abc.abstractmethod
52446
c1674551c109 interfaces: add the missing `self` arg to the repository Protocol classes
Matt Harbison <matt_harbison@yahoo.com>
parents: 52445
diff changeset
1513 def revdiff(self, rev1, rev2):
39314
7f5e6d3e9032 manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39244
diff changeset
1514 """Obtain a delta between two revision numbers.
7f5e6d3e9032 manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39244
diff changeset
1515
7f5e6d3e9032 manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39244
diff changeset
1516 The returned data is the result of ``bdiff.bdiff()`` on the raw
7f5e6d3e9032 manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39244
diff changeset
1517 revision data.
7f5e6d3e9032 manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39244
diff changeset
1518 """
7f5e6d3e9032 manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39244
diff changeset
1519
52479
99ca58c7cd0d interfaces: make `repository.imanifeststorage` methods abstract
Matt Harbison <matt_harbison@yahoo.com>
parents: 52478
diff changeset
1520 @abc.abstractmethod
52446
c1674551c109 interfaces: add the missing `self` arg to the repository Protocol classes
Matt Harbison <matt_harbison@yahoo.com>
parents: 52445
diff changeset
1521 def cmp(self, node, fulltext):
39314
7f5e6d3e9032 manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39244
diff changeset
1522 """Compare fulltext to another revision.
7f5e6d3e9032 manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39244
diff changeset
1523
7f5e6d3e9032 manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39244
diff changeset
1524 Returns True if the fulltext is different from what is stored.
7f5e6d3e9032 manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39244
diff changeset
1525 """
7f5e6d3e9032 manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39244
diff changeset
1526
52479
99ca58c7cd0d interfaces: make `repository.imanifeststorage` methods abstract
Matt Harbison <matt_harbison@yahoo.com>
parents: 52478
diff changeset
1527 @abc.abstractmethod
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43032
diff changeset
1528 def emitrevisions(
52446
c1674551c109 interfaces: add the missing `self` arg to the repository Protocol classes
Matt Harbison <matt_harbison@yahoo.com>
parents: 52445
diff changeset
1529 self,
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43032
diff changeset
1530 nodes,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43032
diff changeset
1531 nodesorder=None,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43032
diff changeset
1532 revisiondata=False,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43032
diff changeset
1533 assumehaveparentrevisions=False,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43032
diff changeset
1534 ):
39862
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39860
diff changeset
1535 """Produce ``irevisiondelta`` describing revisions.
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39860
diff changeset
1536
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39860
diff changeset
1537 See the documentation for ``ifiledata`` for more.
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39860
diff changeset
1538 """
5a9ab91e0a45 revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39860
diff changeset
1539
52479
99ca58c7cd0d interfaces: make `repository.imanifeststorage` methods abstract
Matt Harbison <matt_harbison@yahoo.com>
parents: 52478
diff changeset
1540 @abc.abstractmethod
45788
a5206e71c536 revlog: extend addgroup() with callback for duplicates
Joerg Sonnenberger <joerg@bec.de>
parents: 45671
diff changeset
1541 def addgroup(
52446
c1674551c109 interfaces: add the missing `self` arg to the repository Protocol classes
Matt Harbison <matt_harbison@yahoo.com>
parents: 52445
diff changeset
1542 self,
45788
a5206e71c536 revlog: extend addgroup() with callback for duplicates
Joerg Sonnenberger <joerg@bec.de>
parents: 45671
diff changeset
1543 deltas,
a5206e71c536 revlog: extend addgroup() with callback for duplicates
Joerg Sonnenberger <joerg@bec.de>
parents: 45671
diff changeset
1544 linkmapper,
a5206e71c536 revlog: extend addgroup() with callback for duplicates
Joerg Sonnenberger <joerg@bec.de>
parents: 45671
diff changeset
1545 transaction,
a5206e71c536 revlog: extend addgroup() with callback for duplicates
Joerg Sonnenberger <joerg@bec.de>
parents: 45671
diff changeset
1546 addrevisioncb=None,
a5206e71c536 revlog: extend addgroup() with callback for duplicates
Joerg Sonnenberger <joerg@bec.de>
parents: 45671
diff changeset
1547 duplicaterevisioncb=None,
a5206e71c536 revlog: extend addgroup() with callback for duplicates
Joerg Sonnenberger <joerg@bec.de>
parents: 45671
diff changeset
1548 ):
39314
7f5e6d3e9032 manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39244
diff changeset
1549 """Process a series of deltas for storage.
7f5e6d3e9032 manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39244
diff changeset
1550
7f5e6d3e9032 manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39244
diff changeset
1551 See the documentation in ``ifilemutation`` for more.
7f5e6d3e9032 manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39244
diff changeset
1552 """
7f5e6d3e9032 manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39244
diff changeset
1553
52479
99ca58c7cd0d interfaces: make `repository.imanifeststorage` methods abstract
Matt Harbison <matt_harbison@yahoo.com>
parents: 52478
diff changeset
1554 @abc.abstractmethod
52446
c1674551c109 interfaces: add the missing `self` arg to the repository Protocol classes
Matt Harbison <matt_harbison@yahoo.com>
parents: 52445
diff changeset
1555 def rawsize(self, rev):
39858
9534fe1e5d28 manifest: add rawsize() proxy (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39851
diff changeset
1556 """Obtain the size of tracked data.
9534fe1e5d28 manifest: add rawsize() proxy (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39851
diff changeset
1557
42779
83d090ebec0c rawdata: update callers in repository
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42727
diff changeset
1558 Is equivalent to ``len(m.rawdata(node))``.
39858
9534fe1e5d28 manifest: add rawsize() proxy (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39851
diff changeset
1559
9534fe1e5d28 manifest: add rawsize() proxy (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39851
diff changeset
1560 TODO this method is only used by upgrade code and may be removed.
9534fe1e5d28 manifest: add rawsize() proxy (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39851
diff changeset
1561 """
9534fe1e5d28 manifest: add rawsize() proxy (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39851
diff changeset
1562
52479
99ca58c7cd0d interfaces: make `repository.imanifeststorage` methods abstract
Matt Harbison <matt_harbison@yahoo.com>
parents: 52478
diff changeset
1563 @abc.abstractmethod
52446
c1674551c109 interfaces: add the missing `self` arg to the repository Protocol classes
Matt Harbison <matt_harbison@yahoo.com>
parents: 52445
diff changeset
1564 def getstrippoint(self, minlink):
39314
7f5e6d3e9032 manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39244
diff changeset
1565 """Find minimum revision that must be stripped to strip a linkrev.
7f5e6d3e9032 manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39244
diff changeset
1566
7f5e6d3e9032 manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39244
diff changeset
1567 See the documentation in ``ifilemutation`` for more.
7f5e6d3e9032 manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39244
diff changeset
1568 """
7f5e6d3e9032 manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39244
diff changeset
1569
52479
99ca58c7cd0d interfaces: make `repository.imanifeststorage` methods abstract
Matt Harbison <matt_harbison@yahoo.com>
parents: 52478
diff changeset
1570 @abc.abstractmethod
52446
c1674551c109 interfaces: add the missing `self` arg to the repository Protocol classes
Matt Harbison <matt_harbison@yahoo.com>
parents: 52445
diff changeset
1571 def strip(self, minlink, transaction):
39314
7f5e6d3e9032 manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39244
diff changeset
1572 """Remove storage of items starting at a linkrev.
7f5e6d3e9032 manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39244
diff changeset
1573
7f5e6d3e9032 manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39244
diff changeset
1574 See the documentation in ``ifilemutation`` for more.
7f5e6d3e9032 manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39244
diff changeset
1575 """
7f5e6d3e9032 manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39244
diff changeset
1576
52479
99ca58c7cd0d interfaces: make `repository.imanifeststorage` methods abstract
Matt Harbison <matt_harbison@yahoo.com>
parents: 52478
diff changeset
1577 @abc.abstractmethod
52446
c1674551c109 interfaces: add the missing `self` arg to the repository Protocol classes
Matt Harbison <matt_harbison@yahoo.com>
parents: 52445
diff changeset
1578 def checksize(self):
39314
7f5e6d3e9032 manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39244
diff changeset
1579 """Obtain the expected sizes of backing files.
7f5e6d3e9032 manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39244
diff changeset
1580
7f5e6d3e9032 manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39244
diff changeset
1581 TODO this is used by verify and it should not be part of the interface.
7f5e6d3e9032 manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39244
diff changeset
1582 """
7f5e6d3e9032 manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39244
diff changeset
1583
52479
99ca58c7cd0d interfaces: make `repository.imanifeststorage` methods abstract
Matt Harbison <matt_harbison@yahoo.com>
parents: 52478
diff changeset
1584 @abc.abstractmethod
52446
c1674551c109 interfaces: add the missing `self` arg to the repository Protocol classes
Matt Harbison <matt_harbison@yahoo.com>
parents: 52445
diff changeset
1585 def files(self):
39314
7f5e6d3e9032 manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39244
diff changeset
1586 """Obtain paths that are backing storage for this manifest.
7f5e6d3e9032 manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39244
diff changeset
1587
7f5e6d3e9032 manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39244
diff changeset
1588 TODO this is used by verify and there should probably be a better API
7f5e6d3e9032 manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39244
diff changeset
1589 for this functionality.
7f5e6d3e9032 manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39244
diff changeset
1590 """
7f5e6d3e9032 manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39244
diff changeset
1591
52479
99ca58c7cd0d interfaces: make `repository.imanifeststorage` methods abstract
Matt Harbison <matt_harbison@yahoo.com>
parents: 52478
diff changeset
1592 @abc.abstractmethod
52446
c1674551c109 interfaces: add the missing `self` arg to the repository Protocol classes
Matt Harbison <matt_harbison@yahoo.com>
parents: 52445
diff changeset
1593 def deltaparent(self, rev):
39314
7f5e6d3e9032 manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39244
diff changeset
1594 """Obtain the revision that a revision is delta'd against.
7f5e6d3e9032 manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39244
diff changeset
1595
7f5e6d3e9032 manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39244
diff changeset
1596 TODO delta encoding is an implementation detail of storage and should
7f5e6d3e9032 manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39244
diff changeset
1597 not be exposed to the storage interface.
7f5e6d3e9032 manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39244
diff changeset
1598 """
7f5e6d3e9032 manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39244
diff changeset
1599
52479
99ca58c7cd0d interfaces: make `repository.imanifeststorage` methods abstract
Matt Harbison <matt_harbison@yahoo.com>
parents: 52478
diff changeset
1600 @abc.abstractmethod
52446
c1674551c109 interfaces: add the missing `self` arg to the repository Protocol classes
Matt Harbison <matt_harbison@yahoo.com>
parents: 52445
diff changeset
1601 def clone(self, tr, dest, **kwargs):
39314
7f5e6d3e9032 manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39244
diff changeset
1602 """Clone this instance to another."""
7f5e6d3e9032 manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39244
diff changeset
1603
52479
99ca58c7cd0d interfaces: make `repository.imanifeststorage` methods abstract
Matt Harbison <matt_harbison@yahoo.com>
parents: 52478
diff changeset
1604 @abc.abstractmethod
52446
c1674551c109 interfaces: add the missing `self` arg to the repository Protocol classes
Matt Harbison <matt_harbison@yahoo.com>
parents: 52445
diff changeset
1605 def clearcaches(self, clear_persisted_data=False):
39314
7f5e6d3e9032 manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39244
diff changeset
1606 """Clear any caches associated with this instance."""
7f5e6d3e9032 manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39244
diff changeset
1607
52479
99ca58c7cd0d interfaces: make `repository.imanifeststorage` methods abstract
Matt Harbison <matt_harbison@yahoo.com>
parents: 52478
diff changeset
1608 @abc.abstractmethod
52446
c1674551c109 interfaces: add the missing `self` arg to the repository Protocol classes
Matt Harbison <matt_harbison@yahoo.com>
parents: 52445
diff changeset
1609 def dirlog(self, d):
39314
7f5e6d3e9032 manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39244
diff changeset
1610 """Obtain a manifest storage instance for a tree."""
7f5e6d3e9032 manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39244
diff changeset
1611
52479
99ca58c7cd0d interfaces: make `repository.imanifeststorage` methods abstract
Matt Harbison <matt_harbison@yahoo.com>
parents: 52478
diff changeset
1612 @abc.abstractmethod
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43032
diff changeset
1613 def add(
52446
c1674551c109 interfaces: add the missing `self` arg to the repository Protocol classes
Matt Harbison <matt_harbison@yahoo.com>
parents: 52445
diff changeset
1614 self,
c1674551c109 interfaces: add the missing `self` arg to the repository Protocol classes
Matt Harbison <matt_harbison@yahoo.com>
parents: 52445
diff changeset
1615 m,
c1674551c109 interfaces: add the missing `self` arg to the repository Protocol classes
Matt Harbison <matt_harbison@yahoo.com>
parents: 52445
diff changeset
1616 transaction,
c1674551c109 interfaces: add the missing `self` arg to the repository Protocol classes
Matt Harbison <matt_harbison@yahoo.com>
parents: 52445
diff changeset
1617 link,
c1674551c109 interfaces: add the missing `self` arg to the repository Protocol classes
Matt Harbison <matt_harbison@yahoo.com>
parents: 52445
diff changeset
1618 p1,
c1674551c109 interfaces: add the missing `self` arg to the repository Protocol classes
Matt Harbison <matt_harbison@yahoo.com>
parents: 52445
diff changeset
1619 p2,
c1674551c109 interfaces: add the missing `self` arg to the repository Protocol classes
Matt Harbison <matt_harbison@yahoo.com>
parents: 52445
diff changeset
1620 added,
c1674551c109 interfaces: add the missing `self` arg to the repository Protocol classes
Matt Harbison <matt_harbison@yahoo.com>
parents: 52445
diff changeset
1621 removed,
c1674551c109 interfaces: add the missing `self` arg to the repository Protocol classes
Matt Harbison <matt_harbison@yahoo.com>
parents: 52445
diff changeset
1622 readtree=None,
c1674551c109 interfaces: add the missing `self` arg to the repository Protocol classes
Matt Harbison <matt_harbison@yahoo.com>
parents: 52445
diff changeset
1623 match=None,
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43032
diff changeset
1624 ):
39314
7f5e6d3e9032 manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39244
diff changeset
1625 """Add a revision to storage.
7f5e6d3e9032 manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39244
diff changeset
1626
7f5e6d3e9032 manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39244
diff changeset
1627 ``m`` is an object conforming to ``imanifestdict``.
7f5e6d3e9032 manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39244
diff changeset
1628
7f5e6d3e9032 manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39244
diff changeset
1629 ``link`` is the linkrev revision number.
7f5e6d3e9032 manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39244
diff changeset
1630
7f5e6d3e9032 manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39244
diff changeset
1631 ``p1`` and ``p2`` are the parent revision numbers.
7f5e6d3e9032 manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39244
diff changeset
1632
7f5e6d3e9032 manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39244
diff changeset
1633 ``added`` and ``removed`` are iterables of added and removed paths,
7f5e6d3e9032 manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39244
diff changeset
1634 respectively.
39668
24870f1be088 narrow: when writing treemanifests, skip inspecting directories outside narrow
spectral <spectral@google.com>
parents: 39315
diff changeset
1635
24870f1be088 narrow: when writing treemanifests, skip inspecting directories outside narrow
spectral <spectral@google.com>
parents: 39315
diff changeset
1636 ``readtree`` is a function that can be used to read the child tree(s)
24870f1be088 narrow: when writing treemanifests, skip inspecting directories outside narrow
spectral <spectral@google.com>
parents: 39315
diff changeset
1637 when recursively writing the full tree structure when using
24870f1be088 narrow: when writing treemanifests, skip inspecting directories outside narrow
spectral <spectral@google.com>
parents: 39315
diff changeset
1638 treemanifets.
24870f1be088 narrow: when writing treemanifests, skip inspecting directories outside narrow
spectral <spectral@google.com>
parents: 39315
diff changeset
1639
24870f1be088 narrow: when writing treemanifests, skip inspecting directories outside narrow
spectral <spectral@google.com>
parents: 39315
diff changeset
1640 ``match`` is a matcher that can be used to hint to storage that not all
24870f1be088 narrow: when writing treemanifests, skip inspecting directories outside narrow
spectral <spectral@google.com>
parents: 39315
diff changeset
1641 paths must be inspected; this is an optimization and can be safely
24870f1be088 narrow: when writing treemanifests, skip inspecting directories outside narrow
spectral <spectral@google.com>
parents: 39315
diff changeset
1642 ignored. Note that the storage must still be able to reproduce a full
24870f1be088 narrow: when writing treemanifests, skip inspecting directories outside narrow
spectral <spectral@google.com>
parents: 39315
diff changeset
1643 manifest including files that did not match.
39314
7f5e6d3e9032 manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39244
diff changeset
1644 """
7f5e6d3e9032 manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39244
diff changeset
1645
52479
99ca58c7cd0d interfaces: make `repository.imanifeststorage` methods abstract
Matt Harbison <matt_harbison@yahoo.com>
parents: 52478
diff changeset
1646 @abc.abstractmethod
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43032
diff changeset
1647 def storageinfo(
52446
c1674551c109 interfaces: add the missing `self` arg to the repository Protocol classes
Matt Harbison <matt_harbison@yahoo.com>
parents: 52445
diff changeset
1648 self,
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43032
diff changeset
1649 exclusivefiles=False,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43032
diff changeset
1650 sharedfiles=False,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43032
diff changeset
1651 revisionscount=False,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43032
diff changeset
1652 trackedsize=False,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43032
diff changeset
1653 storedsize=False,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43032
diff changeset
1654 ):
39869
14e500b58263 revlog: add method for obtaining storage info (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39867
diff changeset
1655 """Obtain information about storage for this manifest's data.
14e500b58263 revlog: add method for obtaining storage info (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39867
diff changeset
1656
14e500b58263 revlog: add method for obtaining storage info (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39867
diff changeset
1657 See ``ifilestorage.storageinfo()`` for a description of this method.
14e500b58263 revlog: add method for obtaining storage info (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39867
diff changeset
1658 This one behaves the same way, except for manifest data.
14e500b58263 revlog: add method for obtaining storage info (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39867
diff changeset
1659 """
14e500b58263 revlog: add method for obtaining storage info (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39867
diff changeset
1660
52479
99ca58c7cd0d interfaces: make `repository.imanifeststorage` methods abstract
Matt Harbison <matt_harbison@yahoo.com>
parents: 52478
diff changeset
1661 @abc.abstractmethod
52446
c1674551c109 interfaces: add the missing `self` arg to the repository Protocol classes
Matt Harbison <matt_harbison@yahoo.com>
parents: 52445
diff changeset
1662 def get_revlog(self):
50634
32837c7e2e4b revlog: add a `get_revlog` method
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 50437
diff changeset
1663 """return an actual revlog instance if any
32837c7e2e4b revlog: add a `get_revlog` method
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 50437
diff changeset
1664
32837c7e2e4b revlog: add a `get_revlog` method
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 50437
diff changeset
1665 This exist because a lot of code leverage the fact the underlying
32837c7e2e4b revlog: add a `get_revlog` method
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 50437
diff changeset
1666 storage is a revlog for optimization, so giving simple way to access
32837c7e2e4b revlog: add a `get_revlog` method
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 50437
diff changeset
1667 the revlog instance helps such code.
32837c7e2e4b revlog: add a `get_revlog` method
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 50437
diff changeset
1668 """
32837c7e2e4b revlog: add a `get_revlog` method
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 50437
diff changeset
1669
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43032
diff changeset
1670
52445
26dd402c3497 interfaces: convert the repository zope interfaces to Protocol classes
Matt Harbison <matt_harbison@yahoo.com>
parents: 52432
diff changeset
1671 class imanifestlog(Protocol):
39240
2af6b2d8d1d8 repository: clarify role of imanifestlog
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39235
diff changeset
1672 """Interface representing a collection of manifest snapshots.
2af6b2d8d1d8 repository: clarify role of imanifestlog
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39235
diff changeset
1673
2af6b2d8d1d8 repository: clarify role of imanifestlog
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39235
diff changeset
1674 Represents the root manifest in a repository.
2af6b2d8d1d8 repository: clarify role of imanifestlog
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39235
diff changeset
1675
2af6b2d8d1d8 repository: clarify role of imanifestlog
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39235
diff changeset
1676 Also serves as a means to access nested tree manifests and to cache
2af6b2d8d1d8 repository: clarify role of imanifestlog
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39235
diff changeset
1677 tree manifests.
2af6b2d8d1d8 repository: clarify role of imanifestlog
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39235
diff changeset
1678 """
38530
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
1679
52482
ed70604d6e07 interfaces: convert `repository.imanifestlog` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52480
diff changeset
1680 nodeconstants: NodeConstants
ed70604d6e07 interfaces: convert `repository.imanifestlog` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52480
diff changeset
1681 """nodeconstants used by the current repository."""
ed70604d6e07 interfaces: convert `repository.imanifestlog` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52480
diff changeset
1682
ed70604d6e07 interfaces: convert `repository.imanifestlog` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52480
diff changeset
1683 narrowed: bool
ed70604d6e07 interfaces: convert `repository.imanifestlog` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52480
diff changeset
1684 """True, is the manifest is narrowed by a matcher"""
51781
bcb825bf0c5e manifest: add a read_delta_new_entries method
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 51777
diff changeset
1685
52483
196f441ffc93 interfaces: make `repository.imanifestlog` methods abstract
Matt Harbison <matt_harbison@yahoo.com>
parents: 52482
diff changeset
1686 @abc.abstractmethod
52446
c1674551c109 interfaces: add the missing `self` arg to the repository Protocol classes
Matt Harbison <matt_harbison@yahoo.com>
parents: 52445
diff changeset
1687 def __getitem__(self, node):
38530
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
1688 """Obtain a manifest instance for a given binary node.
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
1689
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
1690 Equivalent to calling ``self.get('', node)``.
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
1691
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
1692 The returned object conforms to the ``imanifestrevisionstored``
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
1693 interface.
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
1694 """
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
1695
52483
196f441ffc93 interfaces: make `repository.imanifestlog` methods abstract
Matt Harbison <matt_harbison@yahoo.com>
parents: 52482
diff changeset
1696 @abc.abstractmethod
52446
c1674551c109 interfaces: add the missing `self` arg to the repository Protocol classes
Matt Harbison <matt_harbison@yahoo.com>
parents: 52445
diff changeset
1697 def get(self, tree, node, verify=True):
38530
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
1698 """Retrieve the manifest instance for a given directory and binary node.
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
1699
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
1700 ``node`` always refers to the node of the root manifest (which will be
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
1701 the only manifest if flat manifests are being used).
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
1702
39235
43387fd2aa1f manifest: rename dir to tree to avoid shadowing built-in
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39234
diff changeset
1703 If ``tree`` is the empty string, the root manifest is returned.
43387fd2aa1f manifest: rename dir to tree to avoid shadowing built-in
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39234
diff changeset
1704 Otherwise the manifest for the specified directory will be returned
43387fd2aa1f manifest: rename dir to tree to avoid shadowing built-in
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39234
diff changeset
1705 (requires tree manifests).
38530
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
1706
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
1707 If ``verify`` is True, ``LookupError`` is raised if the node is not
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
1708 known.
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
1709
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
1710 The returned object conforms to the ``imanifestrevisionstored``
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
1711 interface.
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
1712 """
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
1713
52483
196f441ffc93 interfaces: make `repository.imanifestlog` methods abstract
Matt Harbison <matt_harbison@yahoo.com>
parents: 52482
diff changeset
1714 @abc.abstractmethod
52446
c1674551c109 interfaces: add the missing `self` arg to the repository Protocol classes
Matt Harbison <matt_harbison@yahoo.com>
parents: 52445
diff changeset
1715 def getstorage(self, tree):
39244
73cf21b2e8a6 manifest: add getstorage() to manifestlog and use it globally
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39241
diff changeset
1716 """Retrieve an interface to storage for a particular tree.
73cf21b2e8a6 manifest: add getstorage() to manifestlog and use it globally
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39241
diff changeset
1717
73cf21b2e8a6 manifest: add getstorage() to manifestlog and use it globally
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39241
diff changeset
1718 If ``tree`` is the empty bytestring, storage for the root manifest will
73cf21b2e8a6 manifest: add getstorage() to manifestlog and use it globally
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39241
diff changeset
1719 be returned. Otherwise storage for a tree manifest is returned.
73cf21b2e8a6 manifest: add getstorage() to manifestlog and use it globally
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39241
diff changeset
1720
73cf21b2e8a6 manifest: add getstorage() to manifestlog and use it globally
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39241
diff changeset
1721 TODO formalize interface for returned object.
73cf21b2e8a6 manifest: add getstorage() to manifestlog and use it globally
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39241
diff changeset
1722 """
73cf21b2e8a6 manifest: add getstorage() to manifestlog and use it globally
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39241
diff changeset
1723
52483
196f441ffc93 interfaces: make `repository.imanifestlog` methods abstract
Matt Harbison <matt_harbison@yahoo.com>
parents: 52482
diff changeset
1724 @abc.abstractmethod
52446
c1674551c109 interfaces: add the missing `self` arg to the repository Protocol classes
Matt Harbison <matt_harbison@yahoo.com>
parents: 52445
diff changeset
1725 def clearcaches(self, clear_persisted_data: bool = False) -> None:
38530
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
1726 """Clear caches associated with this collection."""
c82ea938efbb repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38509
diff changeset
1727
52483
196f441ffc93 interfaces: make `repository.imanifestlog` methods abstract
Matt Harbison <matt_harbison@yahoo.com>
parents: 52482
diff changeset
1728 @abc.abstractmethod
52446
c1674551c109 interfaces: add the missing `self` arg to the repository Protocol classes
Matt Harbison <matt_harbison@yahoo.com>
parents: 52445
diff changeset
1729 def rev(self, node):
38555
f2f9bacf0587 manifest: define and implement rev() on manifestlog
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38530
diff changeset
1730 """Obtain the revision number for a binary node.
f2f9bacf0587 manifest: define and implement rev() on manifestlog
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38530
diff changeset
1731
f2f9bacf0587 manifest: define and implement rev() on manifestlog
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38530
diff changeset
1732 Raises ``error.LookupError`` if the node is not known.
f2f9bacf0587 manifest: define and implement rev() on manifestlog
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38530
diff changeset
1733 """
f2f9bacf0587 manifest: define and implement rev() on manifestlog
Gregory Szorc <gregory.szorc@gmail.com>
parents: 38530
diff changeset
1734
52483
196f441ffc93 interfaces: make `repository.imanifestlog` methods abstract
Matt Harbison <matt_harbison@yahoo.com>
parents: 52482
diff changeset
1735 @abc.abstractmethod
52446
c1674551c109 interfaces: add the missing `self` arg to the repository Protocol classes
Matt Harbison <matt_harbison@yahoo.com>
parents: 52445
diff changeset
1736 def update_caches(self, transaction):
44787
97ebdb192b00 nodemap: also warm manifest nodemap with other caches
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44663
diff changeset
1737 """update whatever cache are relevant for the used storage."""
97ebdb192b00 nodemap: also warm manifest nodemap with other caches
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 44663
diff changeset
1738
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43032
diff changeset
1739
52445
26dd402c3497 interfaces: convert the repository zope interfaces to Protocol classes
Matt Harbison <matt_harbison@yahoo.com>
parents: 52432
diff changeset
1740 class ilocalrepositoryfilestorage(Protocol):
39764
e4e881572382 localrepo: iteratively derive local repository type
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39700
diff changeset
1741 """Local repository sub-interface providing access to tracked file storage.
e4e881572382 localrepo: iteratively derive local repository type
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39700
diff changeset
1742
e4e881572382 localrepo: iteratively derive local repository type
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39700
diff changeset
1743 This interface defines how a repository accesses storage for a single
e4e881572382 localrepo: iteratively derive local repository type
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39700
diff changeset
1744 tracked file path.
e4e881572382 localrepo: iteratively derive local repository type
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39700
diff changeset
1745 """
e4e881572382 localrepo: iteratively derive local repository type
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39700
diff changeset
1746
52490
ef119f914fc1 localrepo: subclass the new `ilocalrepositoryfilestorage` Protocol class
Matt Harbison <matt_harbison@yahoo.com>
parents: 52488
diff changeset
1747 @abc.abstractmethod
52446
c1674551c109 interfaces: add the missing `self` arg to the repository Protocol classes
Matt Harbison <matt_harbison@yahoo.com>
parents: 52445
diff changeset
1748 def file(self, f):
39764
e4e881572382 localrepo: iteratively derive local repository type
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39700
diff changeset
1749 """Obtain a filelog for a tracked path.
e4e881572382 localrepo: iteratively derive local repository type
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39700
diff changeset
1750
e4e881572382 localrepo: iteratively derive local repository type
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39700
diff changeset
1751 The returned type conforms to the ``ifilestorage`` interface.
e4e881572382 localrepo: iteratively derive local repository type
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39700
diff changeset
1752 """
e4e881572382 localrepo: iteratively derive local repository type
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39700
diff changeset
1753
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43032
diff changeset
1754
52445
26dd402c3497 interfaces: convert the repository zope interfaces to Protocol classes
Matt Harbison <matt_harbison@yahoo.com>
parents: 52432
diff changeset
1755 class ilocalrepositorymain(Protocol):
39764
e4e881572382 localrepo: iteratively derive local repository type
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39700
diff changeset
1756 """Main interface for local repositories.
37181
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
1757
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
1758 This currently captures the reality of things - not how things should be.
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
1759 """
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
1760
52485
dfb60fb155da interfaces: convert `ilocalrepositorymain` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52483
diff changeset
1761 nodeconstants: NodeConstants
dfb60fb155da interfaces: convert `ilocalrepositorymain` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52483
diff changeset
1762 """Constant nodes matching the hash function used by the repository."""
dfb60fb155da interfaces: convert `ilocalrepositorymain` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52483
diff changeset
1763
dfb60fb155da interfaces: convert `ilocalrepositorymain` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52483
diff changeset
1764 nullid: bytes
dfb60fb155da interfaces: convert `ilocalrepositorymain` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52483
diff changeset
1765 """null revision for the hash function used by the repository."""
dfb60fb155da interfaces: convert `ilocalrepositorymain` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52483
diff changeset
1766
dfb60fb155da interfaces: convert `ilocalrepositorymain` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52483
diff changeset
1767 supported: set[bytes]
dfb60fb155da interfaces: convert `ilocalrepositorymain` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52483
diff changeset
1768 """Set of requirements that this repo is capable of opening."""
dfb60fb155da interfaces: convert `ilocalrepositorymain` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52483
diff changeset
1769
dfb60fb155da interfaces: convert `ilocalrepositorymain` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52483
diff changeset
1770 requirements: set[bytes]
dfb60fb155da interfaces: convert `ilocalrepositorymain` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52483
diff changeset
1771 """Set of requirements this repo uses."""
dfb60fb155da interfaces: convert `ilocalrepositorymain` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52483
diff changeset
1772
dfb60fb155da interfaces: convert `ilocalrepositorymain` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52483
diff changeset
1773 features: set[bytes]
dfb60fb155da interfaces: convert `ilocalrepositorymain` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52483
diff changeset
1774 """Set of "features" this repository supports.
dfb60fb155da interfaces: convert `ilocalrepositorymain` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52483
diff changeset
1775
dfb60fb155da interfaces: convert `ilocalrepositorymain` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52483
diff changeset
1776 A "feature" is a loosely-defined term. It can refer to a feature
dfb60fb155da interfaces: convert `ilocalrepositorymain` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52483
diff changeset
1777 in the classical sense or can describe an implementation detail
dfb60fb155da interfaces: convert `ilocalrepositorymain` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52483
diff changeset
1778 of the repository. For example, a ``readonly`` feature may denote
dfb60fb155da interfaces: convert `ilocalrepositorymain` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52483
diff changeset
1779 the repository as read-only. Or a ``revlogfilestore`` feature may
dfb60fb155da interfaces: convert `ilocalrepositorymain` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52483
diff changeset
1780 denote that the repository is using revlogs for file storage.
dfb60fb155da interfaces: convert `ilocalrepositorymain` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52483
diff changeset
1781
dfb60fb155da interfaces: convert `ilocalrepositorymain` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52483
diff changeset
1782 The intent of features is to provide a machine-queryable mechanism
dfb60fb155da interfaces: convert `ilocalrepositorymain` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52483
diff changeset
1783 for repo consumers to test for various repository characteristics.
dfb60fb155da interfaces: convert `ilocalrepositorymain` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52483
diff changeset
1784
dfb60fb155da interfaces: convert `ilocalrepositorymain` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52483
diff changeset
1785 Features are similar to ``requirements``. The main difference is that
dfb60fb155da interfaces: convert `ilocalrepositorymain` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52483
diff changeset
1786 requirements are stored on-disk and represent requirements to open the
dfb60fb155da interfaces: convert `ilocalrepositorymain` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52483
diff changeset
1787 repository. Features are more run-time capabilities of the repository
dfb60fb155da interfaces: convert `ilocalrepositorymain` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52483
diff changeset
1788 and more granular capabilities (which may be derived from requirements).
dfb60fb155da interfaces: convert `ilocalrepositorymain` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52483
diff changeset
1789 """
dfb60fb155da interfaces: convert `ilocalrepositorymain` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52483
diff changeset
1790
dfb60fb155da interfaces: convert `ilocalrepositorymain` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52483
diff changeset
1791 filtername: bytes
dfb60fb155da interfaces: convert `ilocalrepositorymain` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52483
diff changeset
1792 """Name of the repoview that is active on this repo."""
dfb60fb155da interfaces: convert `ilocalrepositorymain` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52483
diff changeset
1793
dfb60fb155da interfaces: convert `ilocalrepositorymain` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52483
diff changeset
1794 vfs_map: Mapping[bytes, Vfs]
dfb60fb155da interfaces: convert `ilocalrepositorymain` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52483
diff changeset
1795 """a bytes-key → vfs mapping used by transaction and others"""
dfb60fb155da interfaces: convert `ilocalrepositorymain` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52483
diff changeset
1796
dfb60fb155da interfaces: convert `ilocalrepositorymain` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52483
diff changeset
1797 wvfs: Vfs
dfb60fb155da interfaces: convert `ilocalrepositorymain` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52483
diff changeset
1798 """VFS used to access the working directory."""
dfb60fb155da interfaces: convert `ilocalrepositorymain` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52483
diff changeset
1799
dfb60fb155da interfaces: convert `ilocalrepositorymain` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52483
diff changeset
1800 vfs: Vfs
dfb60fb155da interfaces: convert `ilocalrepositorymain` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52483
diff changeset
1801 """VFS rooted at the .hg directory.
dfb60fb155da interfaces: convert `ilocalrepositorymain` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52483
diff changeset
1802
dfb60fb155da interfaces: convert `ilocalrepositorymain` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52483
diff changeset
1803 Used to access repository data not in the store.
dfb60fb155da interfaces: convert `ilocalrepositorymain` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52483
diff changeset
1804 """
dfb60fb155da interfaces: convert `ilocalrepositorymain` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52483
diff changeset
1805
dfb60fb155da interfaces: convert `ilocalrepositorymain` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52483
diff changeset
1806 svfs: Vfs
dfb60fb155da interfaces: convert `ilocalrepositorymain` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52483
diff changeset
1807 """VFS rooted at the store.
dfb60fb155da interfaces: convert `ilocalrepositorymain` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52483
diff changeset
1808
dfb60fb155da interfaces: convert `ilocalrepositorymain` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52483
diff changeset
1809 Used to access repository data in the store. Typically .hg/store.
dfb60fb155da interfaces: convert `ilocalrepositorymain` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52483
diff changeset
1810 But can point elsewhere if the store is shared.
dfb60fb155da interfaces: convert `ilocalrepositorymain` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52483
diff changeset
1811 """
dfb60fb155da interfaces: convert `ilocalrepositorymain` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52483
diff changeset
1812
dfb60fb155da interfaces: convert `ilocalrepositorymain` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52483
diff changeset
1813 root: bytes
dfb60fb155da interfaces: convert `ilocalrepositorymain` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52483
diff changeset
1814 """Path to the root of the working directory."""
dfb60fb155da interfaces: convert `ilocalrepositorymain` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52483
diff changeset
1815
dfb60fb155da interfaces: convert `ilocalrepositorymain` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52483
diff changeset
1816 path: bytes
dfb60fb155da interfaces: convert `ilocalrepositorymain` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52483
diff changeset
1817 """Path to the .hg directory."""
dfb60fb155da interfaces: convert `ilocalrepositorymain` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52483
diff changeset
1818
dfb60fb155da interfaces: convert `ilocalrepositorymain` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52483
diff changeset
1819 origroot: bytes
dfb60fb155da interfaces: convert `ilocalrepositorymain` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52483
diff changeset
1820 """The filesystem path that was used to construct the repo."""
dfb60fb155da interfaces: convert `ilocalrepositorymain` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52483
diff changeset
1821
dfb60fb155da interfaces: convert `ilocalrepositorymain` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52483
diff changeset
1822 auditor: Any
dfb60fb155da interfaces: convert `ilocalrepositorymain` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52483
diff changeset
1823 """A pathauditor for the working directory.
dfb60fb155da interfaces: convert `ilocalrepositorymain` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52483
diff changeset
1824
dfb60fb155da interfaces: convert `ilocalrepositorymain` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52483
diff changeset
1825 This checks if a path refers to a nested repository.
dfb60fb155da interfaces: convert `ilocalrepositorymain` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52483
diff changeset
1826
dfb60fb155da interfaces: convert `ilocalrepositorymain` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52483
diff changeset
1827 Operates on the filesystem.
dfb60fb155da interfaces: convert `ilocalrepositorymain` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52483
diff changeset
1828 """
dfb60fb155da interfaces: convert `ilocalrepositorymain` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52483
diff changeset
1829
dfb60fb155da interfaces: convert `ilocalrepositorymain` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52483
diff changeset
1830 nofsauditor: Any # TODO: add type hints
dfb60fb155da interfaces: convert `ilocalrepositorymain` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52483
diff changeset
1831 """A pathauditor for the working directory.
dfb60fb155da interfaces: convert `ilocalrepositorymain` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52483
diff changeset
1832
dfb60fb155da interfaces: convert `ilocalrepositorymain` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52483
diff changeset
1833 This is like ``auditor`` except it doesn't do filesystem checks.
dfb60fb155da interfaces: convert `ilocalrepositorymain` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52483
diff changeset
1834 """
dfb60fb155da interfaces: convert `ilocalrepositorymain` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52483
diff changeset
1835
dfb60fb155da interfaces: convert `ilocalrepositorymain` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52483
diff changeset
1836 baseui: Ui
dfb60fb155da interfaces: convert `ilocalrepositorymain` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52483
diff changeset
1837 """Original ui instance passed into constructor."""
dfb60fb155da interfaces: convert `ilocalrepositorymain` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52483
diff changeset
1838
dfb60fb155da interfaces: convert `ilocalrepositorymain` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52483
diff changeset
1839 ui: Ui
dfb60fb155da interfaces: convert `ilocalrepositorymain` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52483
diff changeset
1840 """Main ui instance for this instance."""
dfb60fb155da interfaces: convert `ilocalrepositorymain` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52483
diff changeset
1841
dfb60fb155da interfaces: convert `ilocalrepositorymain` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52483
diff changeset
1842 sharedpath: bytes
dfb60fb155da interfaces: convert `ilocalrepositorymain` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52483
diff changeset
1843 """Path to the .hg directory of the repo this repo was shared from."""
dfb60fb155da interfaces: convert `ilocalrepositorymain` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52483
diff changeset
1844
dfb60fb155da interfaces: convert `ilocalrepositorymain` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52483
diff changeset
1845 store: Any # TODO: add type hints
dfb60fb155da interfaces: convert `ilocalrepositorymain` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52483
diff changeset
1846 """A store instance."""
dfb60fb155da interfaces: convert `ilocalrepositorymain` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52483
diff changeset
1847
dfb60fb155da interfaces: convert `ilocalrepositorymain` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52483
diff changeset
1848 spath: bytes
dfb60fb155da interfaces: convert `ilocalrepositorymain` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52483
diff changeset
1849 """Path to the store."""
dfb60fb155da interfaces: convert `ilocalrepositorymain` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52483
diff changeset
1850
dfb60fb155da interfaces: convert `ilocalrepositorymain` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52483
diff changeset
1851 sjoin: Callable # TODO: add type hints
dfb60fb155da interfaces: convert `ilocalrepositorymain` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52483
diff changeset
1852 """Alias to self.store.join."""
dfb60fb155da interfaces: convert `ilocalrepositorymain` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52483
diff changeset
1853
dfb60fb155da interfaces: convert `ilocalrepositorymain` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52483
diff changeset
1854 cachevfs: Vfs
dfb60fb155da interfaces: convert `ilocalrepositorymain` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52483
diff changeset
1855 """A VFS used to access the cache directory.
dfb60fb155da interfaces: convert `ilocalrepositorymain` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52483
diff changeset
1856
dfb60fb155da interfaces: convert `ilocalrepositorymain` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52483
diff changeset
1857 Typically .hg/cache.
dfb60fb155da interfaces: convert `ilocalrepositorymain` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52483
diff changeset
1858 """
dfb60fb155da interfaces: convert `ilocalrepositorymain` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52483
diff changeset
1859
dfb60fb155da interfaces: convert `ilocalrepositorymain` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52483
diff changeset
1860 wcachevfs: Vfs
dfb60fb155da interfaces: convert `ilocalrepositorymain` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52483
diff changeset
1861 """A VFS used to access the cache directory dedicated to working copy
dfb60fb155da interfaces: convert `ilocalrepositorymain` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52483
diff changeset
1862
dfb60fb155da interfaces: convert `ilocalrepositorymain` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52483
diff changeset
1863 Typically .hg/wcache.
dfb60fb155da interfaces: convert `ilocalrepositorymain` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52483
diff changeset
1864 """
dfb60fb155da interfaces: convert `ilocalrepositorymain` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52483
diff changeset
1865
dfb60fb155da interfaces: convert `ilocalrepositorymain` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52483
diff changeset
1866 filteredrevcache: Any # TODO: add type hints
dfb60fb155da interfaces: convert `ilocalrepositorymain` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52483
diff changeset
1867 """Holds sets of revisions to be filtered."""
dfb60fb155da interfaces: convert `ilocalrepositorymain` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52483
diff changeset
1868
dfb60fb155da interfaces: convert `ilocalrepositorymain` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52483
diff changeset
1869 names: Any # TODO: add type hints
dfb60fb155da interfaces: convert `ilocalrepositorymain` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52483
diff changeset
1870 """A ``namespaces`` instance."""
dfb60fb155da interfaces: convert `ilocalrepositorymain` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52483
diff changeset
1871
dfb60fb155da interfaces: convert `ilocalrepositorymain` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52483
diff changeset
1872 filecopiesmode: Any # TODO: add type hints
dfb60fb155da interfaces: convert `ilocalrepositorymain` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52483
diff changeset
1873 """The way files copies should be dealt with in this repo."""
43142
beed7ce61681 sidedatacopies: write copies information in sidedata when applicable
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 43077
diff changeset
1874
52486
c0d9fda9f5f5 interfaces: make `repository.ilocalrepositorymain` methods abstract
Matt Harbison <matt_harbison@yahoo.com>
parents: 52485
diff changeset
1875 @abc.abstractmethod
52446
c1674551c109 interfaces: add the missing `self` arg to the repository Protocol classes
Matt Harbison <matt_harbison@yahoo.com>
parents: 52445
diff changeset
1876 def close(self):
37181
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
1877 """Close the handle on this repository."""
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
1878
52486
c0d9fda9f5f5 interfaces: make `repository.ilocalrepositorymain` methods abstract
Matt Harbison <matt_harbison@yahoo.com>
parents: 52485
diff changeset
1879 @abc.abstractmethod
52446
c1674551c109 interfaces: add the missing `self` arg to the repository Protocol classes
Matt Harbison <matt_harbison@yahoo.com>
parents: 52445
diff changeset
1880 def peer(self, path=None):
37181
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
1881 """Obtain an object conforming to the ``peer`` interface."""
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
1882
52486
c0d9fda9f5f5 interfaces: make `repository.ilocalrepositorymain` methods abstract
Matt Harbison <matt_harbison@yahoo.com>
parents: 52485
diff changeset
1883 @abc.abstractmethod
52446
c1674551c109 interfaces: add the missing `self` arg to the repository Protocol classes
Matt Harbison <matt_harbison@yahoo.com>
parents: 52445
diff changeset
1884 def unfiltered(self):
37181
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
1885 """Obtain an unfiltered/raw view of this repo."""
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
1886
52486
c0d9fda9f5f5 interfaces: make `repository.ilocalrepositorymain` methods abstract
Matt Harbison <matt_harbison@yahoo.com>
parents: 52485
diff changeset
1887 @abc.abstractmethod
52446
c1674551c109 interfaces: add the missing `self` arg to the repository Protocol classes
Matt Harbison <matt_harbison@yahoo.com>
parents: 52445
diff changeset
1888 def filtered(self, name, visibilityexceptions=None):
37181
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
1889 """Obtain a named view of this repository."""
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
1890
52485
dfb60fb155da interfaces: convert `ilocalrepositorymain` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52483
diff changeset
1891 obsstore: Any # TODO: add type hints
dfb60fb155da interfaces: convert `ilocalrepositorymain` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52483
diff changeset
1892 """A store of obsolescence data."""
dfb60fb155da interfaces: convert `ilocalrepositorymain` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52483
diff changeset
1893
dfb60fb155da interfaces: convert `ilocalrepositorymain` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52483
diff changeset
1894 changelog: Any # TODO: add type hints
dfb60fb155da interfaces: convert `ilocalrepositorymain` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52483
diff changeset
1895 """A handle on the changelog revlog."""
dfb60fb155da interfaces: convert `ilocalrepositorymain` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52483
diff changeset
1896
dfb60fb155da interfaces: convert `ilocalrepositorymain` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52483
diff changeset
1897 manifestlog: imanifestlog
dfb60fb155da interfaces: convert `ilocalrepositorymain` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52483
diff changeset
1898 """An instance conforming to the ``imanifestlog`` interface.
dfb60fb155da interfaces: convert `ilocalrepositorymain` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52483
diff changeset
1899
dfb60fb155da interfaces: convert `ilocalrepositorymain` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52483
diff changeset
1900 Provides access to manifests for the repository.
dfb60fb155da interfaces: convert `ilocalrepositorymain` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52483
diff changeset
1901 """
dfb60fb155da interfaces: convert `ilocalrepositorymain` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52483
diff changeset
1902
dfb60fb155da interfaces: convert `ilocalrepositorymain` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52483
diff changeset
1903 dirstate: intdirstate.idirstate
dfb60fb155da interfaces: convert `ilocalrepositorymain` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52483
diff changeset
1904 """Working directory state."""
dfb60fb155da interfaces: convert `ilocalrepositorymain` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52483
diff changeset
1905
dfb60fb155da interfaces: convert `ilocalrepositorymain` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52483
diff changeset
1906 narrowpats: Any # TODO: add type hints
dfb60fb155da interfaces: convert `ilocalrepositorymain` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52483
diff changeset
1907 """Matcher patterns for this repository's narrowspec."""
37181
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
1908
52486
c0d9fda9f5f5 interfaces: make `repository.ilocalrepositorymain` methods abstract
Matt Harbison <matt_harbison@yahoo.com>
parents: 52485
diff changeset
1909 @abc.abstractmethod
52446
c1674551c109 interfaces: add the missing `self` arg to the repository Protocol classes
Matt Harbison <matt_harbison@yahoo.com>
parents: 52445
diff changeset
1910 def narrowmatch(self, match=None, includeexact=False):
37181
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
1911 """Obtain a matcher for the narrowspec."""
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
1912
52486
c0d9fda9f5f5 interfaces: make `repository.ilocalrepositorymain` methods abstract
Matt Harbison <matt_harbison@yahoo.com>
parents: 52485
diff changeset
1913 @abc.abstractmethod
52446
c1674551c109 interfaces: add the missing `self` arg to the repository Protocol classes
Matt Harbison <matt_harbison@yahoo.com>
parents: 52445
diff changeset
1914 def setnarrowpats(self, newincludes, newexcludes):
37181
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
1915 """Define the narrowspec for this repository."""
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
1916
52486
c0d9fda9f5f5 interfaces: make `repository.ilocalrepositorymain` methods abstract
Matt Harbison <matt_harbison@yahoo.com>
parents: 52485
diff changeset
1917 @abc.abstractmethod
52446
c1674551c109 interfaces: add the missing `self` arg to the repository Protocol classes
Matt Harbison <matt_harbison@yahoo.com>
parents: 52445
diff changeset
1918 def __getitem__(self, changeid):
37181
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
1919 """Try to resolve a changectx."""
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
1920
52486
c0d9fda9f5f5 interfaces: make `repository.ilocalrepositorymain` methods abstract
Matt Harbison <matt_harbison@yahoo.com>
parents: 52485
diff changeset
1921 @abc.abstractmethod
52446
c1674551c109 interfaces: add the missing `self` arg to the repository Protocol classes
Matt Harbison <matt_harbison@yahoo.com>
parents: 52445
diff changeset
1922 def __contains__(self, changeid):
37181
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
1923 """Whether a changeset exists."""
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
1924
52486
c0d9fda9f5f5 interfaces: make `repository.ilocalrepositorymain` methods abstract
Matt Harbison <matt_harbison@yahoo.com>
parents: 52485
diff changeset
1925 @abc.abstractmethod
52446
c1674551c109 interfaces: add the missing `self` arg to the repository Protocol classes
Matt Harbison <matt_harbison@yahoo.com>
parents: 52445
diff changeset
1926 def __nonzero__(self):
37181
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
1927 """Always returns True."""
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
1928 return True
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
1929
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
1930 __bool__ = __nonzero__
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
1931
52486
c0d9fda9f5f5 interfaces: make `repository.ilocalrepositorymain` methods abstract
Matt Harbison <matt_harbison@yahoo.com>
parents: 52485
diff changeset
1932 @abc.abstractmethod
52446
c1674551c109 interfaces: add the missing `self` arg to the repository Protocol classes
Matt Harbison <matt_harbison@yahoo.com>
parents: 52445
diff changeset
1933 def __len__(self):
37181
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
1934 """Returns the number of changesets in the repo."""
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
1935
52486
c0d9fda9f5f5 interfaces: make `repository.ilocalrepositorymain` methods abstract
Matt Harbison <matt_harbison@yahoo.com>
parents: 52485
diff changeset
1936 @abc.abstractmethod
52446
c1674551c109 interfaces: add the missing `self` arg to the repository Protocol classes
Matt Harbison <matt_harbison@yahoo.com>
parents: 52445
diff changeset
1937 def __iter__(self):
37181
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
1938 """Iterate over revisions in the changelog."""
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
1939
52486
c0d9fda9f5f5 interfaces: make `repository.ilocalrepositorymain` methods abstract
Matt Harbison <matt_harbison@yahoo.com>
parents: 52485
diff changeset
1940 @abc.abstractmethod
52446
c1674551c109 interfaces: add the missing `self` arg to the repository Protocol classes
Matt Harbison <matt_harbison@yahoo.com>
parents: 52445
diff changeset
1941 def revs(self, expr, *args):
37181
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
1942 """Evaluate a revset.
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
1943
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
1944 Emits revisions.
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
1945 """
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
1946
52486
c0d9fda9f5f5 interfaces: make `repository.ilocalrepositorymain` methods abstract
Matt Harbison <matt_harbison@yahoo.com>
parents: 52485
diff changeset
1947 @abc.abstractmethod
52446
c1674551c109 interfaces: add the missing `self` arg to the repository Protocol classes
Matt Harbison <matt_harbison@yahoo.com>
parents: 52445
diff changeset
1948 def set(self, expr, *args):
37181
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
1949 """Evaluate a revset.
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
1950
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
1951 Emits changectx instances.
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
1952 """
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
1953
52486
c0d9fda9f5f5 interfaces: make `repository.ilocalrepositorymain` methods abstract
Matt Harbison <matt_harbison@yahoo.com>
parents: 52485
diff changeset
1954 @abc.abstractmethod
52446
c1674551c109 interfaces: add the missing `self` arg to the repository Protocol classes
Matt Harbison <matt_harbison@yahoo.com>
parents: 52445
diff changeset
1955 def anyrevs(self, specs, user=False, localalias=None):
37181
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
1956 """Find revisions matching one of the given revsets."""
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
1957
52486
c0d9fda9f5f5 interfaces: make `repository.ilocalrepositorymain` methods abstract
Matt Harbison <matt_harbison@yahoo.com>
parents: 52485
diff changeset
1958 @abc.abstractmethod
52446
c1674551c109 interfaces: add the missing `self` arg to the repository Protocol classes
Matt Harbison <matt_harbison@yahoo.com>
parents: 52445
diff changeset
1959 def url(self):
37181
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
1960 """Returns a string representing the location of this repo."""
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
1961
52486
c0d9fda9f5f5 interfaces: make `repository.ilocalrepositorymain` methods abstract
Matt Harbison <matt_harbison@yahoo.com>
parents: 52485
diff changeset
1962 @abc.abstractmethod
52446
c1674551c109 interfaces: add the missing `self` arg to the repository Protocol classes
Matt Harbison <matt_harbison@yahoo.com>
parents: 52445
diff changeset
1963 def hook(self, name, throw=False, **args):
37181
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
1964 """Call a hook."""
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
1965
52486
c0d9fda9f5f5 interfaces: make `repository.ilocalrepositorymain` methods abstract
Matt Harbison <matt_harbison@yahoo.com>
parents: 52485
diff changeset
1966 @abc.abstractmethod
52446
c1674551c109 interfaces: add the missing `self` arg to the repository Protocol classes
Matt Harbison <matt_harbison@yahoo.com>
parents: 52445
diff changeset
1967 def tags(self):
37181
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
1968 """Return a mapping of tag to node."""
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
1969
52486
c0d9fda9f5f5 interfaces: make `repository.ilocalrepositorymain` methods abstract
Matt Harbison <matt_harbison@yahoo.com>
parents: 52485
diff changeset
1970 @abc.abstractmethod
52446
c1674551c109 interfaces: add the missing `self` arg to the repository Protocol classes
Matt Harbison <matt_harbison@yahoo.com>
parents: 52445
diff changeset
1971 def tagtype(self, tagname):
37181
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
1972 """Return the type of a given tag."""
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
1973
52486
c0d9fda9f5f5 interfaces: make `repository.ilocalrepositorymain` methods abstract
Matt Harbison <matt_harbison@yahoo.com>
parents: 52485
diff changeset
1974 @abc.abstractmethod
52446
c1674551c109 interfaces: add the missing `self` arg to the repository Protocol classes
Matt Harbison <matt_harbison@yahoo.com>
parents: 52445
diff changeset
1975 def tagslist(self):
37181
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
1976 """Return a list of tags ordered by revision."""
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
1977
52486
c0d9fda9f5f5 interfaces: make `repository.ilocalrepositorymain` methods abstract
Matt Harbison <matt_harbison@yahoo.com>
parents: 52485
diff changeset
1978 @abc.abstractmethod
52446
c1674551c109 interfaces: add the missing `self` arg to the repository Protocol classes
Matt Harbison <matt_harbison@yahoo.com>
parents: 52445
diff changeset
1979 def nodetags(self, node):
37181
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
1980 """Return the tags associated with a node."""
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
1981
52486
c0d9fda9f5f5 interfaces: make `repository.ilocalrepositorymain` methods abstract
Matt Harbison <matt_harbison@yahoo.com>
parents: 52485
diff changeset
1982 @abc.abstractmethod
52446
c1674551c109 interfaces: add the missing `self` arg to the repository Protocol classes
Matt Harbison <matt_harbison@yahoo.com>
parents: 52445
diff changeset
1983 def nodebookmarks(self, node):
37181
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
1984 """Return the list of bookmarks pointing to the specified node."""
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
1985
52486
c0d9fda9f5f5 interfaces: make `repository.ilocalrepositorymain` methods abstract
Matt Harbison <matt_harbison@yahoo.com>
parents: 52485
diff changeset
1986 @abc.abstractmethod
52446
c1674551c109 interfaces: add the missing `self` arg to the repository Protocol classes
Matt Harbison <matt_harbison@yahoo.com>
parents: 52445
diff changeset
1987 def branchmap(self):
37181
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
1988 """Return a mapping of branch to heads in that branch."""
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
1989
52486
c0d9fda9f5f5 interfaces: make `repository.ilocalrepositorymain` methods abstract
Matt Harbison <matt_harbison@yahoo.com>
parents: 52485
diff changeset
1990 @abc.abstractmethod
52446
c1674551c109 interfaces: add the missing `self` arg to the repository Protocol classes
Matt Harbison <matt_harbison@yahoo.com>
parents: 52445
diff changeset
1991 def revbranchcache(self):
37181
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
1992 pass
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
1993
52486
c0d9fda9f5f5 interfaces: make `repository.ilocalrepositorymain` methods abstract
Matt Harbison <matt_harbison@yahoo.com>
parents: 52485
diff changeset
1994 @abc.abstractmethod
52446
c1674551c109 interfaces: add the missing `self` arg to the repository Protocol classes
Matt Harbison <matt_harbison@yahoo.com>
parents: 52445
diff changeset
1995 def register_changeset(self, rev, changelogrevision):
46371
0903d6b9b1df repository: introduce register_changeset callback
Joerg Sonnenberger <joerg@bec.de>
parents: 45946
diff changeset
1996 """Extension point for caches for new nodes.
0903d6b9b1df repository: introduce register_changeset callback
Joerg Sonnenberger <joerg@bec.de>
parents: 45946
diff changeset
1997
0903d6b9b1df repository: introduce register_changeset callback
Joerg Sonnenberger <joerg@bec.de>
parents: 45946
diff changeset
1998 Multiple consumers are expected to need parts of the changelogrevision,
0903d6b9b1df repository: introduce register_changeset callback
Joerg Sonnenberger <joerg@bec.de>
parents: 45946
diff changeset
1999 so it is provided as optimization to avoid duplicate lookups. A simple
0903d6b9b1df repository: introduce register_changeset callback
Joerg Sonnenberger <joerg@bec.de>
parents: 45946
diff changeset
2000 cache would be fragile when other revisions are accessed, too."""
0903d6b9b1df repository: introduce register_changeset callback
Joerg Sonnenberger <joerg@bec.de>
parents: 45946
diff changeset
2001 pass
0903d6b9b1df repository: introduce register_changeset callback
Joerg Sonnenberger <joerg@bec.de>
parents: 45946
diff changeset
2002
52486
c0d9fda9f5f5 interfaces: make `repository.ilocalrepositorymain` methods abstract
Matt Harbison <matt_harbison@yahoo.com>
parents: 52485
diff changeset
2003 @abc.abstractmethod
52446
c1674551c109 interfaces: add the missing `self` arg to the repository Protocol classes
Matt Harbison <matt_harbison@yahoo.com>
parents: 52445
diff changeset
2004 def branchtip(self, branchtip, ignoremissing=False):
37181
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
2005 """Return the tip node for a given branch."""
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
2006
52486
c0d9fda9f5f5 interfaces: make `repository.ilocalrepositorymain` methods abstract
Matt Harbison <matt_harbison@yahoo.com>
parents: 52485
diff changeset
2007 @abc.abstractmethod
52446
c1674551c109 interfaces: add the missing `self` arg to the repository Protocol classes
Matt Harbison <matt_harbison@yahoo.com>
parents: 52445
diff changeset
2008 def lookup(self, key):
37181
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
2009 """Resolve the node for a revision."""
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
2010
52486
c0d9fda9f5f5 interfaces: make `repository.ilocalrepositorymain` methods abstract
Matt Harbison <matt_harbison@yahoo.com>
parents: 52485
diff changeset
2011 @abc.abstractmethod
52446
c1674551c109 interfaces: add the missing `self` arg to the repository Protocol classes
Matt Harbison <matt_harbison@yahoo.com>
parents: 52445
diff changeset
2012 def lookupbranch(self, key):
37181
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
2013 """Look up the branch name of the given revision or branch name."""
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
2014
52486
c0d9fda9f5f5 interfaces: make `repository.ilocalrepositorymain` methods abstract
Matt Harbison <matt_harbison@yahoo.com>
parents: 52485
diff changeset
2015 @abc.abstractmethod
52446
c1674551c109 interfaces: add the missing `self` arg to the repository Protocol classes
Matt Harbison <matt_harbison@yahoo.com>
parents: 52445
diff changeset
2016 def known(self, nodes):
37181
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
2017 """Determine whether a series of nodes is known.
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
2018
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
2019 Returns a list of bools.
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
2020 """
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
2021
52486
c0d9fda9f5f5 interfaces: make `repository.ilocalrepositorymain` methods abstract
Matt Harbison <matt_harbison@yahoo.com>
parents: 52485
diff changeset
2022 @abc.abstractmethod
52446
c1674551c109 interfaces: add the missing `self` arg to the repository Protocol classes
Matt Harbison <matt_harbison@yahoo.com>
parents: 52445
diff changeset
2023 def local(self):
37181
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
2024 """Whether the repository is local."""
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
2025 return True
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
2026
52486
c0d9fda9f5f5 interfaces: make `repository.ilocalrepositorymain` methods abstract
Matt Harbison <matt_harbison@yahoo.com>
parents: 52485
diff changeset
2027 @abc.abstractmethod
52446
c1674551c109 interfaces: add the missing `self` arg to the repository Protocol classes
Matt Harbison <matt_harbison@yahoo.com>
parents: 52445
diff changeset
2028 def publishing(self):
37181
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
2029 """Whether the repository is a publishing repository."""
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
2030
52486
c0d9fda9f5f5 interfaces: make `repository.ilocalrepositorymain` methods abstract
Matt Harbison <matt_harbison@yahoo.com>
parents: 52485
diff changeset
2031 @abc.abstractmethod
52446
c1674551c109 interfaces: add the missing `self` arg to the repository Protocol classes
Matt Harbison <matt_harbison@yahoo.com>
parents: 52445
diff changeset
2032 def cancopy(self):
37181
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
2033 pass
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
2034
52486
c0d9fda9f5f5 interfaces: make `repository.ilocalrepositorymain` methods abstract
Matt Harbison <matt_harbison@yahoo.com>
parents: 52485
diff changeset
2035 @abc.abstractmethod
52446
c1674551c109 interfaces: add the missing `self` arg to the repository Protocol classes
Matt Harbison <matt_harbison@yahoo.com>
parents: 52445
diff changeset
2036 def shared(self):
37181
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
2037 """The type of shared repository or None."""
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
2038
52486
c0d9fda9f5f5 interfaces: make `repository.ilocalrepositorymain` methods abstract
Matt Harbison <matt_harbison@yahoo.com>
parents: 52485
diff changeset
2039 @abc.abstractmethod
52446
c1674551c109 interfaces: add the missing `self` arg to the repository Protocol classes
Matt Harbison <matt_harbison@yahoo.com>
parents: 52445
diff changeset
2040 def wjoin(self, f, *insidef):
37181
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
2041 """Calls self.vfs.reljoin(self.root, f, *insidef)"""
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
2042
52486
c0d9fda9f5f5 interfaces: make `repository.ilocalrepositorymain` methods abstract
Matt Harbison <matt_harbison@yahoo.com>
parents: 52485
diff changeset
2043 @abc.abstractmethod
52446
c1674551c109 interfaces: add the missing `self` arg to the repository Protocol classes
Matt Harbison <matt_harbison@yahoo.com>
parents: 52445
diff changeset
2044 def setparents(self, p1, p2):
37181
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
2045 """Set the parent nodes of the working directory."""
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
2046
52486
c0d9fda9f5f5 interfaces: make `repository.ilocalrepositorymain` methods abstract
Matt Harbison <matt_harbison@yahoo.com>
parents: 52485
diff changeset
2047 @abc.abstractmethod
52446
c1674551c109 interfaces: add the missing `self` arg to the repository Protocol classes
Matt Harbison <matt_harbison@yahoo.com>
parents: 52445
diff changeset
2048 def filectx(self, path, changeid=None, fileid=None):
37181
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
2049 """Obtain a filectx for the given file revision."""
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
2050
52486
c0d9fda9f5f5 interfaces: make `repository.ilocalrepositorymain` methods abstract
Matt Harbison <matt_harbison@yahoo.com>
parents: 52485
diff changeset
2051 @abc.abstractmethod
52446
c1674551c109 interfaces: add the missing `self` arg to the repository Protocol classes
Matt Harbison <matt_harbison@yahoo.com>
parents: 52445
diff changeset
2052 def getcwd(self):
37181
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
2053 """Obtain the current working directory from the dirstate."""
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
2054
52486
c0d9fda9f5f5 interfaces: make `repository.ilocalrepositorymain` methods abstract
Matt Harbison <matt_harbison@yahoo.com>
parents: 52485
diff changeset
2055 @abc.abstractmethod
52446
c1674551c109 interfaces: add the missing `self` arg to the repository Protocol classes
Matt Harbison <matt_harbison@yahoo.com>
parents: 52445
diff changeset
2056 def pathto(self, f, cwd=None):
37181
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
2057 """Obtain the relative path to a file."""
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
2058
52486
c0d9fda9f5f5 interfaces: make `repository.ilocalrepositorymain` methods abstract
Matt Harbison <matt_harbison@yahoo.com>
parents: 52485
diff changeset
2059 @abc.abstractmethod
52446
c1674551c109 interfaces: add the missing `self` arg to the repository Protocol classes
Matt Harbison <matt_harbison@yahoo.com>
parents: 52445
diff changeset
2060 def adddatafilter(self, name, fltr):
37181
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
2061 pass
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
2062
52486
c0d9fda9f5f5 interfaces: make `repository.ilocalrepositorymain` methods abstract
Matt Harbison <matt_harbison@yahoo.com>
parents: 52485
diff changeset
2063 @abc.abstractmethod
52446
c1674551c109 interfaces: add the missing `self` arg to the repository Protocol classes
Matt Harbison <matt_harbison@yahoo.com>
parents: 52445
diff changeset
2064 def wread(self, filename):
37181
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
2065 """Read a file from wvfs, using data filters."""
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
2066
52486
c0d9fda9f5f5 interfaces: make `repository.ilocalrepositorymain` methods abstract
Matt Harbison <matt_harbison@yahoo.com>
parents: 52485
diff changeset
2067 @abc.abstractmethod
52446
c1674551c109 interfaces: add the missing `self` arg to the repository Protocol classes
Matt Harbison <matt_harbison@yahoo.com>
parents: 52445
diff changeset
2068 def wwrite(self, filename, data, flags, backgroundclose=False, **kwargs):
37181
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
2069 """Write data to a file in the wvfs, using data filters."""
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
2070
52486
c0d9fda9f5f5 interfaces: make `repository.ilocalrepositorymain` methods abstract
Matt Harbison <matt_harbison@yahoo.com>
parents: 52485
diff changeset
2071 @abc.abstractmethod
52446
c1674551c109 interfaces: add the missing `self` arg to the repository Protocol classes
Matt Harbison <matt_harbison@yahoo.com>
parents: 52445
diff changeset
2072 def wwritedata(self, filename, data):
37181
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
2073 """Resolve data for writing to the wvfs, using data filters."""
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
2074
52486
c0d9fda9f5f5 interfaces: make `repository.ilocalrepositorymain` methods abstract
Matt Harbison <matt_harbison@yahoo.com>
parents: 52485
diff changeset
2075 @abc.abstractmethod
52446
c1674551c109 interfaces: add the missing `self` arg to the repository Protocol classes
Matt Harbison <matt_harbison@yahoo.com>
parents: 52445
diff changeset
2076 def currenttransaction(self):
37181
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
2077 """Obtain the current transaction instance or None."""
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
2078
52486
c0d9fda9f5f5 interfaces: make `repository.ilocalrepositorymain` methods abstract
Matt Harbison <matt_harbison@yahoo.com>
parents: 52485
diff changeset
2079 @abc.abstractmethod
52446
c1674551c109 interfaces: add the missing `self` arg to the repository Protocol classes
Matt Harbison <matt_harbison@yahoo.com>
parents: 52445
diff changeset
2080 def transaction(self, desc, report=None):
37181
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
2081 """Open a new transaction to write to the repository."""
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
2082
52486
c0d9fda9f5f5 interfaces: make `repository.ilocalrepositorymain` methods abstract
Matt Harbison <matt_harbison@yahoo.com>
parents: 52485
diff changeset
2083 @abc.abstractmethod
52446
c1674551c109 interfaces: add the missing `self` arg to the repository Protocol classes
Matt Harbison <matt_harbison@yahoo.com>
parents: 52445
diff changeset
2084 def undofiles(self):
37181
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
2085 """Returns a list of (vfs, path) for files to undo transactions."""
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
2086
52486
c0d9fda9f5f5 interfaces: make `repository.ilocalrepositorymain` methods abstract
Matt Harbison <matt_harbison@yahoo.com>
parents: 52485
diff changeset
2087 @abc.abstractmethod
52446
c1674551c109 interfaces: add the missing `self` arg to the repository Protocol classes
Matt Harbison <matt_harbison@yahoo.com>
parents: 52445
diff changeset
2088 def recover(self):
37181
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
2089 """Roll back an interrupted transaction."""
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
2090
52486
c0d9fda9f5f5 interfaces: make `repository.ilocalrepositorymain` methods abstract
Matt Harbison <matt_harbison@yahoo.com>
parents: 52485
diff changeset
2091 @abc.abstractmethod
52446
c1674551c109 interfaces: add the missing `self` arg to the repository Protocol classes
Matt Harbison <matt_harbison@yahoo.com>
parents: 52445
diff changeset
2092 def rollback(self, dryrun=False, force=False):
37181
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
2093 """Undo the last transaction.
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
2094
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
2095 DANGEROUS.
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
2096 """
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
2097
52486
c0d9fda9f5f5 interfaces: make `repository.ilocalrepositorymain` methods abstract
Matt Harbison <matt_harbison@yahoo.com>
parents: 52485
diff changeset
2098 @abc.abstractmethod
52446
c1674551c109 interfaces: add the missing `self` arg to the repository Protocol classes
Matt Harbison <matt_harbison@yahoo.com>
parents: 52445
diff changeset
2099 def updatecaches(self, tr=None, full=False, caches=None):
37181
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
2100 """Warm repo caches."""
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
2101
52486
c0d9fda9f5f5 interfaces: make `repository.ilocalrepositorymain` methods abstract
Matt Harbison <matt_harbison@yahoo.com>
parents: 52485
diff changeset
2102 @abc.abstractmethod
52446
c1674551c109 interfaces: add the missing `self` arg to the repository Protocol classes
Matt Harbison <matt_harbison@yahoo.com>
parents: 52445
diff changeset
2103 def invalidatecaches(self):
37181
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
2104 """Invalidate cached data due to the repository mutating."""
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
2105
52486
c0d9fda9f5f5 interfaces: make `repository.ilocalrepositorymain` methods abstract
Matt Harbison <matt_harbison@yahoo.com>
parents: 52485
diff changeset
2106 @abc.abstractmethod
52446
c1674551c109 interfaces: add the missing `self` arg to the repository Protocol classes
Matt Harbison <matt_harbison@yahoo.com>
parents: 52445
diff changeset
2107 def invalidatevolatilesets(self):
37181
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
2108 pass
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
2109
52486
c0d9fda9f5f5 interfaces: make `repository.ilocalrepositorymain` methods abstract
Matt Harbison <matt_harbison@yahoo.com>
parents: 52485
diff changeset
2110 @abc.abstractmethod
52446
c1674551c109 interfaces: add the missing `self` arg to the repository Protocol classes
Matt Harbison <matt_harbison@yahoo.com>
parents: 52445
diff changeset
2111 def invalidatedirstate(self):
37181
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
2112 """Invalidate the dirstate."""
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
2113
52486
c0d9fda9f5f5 interfaces: make `repository.ilocalrepositorymain` methods abstract
Matt Harbison <matt_harbison@yahoo.com>
parents: 52485
diff changeset
2114 @abc.abstractmethod
52446
c1674551c109 interfaces: add the missing `self` arg to the repository Protocol classes
Matt Harbison <matt_harbison@yahoo.com>
parents: 52445
diff changeset
2115 def invalidate(self, clearfilecache=False):
37181
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
2116 pass
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
2117
52486
c0d9fda9f5f5 interfaces: make `repository.ilocalrepositorymain` methods abstract
Matt Harbison <matt_harbison@yahoo.com>
parents: 52485
diff changeset
2118 @abc.abstractmethod
52446
c1674551c109 interfaces: add the missing `self` arg to the repository Protocol classes
Matt Harbison <matt_harbison@yahoo.com>
parents: 52445
diff changeset
2119 def invalidateall(self):
37181
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
2120 pass
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
2121
52486
c0d9fda9f5f5 interfaces: make `repository.ilocalrepositorymain` methods abstract
Matt Harbison <matt_harbison@yahoo.com>
parents: 52485
diff changeset
2122 @abc.abstractmethod
52725
0f2268783c11 clone: explicitly steal lock instead of assigning previous lock
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 52654
diff changeset
2123 def lock(self, wait=True, steal_from=None):
0f2268783c11 clone: explicitly steal lock instead of assigning previous lock
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 52654
diff changeset
2124 """Lock the repository store and return a lock instance.
0f2268783c11 clone: explicitly steal lock instead of assigning previous lock
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 52654
diff changeset
2125
0f2268783c11 clone: explicitly steal lock instead of assigning previous lock
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 52654
diff changeset
2126 If another lock object is specified through the "steal_from" argument,
0f2268783c11 clone: explicitly steal lock instead of assigning previous lock
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 52654
diff changeset
2127 the new lock will reuse the on-disk lock of that "stolen" lock instead
0f2268783c11 clone: explicitly steal lock instead of assigning previous lock
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 52654
diff changeset
2128 of creating its own. The "stolen" lock is no longer usable for any
0f2268783c11 clone: explicitly steal lock instead of assigning previous lock
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 52654
diff changeset
2129 purpose and won't execute its release callback.
0f2268783c11 clone: explicitly steal lock instead of assigning previous lock
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 52654
diff changeset
2130
0f2268783c11 clone: explicitly steal lock instead of assigning previous lock
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 52654
diff changeset
2131 That steal_from argument is used during local clone when reloading a
0f2268783c11 clone: explicitly steal lock instead of assigning previous lock
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 52654
diff changeset
2132 repository. If we could remove the need for this during copy clone, we
0f2268783c11 clone: explicitly steal lock instead of assigning previous lock
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 52654
diff changeset
2133 could remove this function.
0f2268783c11 clone: explicitly steal lock instead of assigning previous lock
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 52654
diff changeset
2134 """
37181
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
2135
52486
c0d9fda9f5f5 interfaces: make `repository.ilocalrepositorymain` methods abstract
Matt Harbison <matt_harbison@yahoo.com>
parents: 52485
diff changeset
2136 @abc.abstractmethod
52446
c1674551c109 interfaces: add the missing `self` arg to the repository Protocol classes
Matt Harbison <matt_harbison@yahoo.com>
parents: 52445
diff changeset
2137 def currentlock(self):
50323
6901916458bd localrepo: add a `currentlock` method
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 50281
diff changeset
2138 """Return the lock if it's held or None."""
6901916458bd localrepo: add a `currentlock` method
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 50281
diff changeset
2139
52486
c0d9fda9f5f5 interfaces: make `repository.ilocalrepositorymain` methods abstract
Matt Harbison <matt_harbison@yahoo.com>
parents: 52485
diff changeset
2140 @abc.abstractmethod
52725
0f2268783c11 clone: explicitly steal lock instead of assigning previous lock
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 52654
diff changeset
2141 def wlock(self, wait=True, steal_from=None):
0f2268783c11 clone: explicitly steal lock instead of assigning previous lock
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 52654
diff changeset
2142 """Lock the non-store parts of the repository.
0f2268783c11 clone: explicitly steal lock instead of assigning previous lock
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 52654
diff changeset
2143
0f2268783c11 clone: explicitly steal lock instead of assigning previous lock
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 52654
diff changeset
2144 If another lock object is specified through the "steal_from" argument,
0f2268783c11 clone: explicitly steal lock instead of assigning previous lock
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 52654
diff changeset
2145 the new lock will reuse the on-disk lock of that "stolen" lock instead
0f2268783c11 clone: explicitly steal lock instead of assigning previous lock
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 52654
diff changeset
2146 of creating its own. The "stolen" lock is no longer usable for any
0f2268783c11 clone: explicitly steal lock instead of assigning previous lock
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 52654
diff changeset
2147 purpose and won't execute its release callback.
0f2268783c11 clone: explicitly steal lock instead of assigning previous lock
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 52654
diff changeset
2148
0f2268783c11 clone: explicitly steal lock instead of assigning previous lock
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 52654
diff changeset
2149 That steal_from argument is used during local clone when reloading a
0f2268783c11 clone: explicitly steal lock instead of assigning previous lock
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 52654
diff changeset
2150 repository. If we could remove the need for this during copy clone, we
0f2268783c11 clone: explicitly steal lock instead of assigning previous lock
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 52654
diff changeset
2151 could remove this function.
0f2268783c11 clone: explicitly steal lock instead of assigning previous lock
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 52654
diff changeset
2152 """
37181
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
2153
52486
c0d9fda9f5f5 interfaces: make `repository.ilocalrepositorymain` methods abstract
Matt Harbison <matt_harbison@yahoo.com>
parents: 52485
diff changeset
2154 @abc.abstractmethod
52446
c1674551c109 interfaces: add the missing `self` arg to the repository Protocol classes
Matt Harbison <matt_harbison@yahoo.com>
parents: 52445
diff changeset
2155 def currentwlock(self):
37181
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
2156 """Return the wlock if it's held or None."""
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
2157
52486
c0d9fda9f5f5 interfaces: make `repository.ilocalrepositorymain` methods abstract
Matt Harbison <matt_harbison@yahoo.com>
parents: 52485
diff changeset
2158 @abc.abstractmethod
52446
c1674551c109 interfaces: add the missing `self` arg to the repository Protocol classes
Matt Harbison <matt_harbison@yahoo.com>
parents: 52445
diff changeset
2159 def checkcommitpatterns(self, wctx, match, status, fail):
37181
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
2160 pass
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
2161
52486
c0d9fda9f5f5 interfaces: make `repository.ilocalrepositorymain` methods abstract
Matt Harbison <matt_harbison@yahoo.com>
parents: 52485
diff changeset
2162 @abc.abstractmethod
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43032
diff changeset
2163 def commit(
52446
c1674551c109 interfaces: add the missing `self` arg to the repository Protocol classes
Matt Harbison <matt_harbison@yahoo.com>
parents: 52445
diff changeset
2164 self,
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
2165 text=b'',
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43032
diff changeset
2166 user=None,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43032
diff changeset
2167 date=None,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43032
diff changeset
2168 match=None,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43032
diff changeset
2169 force=False,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43032
diff changeset
2170 editor=False,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43032
diff changeset
2171 extra=None,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43032
diff changeset
2172 ):
37181
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
2173 """Add a new revision to the repository."""
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
2174
52486
c0d9fda9f5f5 interfaces: make `repository.ilocalrepositorymain` methods abstract
Matt Harbison <matt_harbison@yahoo.com>
parents: 52485
diff changeset
2175 @abc.abstractmethod
52446
c1674551c109 interfaces: add the missing `self` arg to the repository Protocol classes
Matt Harbison <matt_harbison@yahoo.com>
parents: 52445
diff changeset
2176 def commitctx(self, ctx, error=False, origctx=None):
37181
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
2177 """Commit a commitctx instance to the repository."""
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
2178
52486
c0d9fda9f5f5 interfaces: make `repository.ilocalrepositorymain` methods abstract
Matt Harbison <matt_harbison@yahoo.com>
parents: 52485
diff changeset
2179 @abc.abstractmethod
52446
c1674551c109 interfaces: add the missing `self` arg to the repository Protocol classes
Matt Harbison <matt_harbison@yahoo.com>
parents: 52445
diff changeset
2180 def destroying(self):
37181
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
2181 """Inform the repository that nodes are about to be destroyed."""
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
2182
52486
c0d9fda9f5f5 interfaces: make `repository.ilocalrepositorymain` methods abstract
Matt Harbison <matt_harbison@yahoo.com>
parents: 52485
diff changeset
2183 @abc.abstractmethod
52446
c1674551c109 interfaces: add the missing `self` arg to the repository Protocol classes
Matt Harbison <matt_harbison@yahoo.com>
parents: 52445
diff changeset
2184 def destroyed(self):
37181
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
2185 """Inform the repository that nodes have been destroyed."""
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
2186
52486
c0d9fda9f5f5 interfaces: make `repository.ilocalrepositorymain` methods abstract
Matt Harbison <matt_harbison@yahoo.com>
parents: 52485
diff changeset
2187 @abc.abstractmethod
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43032
diff changeset
2188 def status(
52446
c1674551c109 interfaces: add the missing `self` arg to the repository Protocol classes
Matt Harbison <matt_harbison@yahoo.com>
parents: 52445
diff changeset
2189 self,
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
2190 node1=b'.',
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43032
diff changeset
2191 node2=None,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43032
diff changeset
2192 match=None,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43032
diff changeset
2193 ignored=False,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43032
diff changeset
2194 clean=False,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43032
diff changeset
2195 unknown=False,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43032
diff changeset
2196 listsubrepos=False,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43032
diff changeset
2197 ):
37181
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
2198 """Convenience method to call repo[x].status()."""
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
2199
52486
c0d9fda9f5f5 interfaces: make `repository.ilocalrepositorymain` methods abstract
Matt Harbison <matt_harbison@yahoo.com>
parents: 52485
diff changeset
2200 @abc.abstractmethod
52446
c1674551c109 interfaces: add the missing `self` arg to the repository Protocol classes
Matt Harbison <matt_harbison@yahoo.com>
parents: 52445
diff changeset
2201 def addpostdsstatus(self, ps):
37181
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
2202 pass
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
2203
52486
c0d9fda9f5f5 interfaces: make `repository.ilocalrepositorymain` methods abstract
Matt Harbison <matt_harbison@yahoo.com>
parents: 52485
diff changeset
2204 @abc.abstractmethod
52446
c1674551c109 interfaces: add the missing `self` arg to the repository Protocol classes
Matt Harbison <matt_harbison@yahoo.com>
parents: 52445
diff changeset
2205 def postdsstatus(self):
37181
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
2206 pass
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
2207
52486
c0d9fda9f5f5 interfaces: make `repository.ilocalrepositorymain` methods abstract
Matt Harbison <matt_harbison@yahoo.com>
parents: 52485
diff changeset
2208 @abc.abstractmethod
52446
c1674551c109 interfaces: add the missing `self` arg to the repository Protocol classes
Matt Harbison <matt_harbison@yahoo.com>
parents: 52445
diff changeset
2209 def clearpostdsstatus(self):
37181
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
2210 pass
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
2211
52486
c0d9fda9f5f5 interfaces: make `repository.ilocalrepositorymain` methods abstract
Matt Harbison <matt_harbison@yahoo.com>
parents: 52485
diff changeset
2212 @abc.abstractmethod
52446
c1674551c109 interfaces: add the missing `self` arg to the repository Protocol classes
Matt Harbison <matt_harbison@yahoo.com>
parents: 52445
diff changeset
2213 def heads(self, start=None):
37181
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
2214 """Obtain list of nodes that are DAG heads."""
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
2215
52486
c0d9fda9f5f5 interfaces: make `repository.ilocalrepositorymain` methods abstract
Matt Harbison <matt_harbison@yahoo.com>
parents: 52485
diff changeset
2216 @abc.abstractmethod
52446
c1674551c109 interfaces: add the missing `self` arg to the repository Protocol classes
Matt Harbison <matt_harbison@yahoo.com>
parents: 52445
diff changeset
2217 def branchheads(self, branch=None, start=None, closed=False):
37181
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
2218 pass
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
2219
52486
c0d9fda9f5f5 interfaces: make `repository.ilocalrepositorymain` methods abstract
Matt Harbison <matt_harbison@yahoo.com>
parents: 52485
diff changeset
2220 @abc.abstractmethod
52446
c1674551c109 interfaces: add the missing `self` arg to the repository Protocol classes
Matt Harbison <matt_harbison@yahoo.com>
parents: 52445
diff changeset
2221 def branches(self, nodes):
37181
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
2222 pass
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
2223
52486
c0d9fda9f5f5 interfaces: make `repository.ilocalrepositorymain` methods abstract
Matt Harbison <matt_harbison@yahoo.com>
parents: 52485
diff changeset
2224 @abc.abstractmethod
52446
c1674551c109 interfaces: add the missing `self` arg to the repository Protocol classes
Matt Harbison <matt_harbison@yahoo.com>
parents: 52445
diff changeset
2225 def between(self, pairs):
37181
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
2226 pass
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
2227
52486
c0d9fda9f5f5 interfaces: make `repository.ilocalrepositorymain` methods abstract
Matt Harbison <matt_harbison@yahoo.com>
parents: 52485
diff changeset
2228 @abc.abstractmethod
52446
c1674551c109 interfaces: add the missing `self` arg to the repository Protocol classes
Matt Harbison <matt_harbison@yahoo.com>
parents: 52445
diff changeset
2229 def checkpush(self, pushop):
37181
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
2230 pass
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
2231
52485
dfb60fb155da interfaces: convert `ilocalrepositorymain` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52483
diff changeset
2232 prepushoutgoinghooks: util.hooks
dfb60fb155da interfaces: convert `ilocalrepositorymain` from zope `Attribute` attrs
Matt Harbison <matt_harbison@yahoo.com>
parents: 52483
diff changeset
2233 """util.hooks instance."""
37181
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
2234
52486
c0d9fda9f5f5 interfaces: make `repository.ilocalrepositorymain` methods abstract
Matt Harbison <matt_harbison@yahoo.com>
parents: 52485
diff changeset
2235 @abc.abstractmethod
52446
c1674551c109 interfaces: add the missing `self` arg to the repository Protocol classes
Matt Harbison <matt_harbison@yahoo.com>
parents: 52445
diff changeset
2236 def pushkey(self, namespace, key, old, new):
37181
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
2237 pass
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
2238
52486
c0d9fda9f5f5 interfaces: make `repository.ilocalrepositorymain` methods abstract
Matt Harbison <matt_harbison@yahoo.com>
parents: 52485
diff changeset
2239 @abc.abstractmethod
52446
c1674551c109 interfaces: add the missing `self` arg to the repository Protocol classes
Matt Harbison <matt_harbison@yahoo.com>
parents: 52445
diff changeset
2240 def listkeys(self, namespace):
37181
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
2241 pass
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
2242
52486
c0d9fda9f5f5 interfaces: make `repository.ilocalrepositorymain` methods abstract
Matt Harbison <matt_harbison@yahoo.com>
parents: 52485
diff changeset
2243 @abc.abstractmethod
52446
c1674551c109 interfaces: add the missing `self` arg to the repository Protocol classes
Matt Harbison <matt_harbison@yahoo.com>
parents: 52445
diff changeset
2244 def debugwireargs(self, one, two, three=None, four=None, five=None):
37181
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
2245 pass
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
2246
52486
c0d9fda9f5f5 interfaces: make `repository.ilocalrepositorymain` methods abstract
Matt Harbison <matt_harbison@yahoo.com>
parents: 52485
diff changeset
2247 @abc.abstractmethod
52446
c1674551c109 interfaces: add the missing `self` arg to the repository Protocol classes
Matt Harbison <matt_harbison@yahoo.com>
parents: 52445
diff changeset
2248 def savecommitmessage(self, text):
37181
0dfb5672f015 repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33802
diff changeset
2249 pass
39764
e4e881572382 localrepo: iteratively derive local repository type
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39700
diff changeset
2250
52486
c0d9fda9f5f5 interfaces: make `repository.ilocalrepositorymain` methods abstract
Matt Harbison <matt_harbison@yahoo.com>
parents: 52485
diff changeset
2251 @abc.abstractmethod
47083
81eb7091c494 sidedata: add a way of replacing an existing sidedata computer
Rapha?l Gom?s <rgomes@octobus.net>
parents: 47078
diff changeset
2252 def register_sidedata_computer(
52446
c1674551c109 interfaces: add the missing `self` arg to the repository Protocol classes
Matt Harbison <matt_harbison@yahoo.com>
parents: 52445
diff changeset
2253 self, kind, category, keys, computer, flags, replace=False
47083
81eb7091c494 sidedata: add a way of replacing an existing sidedata computer
Rapha?l Gom?s <rgomes@octobus.net>
parents: 47078
diff changeset
2254 ):
46713
bc2519513ae0 sidedata-exchange: add `wanted_sidedata` and `sidedata_computers` to repos
Rapha?l Gom?s <rgomes@octobus.net>
parents: 46712
diff changeset
2255 pass
bc2519513ae0 sidedata-exchange: add `wanted_sidedata` and `sidedata_computers` to repos
Rapha?l Gom?s <rgomes@octobus.net>
parents: 46712
diff changeset
2256
52486
c0d9fda9f5f5 interfaces: make `repository.ilocalrepositorymain` methods abstract
Matt Harbison <matt_harbison@yahoo.com>
parents: 52485
diff changeset
2257 @abc.abstractmethod
52446
c1674551c109 interfaces: add the missing `self` arg to the repository Protocol classes
Matt Harbison <matt_harbison@yahoo.com>
parents: 52445
diff changeset
2258 def register_wanted_sidedata(self, category):
46713
bc2519513ae0 sidedata-exchange: add `wanted_sidedata` and `sidedata_computers` to repos
Rapha?l Gom?s <rgomes@octobus.net>
parents: 46712
diff changeset
2259 pass
bc2519513ae0 sidedata-exchange: add `wanted_sidedata` and `sidedata_computers` to repos
Rapha?l Gom?s <rgomes@octobus.net>
parents: 46712
diff changeset
2260
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43032
diff changeset
2261
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43032
diff changeset
2262 class completelocalrepository(
52500
3abf9bc10fcc interfaces: mark `completelocalrepository` as a Protocol class
Matt Harbison <matt_harbison@yahoo.com>
parents: 52499
diff changeset
2263 ilocalrepositorymain,
3abf9bc10fcc interfaces: mark `completelocalrepository` as a Protocol class
Matt Harbison <matt_harbison@yahoo.com>
parents: 52499
diff changeset
2264 ilocalrepositoryfilestorage,
3abf9bc10fcc interfaces: mark `completelocalrepository` as a Protocol class
Matt Harbison <matt_harbison@yahoo.com>
parents: 52499
diff changeset
2265 Protocol,
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43032
diff changeset
2266 ):
39764
e4e881572382 localrepo: iteratively derive local repository type
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39700
diff changeset
2267 """Complete interface for a local repository."""
40021
c537144fdbef wireprotov2: support response caching
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40002
diff changeset
2268
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43032
diff changeset
2269
52445
26dd402c3497 interfaces: convert the repository zope interfaces to Protocol classes
Matt Harbison <matt_harbison@yahoo.com>
parents: 52432
diff changeset
2270 class iwireprotocolcommandcacher(Protocol):
40021
c537144fdbef wireprotov2: support response caching
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40002
diff changeset
2271 """Represents a caching backend for wire protocol commands.
c537144fdbef wireprotov2: support response caching
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40002
diff changeset
2272
c537144fdbef wireprotov2: support response caching
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40002
diff changeset
2273 Wire protocol version 2 supports transparent caching of many commands.
c537144fdbef wireprotov2: support response caching
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40002
diff changeset
2274 To leverage this caching, servers can activate objects that cache
c537144fdbef wireprotov2: support response caching
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40002
diff changeset
2275 command responses. Objects handle both cache writing and reading.
c537144fdbef wireprotov2: support response caching
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40002
diff changeset
2276 This interface defines how that response caching mechanism works.
c537144fdbef wireprotov2: support response caching
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40002
diff changeset
2277
c537144fdbef wireprotov2: support response caching
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40002
diff changeset
2278 Wire protocol version 2 commands emit a series of objects that are
c537144fdbef wireprotov2: support response caching
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40002
diff changeset
2279 serialized and sent to the client. The caching layer exists between
c537144fdbef wireprotov2: support response caching
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40002
diff changeset
2280 the invocation of the command function and the sending of its output
c537144fdbef wireprotov2: support response caching
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40002
diff changeset
2281 objects to an output layer.
c537144fdbef wireprotov2: support response caching
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40002
diff changeset
2282
c537144fdbef wireprotov2: support response caching
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40002
diff changeset
2283 Instances of this interface represent a binding to a cache that
c537144fdbef wireprotov2: support response caching
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40002
diff changeset
2284 can serve a response (in place of calling a command function) and/or
c537144fdbef wireprotov2: support response caching
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40002
diff changeset
2285 write responses to a cache for subsequent use.
c537144fdbef wireprotov2: support response caching
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40002
diff changeset
2286
c537144fdbef wireprotov2: support response caching
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40002
diff changeset
2287 When a command request arrives, the following happens with regards
c537144fdbef wireprotov2: support response caching
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40002
diff changeset
2288 to this interface:
c537144fdbef wireprotov2: support response caching
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40002
diff changeset
2289
c537144fdbef wireprotov2: support response caching
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40002
diff changeset
2290 1. The server determines whether the command request is cacheable.
c537144fdbef wireprotov2: support response caching
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40002
diff changeset
2291 2. If it is, an instance of this interface is spawned.
c537144fdbef wireprotov2: support response caching
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40002
diff changeset
2292 3. The cacher is activated in a context manager (``__enter__`` is called).
c537144fdbef wireprotov2: support response caching
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40002
diff changeset
2293 4. A cache *key* for that request is derived. This will call the
c537144fdbef wireprotov2: support response caching
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40002
diff changeset
2294 instance's ``adjustcachekeystate()`` method so the derivation
c537144fdbef wireprotov2: support response caching
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40002
diff changeset
2295 can be influenced.
c537144fdbef wireprotov2: support response caching
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40002
diff changeset
2296 5. The cacher is informed of the derived cache key via a call to
c537144fdbef wireprotov2: support response caching
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40002
diff changeset
2297 ``setcachekey()``.
c537144fdbef wireprotov2: support response caching
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40002
diff changeset
2298 6. The cacher's ``lookup()`` method is called to test for presence of
c537144fdbef wireprotov2: support response caching
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40002
diff changeset
2299 the derived key in the cache.
c537144fdbef wireprotov2: support response caching
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40002
diff changeset
2300 7. If ``lookup()`` returns a hit, that cached result is used in place
c537144fdbef wireprotov2: support response caching
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40002
diff changeset
2301 of invoking the command function. ``__exit__`` is called and the instance
c537144fdbef wireprotov2: support response caching
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40002
diff changeset
2302 is discarded.
c537144fdbef wireprotov2: support response caching
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40002
diff changeset
2303 8. The command function is invoked.
c537144fdbef wireprotov2: support response caching
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40002
diff changeset
2304 9. ``onobject()`` is called for each object emitted by the command
c537144fdbef wireprotov2: support response caching
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40002
diff changeset
2305 function.
40279
4821affc154f wireproto: fix incorrect function name in docstring
Connor Sheehan <sheehan@mozilla.com>
parents: 40171
diff changeset
2306 10. After the final object is seen, ``onfinished()`` is called.
40021
c537144fdbef wireprotov2: support response caching
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40002
diff changeset
2307 11. ``__exit__`` is called to signal the end of use of the instance.
c537144fdbef wireprotov2: support response caching
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40002
diff changeset
2308
c537144fdbef wireprotov2: support response caching
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40002
diff changeset
2309 Cache *key* derivation can be influenced by the instance.
c537144fdbef wireprotov2: support response caching
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40002
diff changeset
2310
c537144fdbef wireprotov2: support response caching
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40002
diff changeset
2311 Cache keys are initially derived by a deterministic representation of
c537144fdbef wireprotov2: support response caching
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40002
diff changeset
2312 the command request. This includes the command name, arguments, protocol
c537144fdbef wireprotov2: support response caching
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40002
diff changeset
2313 version, etc. This initial key derivation is performed by CBOR-encoding a
c537144fdbef wireprotov2: support response caching
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40002
diff changeset
2314 data structure and feeding that output into a hasher.
c537144fdbef wireprotov2: support response caching
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40002
diff changeset
2315
c537144fdbef wireprotov2: support response caching
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40002
diff changeset
2316 Instances of this interface can influence this initial key derivation
c537144fdbef wireprotov2: support response caching
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40002
diff changeset
2317 via ``adjustcachekeystate()``.
c537144fdbef wireprotov2: support response caching
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40002
diff changeset
2318
c537144fdbef wireprotov2: support response caching
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40002
diff changeset
2319 The instance is informed of the derived cache key via a call to
c537144fdbef wireprotov2: support response caching
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40002
diff changeset
2320 ``setcachekey()``. The instance must store the key locally so it can
c537144fdbef wireprotov2: support response caching
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40002
diff changeset
2321 be consulted on subsequent operations that may require it.
c537144fdbef wireprotov2: support response caching
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40002
diff changeset
2322
c537144fdbef wireprotov2: support response caching
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40002
diff changeset
2323 When constructed, the instance has access to a callable that can be used
c537144fdbef wireprotov2: support response caching
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40002
diff changeset
2324 for encoding response objects. This callable receives as its single
c537144fdbef wireprotov2: support response caching
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40002
diff changeset
2325 argument an object emitted by a command function. It returns an iterable
c537144fdbef wireprotov2: support response caching
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40002
diff changeset
2326 of bytes chunks representing the encoded object. Unless the cacher is
c537144fdbef wireprotov2: support response caching
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40002
diff changeset
2327 caching native Python objects in memory or has a way of reconstructing
c537144fdbef wireprotov2: support response caching
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40002
diff changeset
2328 the original Python objects, implementations typically call this function
c537144fdbef wireprotov2: support response caching
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40002
diff changeset
2329 to produce bytes from the output objects and then store those bytes in
c537144fdbef wireprotov2: support response caching
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40002
diff changeset
2330 the cache. When it comes time to re-emit those bytes, they are wrapped
c537144fdbef wireprotov2: support response caching
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40002
diff changeset
2331 in a ``wireprototypes.encodedresponse`` instance to tell the output
c537144fdbef wireprotov2: support response caching
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40002
diff changeset
2332 layer that they are pre-encoded.
c537144fdbef wireprotov2: support response caching
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40002
diff changeset
2333
c537144fdbef wireprotov2: support response caching
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40002
diff changeset
2334 When receiving the objects emitted by the command function, instances
c537144fdbef wireprotov2: support response caching
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40002
diff changeset
2335 can choose what to do with those objects. The simplest thing to do is
c537144fdbef wireprotov2: support response caching
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40002
diff changeset
2336 re-emit the original objects. They will be forwarded to the output
c537144fdbef wireprotov2: support response caching
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40002
diff changeset
2337 layer and will be processed as if the cacher did not exist.
c537144fdbef wireprotov2: support response caching
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40002
diff changeset
2338
c537144fdbef wireprotov2: support response caching
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40002
diff changeset
2339 Implementations could also choose to not emit objects - instead locally
c537144fdbef wireprotov2: support response caching
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40002
diff changeset
2340 buffering objects or their encoded representation. They could then emit
40279
4821affc154f wireproto: fix incorrect function name in docstring
Connor Sheehan <sheehan@mozilla.com>
parents: 40171
diff changeset
2341 a single "coalesced" object when ``onfinished()`` is called. In
40021
c537144fdbef wireprotov2: support response caching
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40002
diff changeset
2342 this way, the implementation would function as a filtering layer of
c537144fdbef wireprotov2: support response caching
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40002
diff changeset
2343 sorts.
c537144fdbef wireprotov2: support response caching
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40002
diff changeset
2344
c537144fdbef wireprotov2: support response caching
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40002
diff changeset
2345 When caching objects, typically the encoded form of the object will
c537144fdbef wireprotov2: support response caching
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40002
diff changeset
2346 be stored. Keep in mind that if the original object is forwarded to
c537144fdbef wireprotov2: support response caching
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40002
diff changeset
2347 the output layer, it will need to be encoded there as well. For large
c537144fdbef wireprotov2: support response caching
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40002
diff changeset
2348 output, this redundant encoding could add overhead. Implementations
c537144fdbef wireprotov2: support response caching
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40002
diff changeset
2349 could wrap the encoded object data in ``wireprototypes.encodedresponse``
c537144fdbef wireprotov2: support response caching
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40002
diff changeset
2350 instances to avoid this overhead.
c537144fdbef wireprotov2: support response caching
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40002
diff changeset
2351 """
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 43032
diff changeset
2352
52499
9358d786af24 interfaces: make all methods on any repository Protocol class abstract
Matt Harbison <matt_harbison@yahoo.com>
parents: 52497
diff changeset
2353 @abc.abstractmethod
52446
c1674551c109 interfaces: add the missing `self` arg to the repository Protocol classes
Matt Harbison <matt_harbison@yahoo.com>
parents: 52445
diff changeset
2354 def __enter__(self):
40021
c537144fdbef wireprotov2: support response caching
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40002
diff changeset
2355 """Marks the instance as active.
c537144fdbef wireprotov2: support response caching
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40002
diff changeset
2356
c537144fdbef wireprotov2: support response caching
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40002
diff changeset
2357 Should return self.
c537144fdbef wireprotov2: support response caching
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40002
diff changeset
2358 """
c537144fdbef wireprotov2: support response caching
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40002
diff changeset
2359
52499
9358d786af24 interfaces: make all methods on any repository Protocol class abstract
Matt Harbison <matt_harbison@yahoo.com>
parents: 52497
diff changeset
2360 @abc.abstractmethod
52446
c1674551c109 interfaces: add the missing `self` arg to the repository Protocol classes
Matt Harbison <matt_harbison@yahoo.com>
parents: 52445
diff changeset
2361 def __exit__(self, exctype, excvalue, exctb):
40021
c537144fdbef wireprotov2: support response caching
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40002
diff changeset
2362 """Called when cacher is no longer used.
c537144fdbef wireprotov2: support response caching
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40002
diff changeset
2363
c537144fdbef wireprotov2: support response caching
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40002
diff changeset
2364 This can be used by implementations to perform cleanup actions (e.g.
c537144fdbef wireprotov2: support response caching
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40002
diff changeset
2365 disconnecting network sockets, aborting a partially cached response.
c537144fdbef wireprotov2: support response caching
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40002
diff changeset
2366 """
c537144fdbef wireprotov2: support response caching
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40002
diff changeset
2367
52499
9358d786af24 interfaces: make all methods on any repository Protocol class abstract
Matt Harbison <matt_harbison@yahoo.com>
parents: 52497
diff changeset
2368 @abc.abstractmethod
52446
c1674551c109 interfaces: add the missing `self` arg to the repository Protocol classes
Matt Harbison <matt_harbison@yahoo.com>
parents: 52445
diff changeset
2369 def adjustcachekeystate(self, state):
40021
c537144fdbef wireprotov2: support response caching
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40002
diff changeset
2370 """Influences cache key derivation by adjusting state to derive key.
c537144fdbef wireprotov2: support response caching
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40002
diff changeset
2371
c537144fdbef wireprotov2: support response caching
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40002
diff changeset
2372 A dict defining the state used to derive the cache key is passed.
c537144fdbef wireprotov2: support response caching
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40002
diff changeset
2373
c537144fdbef wireprotov2: support response caching
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40002
diff changeset
2374 Implementations can modify this dict to record additional state that
c537144fdbef wireprotov2: support response caching
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40002
diff changeset
2375 is wanted to influence key derivation.
c537144fdbef wireprotov2: support response caching
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40002
diff changeset
2376
c537144fdbef wireprotov2: support response caching
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40002
diff changeset
2377 Implementations are *highly* encouraged to not modify or delete
c537144fdbef wireprotov2: support response caching
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40002
diff changeset
2378 existing keys.
c537144fdbef wireprotov2: support response caching
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40002
diff changeset
2379 """
c537144fdbef wireprotov2: support response caching
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40002
diff changeset
2380
52499
9358d786af24 interfaces: make all methods on any repository Protocol class abstract
Matt Harbison <matt_harbison@yahoo.com>
parents: 52497
diff changeset
2381 @abc.abstractmethod
52446
c1674551c109 interfaces: add the missing `self` arg to the repository Protocol classes
Matt Harbison <matt_harbison@yahoo.com>
parents: 52445
diff changeset
2382 def setcachekey(self, key):
40021
c537144fdbef wireprotov2: support response caching
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40002
diff changeset
2383 """Record the derived cache key for this request.
c537144fdbef wireprotov2: support response caching
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40002
diff changeset
2384
c537144fdbef wireprotov2: support response caching
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40002
diff changeset
2385 Instances may mutate the key for internal usage, as desired. e.g.
c537144fdbef wireprotov2: support response caching
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40002
diff changeset
2386 instances may wish to prepend the repo name, introduce path
c537144fdbef wireprotov2: support response caching
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40002
diff changeset
2387 components for filesystem or URL addressing, etc. Behavior is up to
c537144fdbef wireprotov2: support response caching
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40002
diff changeset
2388 the cache.
c537144fdbef wireprotov2: support response caching
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40002
diff changeset
2389
c537144fdbef wireprotov2: support response caching
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40002
diff changeset
2390 Returns a bool indicating if the request is cacheable by this
c537144fdbef wireprotov2: support response caching
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40002
diff changeset
2391 instance.
c537144fdbef wireprotov2: support response caching
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40002
diff changeset
2392 """
c537144fdbef wireprotov2: support response caching
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40002
diff changeset
2393
52499
9358d786af24 interfaces: make all methods on any repository Protocol class abstract
Matt Harbison <matt_harbison@yahoo.com>
parents: 52497
diff changeset
2394 @abc.abstractmethod
52446
c1674551c109 interfaces: add the missing `self` arg to the repository Protocol classes
Matt Harbison <matt_harbison@yahoo.com>
parents: 52445
diff changeset
2395 def lookup(self):
40021
c537144fdbef wireprotov2: support response caching
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40002
diff changeset
2396 """Attempt to resolve an entry in the cache.
c537144fdbef wireprotov2: support response caching
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40002
diff changeset
2397
c537144fdbef wireprotov2: support response caching
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40002
diff changeset
2398 The instance is instructed to look for the cache key that it was
c537144fdbef wireprotov2: support response caching
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40002
diff changeset
2399 informed about via the call to ``setcachekey()``.
c537144fdbef wireprotov2: support response caching
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40002
diff changeset
2400
c537144fdbef wireprotov2: support response caching
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40002
diff changeset
2401 If there's no cache hit or the cacher doesn't wish to use the cached
c537144fdbef wireprotov2: support response caching
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40002
diff changeset
2402 entry, ``None`` should be returned.
c537144fdbef wireprotov2: support response caching
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40002
diff changeset
2403
c537144fdbef wireprotov2: support response caching
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40002
diff changeset
2404 Else, a dict defining the cached result should be returned. The
c537144fdbef wireprotov2: support response caching
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40002
diff changeset
2405 dict may have the following keys:
c537144fdbef wireprotov2: support response caching
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40002
diff changeset
2406
c537144fdbef wireprotov2: support response caching
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40002
diff changeset
2407 objs
c537144fdbef wireprotov2: support response caching
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40002
diff changeset
2408 An iterable of objects that should be sent to the client. That
c537144fdbef wireprotov2: support response caching
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40002
diff changeset
2409 iterable of objects is expected to be what the command function
c537144fdbef wireprotov2: support response caching
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40002
diff changeset
2410 would return if invoked or an equivalent representation thereof.
c537144fdbef wireprotov2: support response caching
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40002
diff changeset
2411 """
c537144fdbef wireprotov2: support response caching
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40002
diff changeset
2412
52499
9358d786af24 interfaces: make all methods on any repository Protocol class abstract
Matt Harbison <matt_harbison@yahoo.com>
parents: 52497
diff changeset
2413 @abc.abstractmethod
52446
c1674551c109 interfaces: add the missing `self` arg to the repository Protocol classes
Matt Harbison <matt_harbison@yahoo.com>
parents: 52445
diff changeset
2414 def onobject(self, obj):
40021
c537144fdbef wireprotov2: support response caching
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40002
diff changeset
2415 """Called when a new object is emitted from the command function.
c537144fdbef wireprotov2: support response caching
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40002
diff changeset
2416
c537144fdbef wireprotov2: support response caching
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40002
diff changeset
2417 Receives as its argument the object that was emitted from the
c537144fdbef wireprotov2: support response caching
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40002
diff changeset
2418 command function.
c537144fdbef wireprotov2: support response caching
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40002
diff changeset
2419
c537144fdbef wireprotov2: support response caching
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40002
diff changeset
2420 This method returns an iterator of objects to forward to the output
c537144fdbef wireprotov2: support response caching
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40002
diff changeset
2421 layer. The easiest implementation is a generator that just
c537144fdbef wireprotov2: support response caching
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40002
diff changeset
2422 ``yield obj``.
c537144fdbef wireprotov2: support response caching
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40002
diff changeset
2423 """
c537144fdbef wireprotov2: support response caching
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40002
diff changeset
2424
52499
9358d786af24 interfaces: make all methods on any repository Protocol class abstract
Matt Harbison <matt_harbison@yahoo.com>
parents: 52497
diff changeset
2425 @abc.abstractmethod
52446
c1674551c109 interfaces: add the missing `self` arg to the repository Protocol classes
Matt Harbison <matt_harbison@yahoo.com>
parents: 52445
diff changeset
2426 def onfinished(self):
40021
c537144fdbef wireprotov2: support response caching
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40002
diff changeset
2427 """Called after all objects have been emitted from the command function.
c537144fdbef wireprotov2: support response caching
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40002
diff changeset
2428
c537144fdbef wireprotov2: support response caching
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40002
diff changeset
2429 Implementations should return an iterator of objects to forward to
c537144fdbef wireprotov2: support response caching
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40002
diff changeset
2430 the output layer.
c537144fdbef wireprotov2: support response caching
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40002
diff changeset
2431
c537144fdbef wireprotov2: support response caching
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40002
diff changeset
2432 This method can be a generator.
c537144fdbef wireprotov2: support response caching
Gregory Szorc <gregory.szorc@gmail.com>
parents: 40002
diff changeset
2433 """