Mercurial > hg
annotate mercurial/interfaces/repository.py @ 50440:3a2df812e1c7
pull: add --remote-hidden option and pass it through peer creation
This option will allow to pull changesets that are hidden on the remote. This
is useful when looking into a changeset’s evolution history, resolving
evolution instability or mirroring a repository.
The option is best effort and will only affect the pull when it can. The option
will be ignored when it cannot be honored.
Support for each type of peer is yet to be implemented. They currently all warn
about lack of support. The warning code will get removed as peers gain
support for this option.
The option is still experimental, so we will have freedom to update the UI or
implementation before it graduates out of experimental.
Based on a changeset by Pierre-Yves David, which added the option.
author | Manuel Jacob <me@manueljacob.de> |
---|---|
date | Thu, 04 Apr 2019 18:07:30 +0200 |
parents | 6901916458bd |
children | 32837c7e2e4b |
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. |
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
|
2 # coding: utf-8 |
33800
f257943e47ab
repository: formalize peer interface with abstract base class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
3 # |
f257943e47ab
repository: formalize peer interface with abstract base class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
4 # 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
|
5 # |
f257943e47ab
repository: formalize peer interface with abstract base class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
6 # 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
|
7 # 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
|
8 |
f257943e47ab
repository: formalize peer interface with abstract base class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
9 |
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
|
10 from ..i18n import _ |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43032
diff
changeset
|
11 from .. import error |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43032
diff
changeset
|
12 from . import util as interfaceutil |
33802
a0aad86b3b6a
repository: implement generic capability methods on peer class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33801
diff
changeset
|
13 |
39850
d89d5bc06eaa
localrepo: define "features" on repository instances (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39844
diff
changeset
|
14 # Local repository feature string. |
d89d5bc06eaa
localrepo: define "features" on repository instances (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39844
diff
changeset
|
15 |
d89d5bc06eaa
localrepo: define "features" on repository instances (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39844
diff
changeset
|
16 # 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
|
17 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
|
18 # 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
|
19 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
|
20 # 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
|
21 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
|
22 # 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
|
23 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
|
24 # 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
|
25 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
|
26 # 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
|
27 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
|
28 |
40047
8e398628a3f2
repository: define and use revision flag constants
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40027
diff
changeset
|
29 REVISION_FLAG_CENSORED = 1 << 15 |
8e398628a3f2
repository: define and use revision flag constants
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40027
diff
changeset
|
30 REVISION_FLAG_ELLIPSIS = 1 << 14 |
8e398628a3f2
repository: define and use revision flag constants
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40027
diff
changeset
|
31 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
|
32 REVISION_FLAG_HASCOPIESINFO = 1 << 12 |
40047
8e398628a3f2
repository: define and use revision flag constants
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40027
diff
changeset
|
33 |
8e398628a3f2
repository: define and use revision flag constants
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40027
diff
changeset
|
34 REVISION_FLAGS_KNOWN = ( |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43032
diff
changeset
|
35 REVISION_FLAG_CENSORED |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43032
diff
changeset
|
36 | REVISION_FLAG_ELLIPSIS |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43032
diff
changeset
|
37 | 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
|
38 | 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
|
39 ) |
40047
8e398628a3f2
repository: define and use revision flag constants
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40027
diff
changeset
|
40 |
40427
59a870a4ad6e
changegroup: refactor emitrevision to use a `deltamode` argument
Boris Feld <boris.feld@octobus.net>
parents:
40390
diff
changeset
|
41 CG_DELTAMODE_STD = b'default' |
59a870a4ad6e
changegroup: refactor emitrevision to use a `deltamode` argument
Boris Feld <boris.feld@octobus.net>
parents:
40390
diff
changeset
|
42 CG_DELTAMODE_PREV = b'previous' |
59a870a4ad6e
changegroup: refactor emitrevision to use a `deltamode` argument
Boris Feld <boris.feld@octobus.net>
parents:
40390
diff
changeset
|
43 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
|
44 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
|
45 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43032
diff
changeset
|
46 |
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
|
47 ## 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
|
48 # |
d1589957fdcb
updatecaches: introduce a set of constants to control which are updated
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47226
diff
changeset
|
49 # 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
|
50 |
d1589957fdcb
updatecaches: introduce a set of constants to control which are updated
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47226
diff
changeset
|
51 # 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
|
52 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
|
53 # 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
|
54 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
|
55 # 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
|
56 CACHE_CHANGELOG_CACHE = b"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
|
57 # 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
|
58 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
|
59 # 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
|
60 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
|
61 # 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
|
62 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
|
63 # 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
|
64 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
|
65 # 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
|
66 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
|
67 # 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
|
68 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
|
69 |
d1589957fdcb
updatecaches: introduce a set of constants to control which are updated
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47226
diff
changeset
|
70 # 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
|
71 # (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
|
72 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
|
73 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
|
74 } |
d1589957fdcb
updatecaches: introduce a set of constants to control which are updated
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47226
diff
changeset
|
75 |
d1589957fdcb
updatecaches: introduce a set of constants to control which are updated
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47226
diff
changeset
|
76 # 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
|
77 # (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
|
78 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
|
79 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
|
80 CACHE_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
|
81 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
|
82 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
|
83 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
|
84 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
|
85 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
|
86 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
|
87 } |
d1589957fdcb
updatecaches: introduce a set of constants to control which are updated
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47226
diff
changeset
|
88 |
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
|
89 # 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
|
90 # (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
|
91 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
|
92 CACHES_POST_CLONE.discard(CACHE_FILE_NODE_TAGS) |
7edaf91c7886
updatecaches: use the `caches` argument instead of a special `full` value
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47296
diff
changeset
|
93 |
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
|
94 |
37810
856f381ad74b
interfaceutil: module to stub out zope.interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37650
diff
changeset
|
95 class ipeerconnection(interfaceutil.Interface): |
33800
f257943e47ab
repository: formalize peer interface with abstract base class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
96 """Represents a "connection" to a repository. |
f257943e47ab
repository: formalize peer interface with abstract base class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
97 |
f257943e47ab
repository: formalize peer interface with abstract base class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
98 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
|
99 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
|
100 |
f257943e47ab
repository: formalize peer interface with abstract base class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
101 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
|
102 outside of this module. |
f257943e47ab
repository: formalize peer interface with abstract base class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
103 """ |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43032
diff
changeset
|
104 |
37810
856f381ad74b
interfaceutil: module to stub out zope.interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37650
diff
changeset
|
105 ui = interfaceutil.Attribute("""ui.ui instance""") |
49752
611ccb631cbc
peer: add a `path` attribute to peer
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49751
diff
changeset
|
106 path = interfaceutil.Attribute("""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
|
107 |
37320
39f7d4ee8bcd
repository: port peer interfaces to zope.interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37316
diff
changeset
|
108 def url(): |
33800
f257943e47ab
repository: formalize peer interface with abstract base class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
109 """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
|
110 |
f257943e47ab
repository: formalize peer interface with abstract base class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
111 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
|
112 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
|
113 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
|
114 data leakage. |
f257943e47ab
repository: formalize peer interface with abstract base class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
115 |
f257943e47ab
repository: formalize peer interface with abstract base class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
116 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
|
117 value. |
f257943e47ab
repository: formalize peer interface with abstract base class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
118 """ |
f257943e47ab
repository: formalize peer interface with abstract base class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
119 |
37320
39f7d4ee8bcd
repository: port peer interfaces to zope.interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37316
diff
changeset
|
120 def local(): |
33800
f257943e47ab
repository: formalize peer interface with abstract base class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
121 """Returns a local repository instance. |
f257943e47ab
repository: formalize peer interface with abstract base class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
122 |
f257943e47ab
repository: formalize peer interface with abstract base class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
123 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
|
124 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
|
125 """ |
f257943e47ab
repository: formalize peer interface with abstract base class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
126 |
37320
39f7d4ee8bcd
repository: port peer interfaces to zope.interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37316
diff
changeset
|
127 def canpush(): |
33800
f257943e47ab
repository: formalize peer interface with abstract base class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
128 """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
|
129 |
37320
39f7d4ee8bcd
repository: port peer interfaces to zope.interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37316
diff
changeset
|
130 def close(): |
33800
f257943e47ab
repository: formalize peer interface with abstract base class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
131 """Close the connection to this peer. |
f257943e47ab
repository: formalize peer interface with abstract base class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
132 |
f257943e47ab
repository: formalize peer interface with abstract base class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
133 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
|
134 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
|
135 """ |
f257943e47ab
repository: formalize peer interface with abstract base class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
136 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43032
diff
changeset
|
137 |
37810
856f381ad74b
interfaceutil: module to stub out zope.interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37650
diff
changeset
|
138 class ipeercapabilities(interfaceutil.Interface): |
37610
98861a2298b5
repository: split capabilities methods into separate interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37440
diff
changeset
|
139 """Peer sub-interface related to capabilities.""" |
98861a2298b5
repository: split capabilities methods into separate interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37440
diff
changeset
|
140 |
98861a2298b5
repository: split capabilities methods into separate interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37440
diff
changeset
|
141 def capable(name): |
98861a2298b5
repository: split capabilities methods into separate interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37440
diff
changeset
|
142 """Determine support for a named capability. |
98861a2298b5
repository: split capabilities methods into separate interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37440
diff
changeset
|
143 |
98861a2298b5
repository: split capabilities methods into separate interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37440
diff
changeset
|
144 Returns ``False`` if capability not supported. |
98861a2298b5
repository: split capabilities methods into separate interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37440
diff
changeset
|
145 |
98861a2298b5
repository: split capabilities methods into separate interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37440
diff
changeset
|
146 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
|
147 if capability support is non-boolean. |
98861a2298b5
repository: split capabilities methods into separate interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37440
diff
changeset
|
148 |
98861a2298b5
repository: split capabilities methods into separate interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37440
diff
changeset
|
149 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
|
150 """ |
98861a2298b5
repository: split capabilities methods into separate interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37440
diff
changeset
|
151 |
98861a2298b5
repository: split capabilities methods into separate interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37440
diff
changeset
|
152 def requirecap(name, purpose): |
98861a2298b5
repository: split capabilities methods into separate interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37440
diff
changeset
|
153 """Require a capability to be present. |
98861a2298b5
repository: split capabilities methods into separate interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37440
diff
changeset
|
154 |
98861a2298b5
repository: split capabilities methods into separate interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37440
diff
changeset
|
155 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
|
156 """ |
98861a2298b5
repository: split capabilities methods into separate interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37440
diff
changeset
|
157 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43032
diff
changeset
|
158 |
37810
856f381ad74b
interfaceutil: module to stub out zope.interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37650
diff
changeset
|
159 class ipeercommands(interfaceutil.Interface): |
33801
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33800
diff
changeset
|
160 """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
|
161 |
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33800
diff
changeset
|
162 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
|
163 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
|
164 """ |
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33800
diff
changeset
|
165 |
37320
39f7d4ee8bcd
repository: port peer interfaces to zope.interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37316
diff
changeset
|
166 def branchmap(): |
33801
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33800
diff
changeset
|
167 """Obtain heads in named branches. |
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33800
diff
changeset
|
168 |
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33800
diff
changeset
|
169 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
|
170 heads on that branch. |
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33800
diff
changeset
|
171 """ |
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33800
diff
changeset
|
172 |
37320
39f7d4ee8bcd
repository: port peer interfaces to zope.interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37316
diff
changeset
|
173 def capabilities(): |
33801
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33800
diff
changeset
|
174 """Obtain capabilities of the peer. |
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33800
diff
changeset
|
175 |
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33800
diff
changeset
|
176 Returns a set of string capabilities. |
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33800
diff
changeset
|
177 """ |
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33800
diff
changeset
|
178 |
37649
a168799687e5
wireproto: properly call clonebundles command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37635
diff
changeset
|
179 def clonebundles(): |
a168799687e5
wireproto: properly call clonebundles command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37635
diff
changeset
|
180 """Obtains the clone bundles manifest for the repo. |
a168799687e5
wireproto: properly call clonebundles command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37635
diff
changeset
|
181 |
a168799687e5
wireproto: properly call clonebundles command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37635
diff
changeset
|
182 Returns the manifest as unparsed bytes. |
a168799687e5
wireproto: properly call clonebundles command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37635
diff
changeset
|
183 """ |
a168799687e5
wireproto: properly call clonebundles command
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37635
diff
changeset
|
184 |
37320
39f7d4ee8bcd
repository: port peer interfaces to zope.interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37316
diff
changeset
|
185 def debugwireargs(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
|
186 """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
|
187 |
37320
39f7d4ee8bcd
repository: port peer interfaces to zope.interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37316
diff
changeset
|
188 def getbundle(source, **kwargs): |
33801
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33800
diff
changeset
|
189 """Obtain remote repository data as a bundle. |
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33800
diff
changeset
|
190 |
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33800
diff
changeset
|
191 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
|
192 the peer to the local repository |
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33800
diff
changeset
|
193 |
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33800
diff
changeset
|
194 Returns a generator of bundle data. |
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33800
diff
changeset
|
195 """ |
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33800
diff
changeset
|
196 |
37320
39f7d4ee8bcd
repository: port peer interfaces to zope.interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37316
diff
changeset
|
197 def heads(): |
33801
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33800
diff
changeset
|
198 """Determine all known head revisions in the peer. |
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33800
diff
changeset
|
199 |
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33800
diff
changeset
|
200 Returns an iterable of binary nodes. |
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33800
diff
changeset
|
201 """ |
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33800
diff
changeset
|
202 |
37320
39f7d4ee8bcd
repository: port peer interfaces to zope.interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37316
diff
changeset
|
203 def known(nodes): |
33801
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33800
diff
changeset
|
204 """Determine whether multiple nodes are known. |
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33800
diff
changeset
|
205 |
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33800
diff
changeset
|
206 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
|
207 |
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33800
diff
changeset
|
208 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
|
209 at that index is known to the peer. |
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33800
diff
changeset
|
210 """ |
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33800
diff
changeset
|
211 |
37320
39f7d4ee8bcd
repository: port peer interfaces to zope.interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37316
diff
changeset
|
212 def listkeys(namespace): |
33801
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33800
diff
changeset
|
213 """Obtain all keys in a pushkey namespace. |
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33800
diff
changeset
|
214 |
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33800
diff
changeset
|
215 Returns an iterable of key names. |
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33800
diff
changeset
|
216 """ |
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33800
diff
changeset
|
217 |
37320
39f7d4ee8bcd
repository: port peer interfaces to zope.interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37316
diff
changeset
|
218 def lookup(key): |
33801
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33800
diff
changeset
|
219 """Resolve a value to a known revision. |
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33800
diff
changeset
|
220 |
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33800
diff
changeset
|
221 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
|
222 """ |
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33800
diff
changeset
|
223 |
37320
39f7d4ee8bcd
repository: port peer interfaces to zope.interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37316
diff
changeset
|
224 def pushkey(namespace, key, old, new): |
33801
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33800
diff
changeset
|
225 """Set a value using the ``pushkey`` protocol. |
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33800
diff
changeset
|
226 |
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33800
diff
changeset
|
227 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
|
228 the old and new values for that key. |
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33800
diff
changeset
|
229 |
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33800
diff
changeset
|
230 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
|
231 namespace. |
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33800
diff
changeset
|
232 """ |
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33800
diff
changeset
|
233 |
37320
39f7d4ee8bcd
repository: port peer interfaces to zope.interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37316
diff
changeset
|
234 def stream_out(): |
33801
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33800
diff
changeset
|
235 """Obtain streaming clone data. |
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 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
|
238 """ |
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33800
diff
changeset
|
239 |
37320
39f7d4ee8bcd
repository: port peer interfaces to zope.interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37316
diff
changeset
|
240 def unbundle(bundle, heads, url): |
33801
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33800
diff
changeset
|
241 """Transfer repository data to the peer. |
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33800
diff
changeset
|
242 |
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33800
diff
changeset
|
243 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
|
244 |
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33800
diff
changeset
|
245 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
|
246 """ |
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33800
diff
changeset
|
247 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43032
diff
changeset
|
248 |
37810
856f381ad74b
interfaceutil: module to stub out zope.interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37650
diff
changeset
|
249 class ipeerlegacycommands(interfaceutil.Interface): |
33801
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33800
diff
changeset
|
250 """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
|
251 |
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33800
diff
changeset
|
252 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
|
253 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
|
254 legacy, the interfaces are split. |
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33800
diff
changeset
|
255 """ |
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33800
diff
changeset
|
256 |
37320
39f7d4ee8bcd
repository: port peer interfaces to zope.interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37316
diff
changeset
|
257 def between(pairs): |
33801
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33800
diff
changeset
|
258 """Obtain nodes between pairs of nodes. |
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 ``pairs`` is an iterable of node pairs. |
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33800
diff
changeset
|
261 |
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33800
diff
changeset
|
262 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
|
263 requested pair. |
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 |
37320
39f7d4ee8bcd
repository: port peer interfaces to zope.interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37316
diff
changeset
|
266 def branches(nodes): |
33801
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33800
diff
changeset
|
267 """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
|
268 |
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33800
diff
changeset
|
269 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
|
270 a DAG root or is a merge. |
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 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
|
273 """ |
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33800
diff
changeset
|
274 |
37635
cc8c06835097
wireproto: convert legacy commands to command executor
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37633
diff
changeset
|
275 def changegroup(nodes, source): |
33801
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33800
diff
changeset
|
276 """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
|
277 |
37635
cc8c06835097
wireproto: convert legacy commands to command executor
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37633
diff
changeset
|
278 def changegroupsubset(bases, heads, source): |
33801
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33800
diff
changeset
|
279 pass |
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33800
diff
changeset
|
280 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43032
diff
changeset
|
281 |
37810
856f381ad74b
interfaceutil: module to stub out zope.interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37650
diff
changeset
|
282 class ipeercommandexecutor(interfaceutil.Interface): |
37629
fa0382088993
repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37610
diff
changeset
|
283 """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
|
284 |
fa0382088993
repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37610
diff
changeset
|
285 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
|
286 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
|
287 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
|
288 outstanding requests are waited on. |
fa0382088993
repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37610
diff
changeset
|
289 """ |
fa0382088993
repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37610
diff
changeset
|
290 |
fa0382088993
repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37610
diff
changeset
|
291 def callcommand(name, args): |
fa0382088993
repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37610
diff
changeset
|
292 """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
|
293 |
fa0382088993
repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37610
diff
changeset
|
294 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
|
295 |
fa0382088993
repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37610
diff
changeset
|
296 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
|
297 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
|
298 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
|
299 |
fa0382088993
repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37610
diff
changeset
|
300 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
|
301 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
|
302 used and the command itself. |
fa0382088993
repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37610
diff
changeset
|
303 |
fa0382088993
repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37610
diff
changeset
|
304 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
|
305 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
|
306 |
fa0382088993
repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37610
diff
changeset
|
307 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
|
308 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
|
309 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
|
310 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
|
311 """ |
fa0382088993
repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37610
diff
changeset
|
312 |
fa0382088993
repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37610
diff
changeset
|
313 def sendcommands(): |
fa0382088993
repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37610
diff
changeset
|
314 """Trigger submission of queued command requests. |
fa0382088993
repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37610
diff
changeset
|
315 |
fa0382088993
repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37610
diff
changeset
|
316 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
|
317 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
|
318 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
|
319 |
fa0382088993
repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37610
diff
changeset
|
320 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
|
321 """ |
fa0382088993
repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37610
diff
changeset
|
322 |
fa0382088993
repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37610
diff
changeset
|
323 def close(): |
fa0382088993
repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37610
diff
changeset
|
324 """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
|
325 |
fa0382088993
repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37610
diff
changeset
|
326 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
|
327 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
|
328 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
|
329 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
|
330 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
|
331 to finish. |
fa0382088993
repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37610
diff
changeset
|
332 |
fa0382088993
repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37610
diff
changeset
|
333 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
|
334 context manager. |
fa0382088993
repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37610
diff
changeset
|
335 |
fa0382088993
repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37610
diff
changeset
|
336 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
|
337 """ |
fa0382088993
repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37610
diff
changeset
|
338 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43032
diff
changeset
|
339 |
37810
856f381ad74b
interfaceutil: module to stub out zope.interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37650
diff
changeset
|
340 class ipeerrequests(interfaceutil.Interface): |
37629
fa0382088993
repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37610
diff
changeset
|
341 """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
|
342 |
42158
69921d02daaf
peer: introduce a limitedarguments attributes
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
41315
diff
changeset
|
343 limitedarguments = interfaceutil.Attribute( |
69921d02daaf
peer: introduce a limitedarguments attributes
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
41315
diff
changeset
|
344 """True if the peer cannot receive large argument value for commands.""" |
69921d02daaf
peer: introduce a limitedarguments attributes
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
41315
diff
changeset
|
345 ) |
69921d02daaf
peer: introduce a limitedarguments attributes
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
41315
diff
changeset
|
346 |
37629
fa0382088993
repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37610
diff
changeset
|
347 def commandexecutor(): |
fa0382088993
repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37610
diff
changeset
|
348 """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
|
349 |
fa0382088993
repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37610
diff
changeset
|
350 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
|
351 to the peer. |
fa0382088993
repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37610
diff
changeset
|
352 |
fa0382088993
repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37610
diff
changeset
|
353 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
|
354 requests. |
fa0382088993
repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37610
diff
changeset
|
355 |
fa0382088993
repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37610
diff
changeset
|
356 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
|
357 (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
|
358 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
|
359 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
|
360 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
|
361 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
|
362 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
|
363 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
|
364 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
|
365 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
|
366 being issued. |
fa0382088993
repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37610
diff
changeset
|
367 """ |
fa0382088993
repository: define new interface for running commands
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37610
diff
changeset
|
368 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43032
diff
changeset
|
369 |
37650
62ebfda864de
repository: remove ipeercommands from ipeerbase
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37649
diff
changeset
|
370 class ipeerbase(ipeerconnection, ipeercapabilities, ipeerrequests): |
37320
39f7d4ee8bcd
repository: port peer interfaces to zope.interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37316
diff
changeset
|
371 """Unified interface for peer repositories. |
33800
f257943e47ab
repository: formalize peer interface with abstract base class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff
changeset
|
372 |
37320
39f7d4ee8bcd
repository: port peer interfaces to zope.interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37316
diff
changeset
|
373 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
|
374 """ |
33801
558f5b2ee10e
repository: formalize wire protocol interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33800
diff
changeset
|
375 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43032
diff
changeset
|
376 |
40171
dac438b7346e
httppeer: expose API descriptor on httpv2peer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40047
diff
changeset
|
377 class ipeerv2(ipeerconnection, ipeercapabilities, ipeerrequests): |
dac438b7346e
httppeer: expose API descriptor on httpv2peer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40047
diff
changeset
|
378 """Unified peer interface for wire protocol version 2 peers.""" |
dac438b7346e
httppeer: expose API descriptor on httpv2peer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40047
diff
changeset
|
379 |
dac438b7346e
httppeer: expose API descriptor on httpv2peer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40047
diff
changeset
|
380 apidescriptor = interfaceutil.Attribute( |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43032
diff
changeset
|
381 """Data structure holding description of server API.""" |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43032
diff
changeset
|
382 ) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43032
diff
changeset
|
383 |
40171
dac438b7346e
httppeer: expose API descriptor on httpv2peer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40047
diff
changeset
|
384 |
37810
856f381ad74b
interfaceutil: module to stub out zope.interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37650
diff
changeset
|
385 @interfaceutil.implementer(ipeerbase) |
48946
642e31cb55f0
py3: use class X: instead of class X(object):
Gregory Szorc <gregory.szorc@gmail.com>
parents:
48875
diff
changeset
|
386 class peer: |
37320
39f7d4ee8bcd
repository: port peer interfaces to zope.interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37316
diff
changeset
|
387 """Base class for peer repositories.""" |
39f7d4ee8bcd
repository: port peer interfaces to zope.interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37316
diff
changeset
|
388 |
42158
69921d02daaf
peer: introduce a limitedarguments attributes
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
41315
diff
changeset
|
389 limitedarguments = False |
69921d02daaf
peer: introduce a limitedarguments attributes
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
41315
diff
changeset
|
390 |
50440
3a2df812e1c7
pull: add --remote-hidden option and pass it through peer creation
Manuel Jacob <me@manueljacob.de>
parents:
50323
diff
changeset
|
391 def __init__(self, ui, path=None, remotehidden=False): |
49751
a6e2a668c746
peer: have a common constructor and use it
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49748
diff
changeset
|
392 self.ui = ui |
49752
611ccb631cbc
peer: add a `path` attribute to peer
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49751
diff
changeset
|
393 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
|
394 |
37320
39f7d4ee8bcd
repository: port peer interfaces to zope.interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37316
diff
changeset
|
395 def capable(self, name): |
33802
a0aad86b3b6a
repository: implement generic capability methods on peer class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33801
diff
changeset
|
396 caps = self.capabilities() |
a0aad86b3b6a
repository: implement generic capability methods on peer class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33801
diff
changeset
|
397 if name in caps: |
a0aad86b3b6a
repository: implement generic capability methods on peer class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33801
diff
changeset
|
398 return True |
a0aad86b3b6a
repository: implement generic capability methods on peer class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33801
diff
changeset
|
399 |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
400 name = b'%s=' % name |
33802
a0aad86b3b6a
repository: implement generic capability methods on peer class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33801
diff
changeset
|
401 for cap in caps: |
a0aad86b3b6a
repository: implement generic capability methods on peer class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33801
diff
changeset
|
402 if cap.startswith(name): |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43032
diff
changeset
|
403 return cap[len(name) :] |
33802
a0aad86b3b6a
repository: implement generic capability methods on peer class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33801
diff
changeset
|
404 |
a0aad86b3b6a
repository: implement generic capability methods on peer class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33801
diff
changeset
|
405 return False |
a0aad86b3b6a
repository: implement generic capability methods on peer class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33801
diff
changeset
|
406 |
a0aad86b3b6a
repository: implement generic capability methods on peer class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33801
diff
changeset
|
407 def requirecap(self, name, purpose): |
a0aad86b3b6a
repository: implement generic capability methods on peer class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33801
diff
changeset
|
408 if self.capable(name): |
a0aad86b3b6a
repository: implement generic capability methods on peer class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33801
diff
changeset
|
409 return |
a0aad86b3b6a
repository: implement generic capability methods on peer class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33801
diff
changeset
|
410 |
a0aad86b3b6a
repository: implement generic capability methods on peer class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33801
diff
changeset
|
411 raise error.CapabilityError( |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43032
diff
changeset
|
412 _( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
413 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
|
414 b'\'%s\' capability' |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43032
diff
changeset
|
415 ) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43032
diff
changeset
|
416 % (purpose, name) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43032
diff
changeset
|
417 ) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43032
diff
changeset
|
418 |
33802
a0aad86b3b6a
repository: implement generic capability methods on peer class
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33801
diff
changeset
|
419 |
39842
97986c9c69d3
verify: start to abstract file verification
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39785
diff
changeset
|
420 class iverifyproblem(interfaceutil.Interface): |
97986c9c69d3
verify: start to abstract file verification
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39785
diff
changeset
|
421 """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
|
422 |
97986c9c69d3
verify: start to abstract file verification
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39785
diff
changeset
|
423 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
|
424 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
|
425 |
97986c9c69d3
verify: start to abstract file verification
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39785
diff
changeset
|
426 Instances are essentially messages associated with severity. |
97986c9c69d3
verify: start to abstract file verification
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39785
diff
changeset
|
427 """ |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43032
diff
changeset
|
428 |
39842
97986c9c69d3
verify: start to abstract file verification
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39785
diff
changeset
|
429 warning = interfaceutil.Attribute( |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43032
diff
changeset
|
430 """Message indicating a non-fatal problem.""" |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43032
diff
changeset
|
431 ) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43032
diff
changeset
|
432 |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43032
diff
changeset
|
433 error = interfaceutil.Attribute("""Message indicating a fatal problem.""") |
39842
97986c9c69d3
verify: start to abstract file verification
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39785
diff
changeset
|
434 |
39872
733db72f0f54
revlog: move revision verification out of verify
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39869
diff
changeset
|
435 node = interfaceutil.Attribute( |
733db72f0f54
revlog: move revision verification out of verify
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39869
diff
changeset
|
436 """Revision encountering the problem. |
733db72f0f54
revlog: move revision verification out of verify
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39869
diff
changeset
|
437 |
733db72f0f54
revlog: move revision verification out of verify
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39869
diff
changeset
|
438 ``None`` means the problem doesn't apply to a single revision. |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43032
diff
changeset
|
439 """ |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43032
diff
changeset
|
440 ) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43032
diff
changeset
|
441 |
39872
733db72f0f54
revlog: move revision verification out of verify
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39869
diff
changeset
|
442 |
39230
b518d495a560
repository: formalize interfaces for revision deltas and requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38835
diff
changeset
|
443 class irevisiondelta(interfaceutil.Interface): |
b518d495a560
repository: formalize interfaces for revision deltas and requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38835
diff
changeset
|
444 """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
|
445 |
b518d495a560
repository: formalize interfaces for revision deltas and requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38835
diff
changeset
|
446 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
|
447 with another repository. |
b518d495a560
repository: formalize interfaces for revision deltas and requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38835
diff
changeset
|
448 |
b518d495a560
repository: formalize interfaces for revision deltas and requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38835
diff
changeset
|
449 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
|
450 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
|
451 are mutually exclusive. |
b518d495a560
repository: formalize interfaces for revision deltas and requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38835
diff
changeset
|
452 |
b518d495a560
repository: formalize interfaces for revision deltas and requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38835
diff
changeset
|
453 Typically used for changegroup generation. |
b518d495a560
repository: formalize interfaces for revision deltas and requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38835
diff
changeset
|
454 """ |
b518d495a560
repository: formalize interfaces for revision deltas and requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38835
diff
changeset
|
455 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43032
diff
changeset
|
456 node = interfaceutil.Attribute("""20 byte node of this revision.""") |
39230
b518d495a560
repository: formalize interfaces for revision deltas and requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38835
diff
changeset
|
457 |
b518d495a560
repository: formalize interfaces for revision deltas and requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38835
diff
changeset
|
458 p1node = interfaceutil.Attribute( |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43032
diff
changeset
|
459 """20 byte node of 1st parent of this revision.""" |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43032
diff
changeset
|
460 ) |
39230
b518d495a560
repository: formalize interfaces for revision deltas and requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38835
diff
changeset
|
461 |
b518d495a560
repository: formalize interfaces for revision deltas and requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38835
diff
changeset
|
462 p2node = interfaceutil.Attribute( |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43032
diff
changeset
|
463 """20 byte node of 2nd parent of this revision.""" |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43032
diff
changeset
|
464 ) |
39230
b518d495a560
repository: formalize interfaces for revision deltas and requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38835
diff
changeset
|
465 |
b518d495a560
repository: formalize interfaces for revision deltas and requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38835
diff
changeset
|
466 linknode = interfaceutil.Attribute( |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43032
diff
changeset
|
467 """20 byte node of the changelog revision this node is linked to.""" |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43032
diff
changeset
|
468 ) |
39230
b518d495a560
repository: formalize interfaces for revision deltas and requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38835
diff
changeset
|
469 |
b518d495a560
repository: formalize interfaces for revision deltas and requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38835
diff
changeset
|
470 flags = interfaceutil.Attribute( |
40047
8e398628a3f2
repository: define and use revision flag constants
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40027
diff
changeset
|
471 """2 bytes of integer flags that apply to this revision. |
8e398628a3f2
repository: define and use revision flag constants
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40027
diff
changeset
|
472 |
8e398628a3f2
repository: define and use revision flag constants
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40027
diff
changeset
|
473 This is a bitwise composition of the ``REVISION_FLAG_*`` constants. |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43032
diff
changeset
|
474 """ |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43032
diff
changeset
|
475 ) |
39230
b518d495a560
repository: formalize interfaces for revision deltas and requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38835
diff
changeset
|
476 |
b518d495a560
repository: formalize interfaces for revision deltas and requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38835
diff
changeset
|
477 basenode = interfaceutil.Attribute( |
b518d495a560
repository: formalize interfaces for revision deltas and requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38835
diff
changeset
|
478 """20 byte node of the revision this data is a delta against. |
b518d495a560
repository: formalize interfaces for revision deltas and requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38835
diff
changeset
|
479 |
b518d495a560
repository: formalize interfaces for revision deltas and requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38835
diff
changeset
|
480 ``nullid`` indicates that the revision is a full revision and not |
b518d495a560
repository: formalize interfaces for revision deltas and requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38835
diff
changeset
|
481 a delta. |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43032
diff
changeset
|
482 """ |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43032
diff
changeset
|
483 ) |
39230
b518d495a560
repository: formalize interfaces for revision deltas and requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38835
diff
changeset
|
484 |
b518d495a560
repository: formalize interfaces for revision deltas and requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38835
diff
changeset
|
485 baserevisionsize = interfaceutil.Attribute( |
b518d495a560
repository: formalize interfaces for revision deltas and requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38835
diff
changeset
|
486 """Size of base revision this delta is against. |
b518d495a560
repository: formalize interfaces for revision deltas and requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38835
diff
changeset
|
487 |
b518d495a560
repository: formalize interfaces for revision deltas and requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38835
diff
changeset
|
488 May be ``None`` if ``basenode`` is ``nullid``. |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43032
diff
changeset
|
489 """ |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43032
diff
changeset
|
490 ) |
39230
b518d495a560
repository: formalize interfaces for revision deltas and requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38835
diff
changeset
|
491 |
b518d495a560
repository: formalize interfaces for revision deltas and requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38835
diff
changeset
|
492 revision = interfaceutil.Attribute( |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43032
diff
changeset
|
493 """Raw fulltext of revision data for this node.""" |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43032
diff
changeset
|
494 ) |
39230
b518d495a560
repository: formalize interfaces for revision deltas and requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38835
diff
changeset
|
495 |
b518d495a560
repository: formalize interfaces for revision deltas and requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38835
diff
changeset
|
496 delta = interfaceutil.Attribute( |
b518d495a560
repository: formalize interfaces for revision deltas and requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38835
diff
changeset
|
497 """Delta between ``basenode`` and ``node``. |
b518d495a560
repository: formalize interfaces for revision deltas and requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38835
diff
changeset
|
498 |
b518d495a560
repository: formalize interfaces for revision deltas and requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38835
diff
changeset
|
499 Stored in the bdiff delta format. |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43032
diff
changeset
|
500 """ |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43032
diff
changeset
|
501 ) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43032
diff
changeset
|
502 |
46712
e8c11a2c96c0
delta: add sidedata field to revision delta
Raphaël Gomès <rgomes@octobus.net>
parents:
46509
diff
changeset
|
503 sidedata = interfaceutil.Attribute( |
e8c11a2c96c0
delta: add sidedata field to revision delta
Raphaël Gomès <rgomes@octobus.net>
parents:
46509
diff
changeset
|
504 """Raw sidedata bytes for the given revision.""" |
e8c11a2c96c0
delta: add sidedata field to revision delta
Raphaël Gomès <rgomes@octobus.net>
parents:
46509
diff
changeset
|
505 ) |
e8c11a2c96c0
delta: add sidedata field to revision delta
Raphaël Gomès <rgomes@octobus.net>
parents:
46509
diff
changeset
|
506 |
47077
119790e1c67c
cg4: introduce protocol flag to signify the presence of sidedata
Raphaël Gomès <rgomes@octobus.net>
parents:
46780
diff
changeset
|
507 protocol_flags = interfaceutil.Attribute( |
119790e1c67c
cg4: introduce protocol flag to signify the presence of sidedata
Raphaël Gomès <rgomes@octobus.net>
parents:
46780
diff
changeset
|
508 """Single byte of integer flags that can influence the protocol. |
119790e1c67c
cg4: introduce protocol flag to signify the presence of sidedata
Raphaël Gomès <rgomes@octobus.net>
parents:
46780
diff
changeset
|
509 |
119790e1c67c
cg4: introduce protocol flag to signify the presence of sidedata
Raphaël Gomès <rgomes@octobus.net>
parents:
46780
diff
changeset
|
510 This is a bitwise composition of the ``storageutil.CG_FLAG*`` constants. |
119790e1c67c
cg4: introduce protocol flag to signify the presence of sidedata
Raphaël Gomès <rgomes@octobus.net>
parents:
46780
diff
changeset
|
511 """ |
119790e1c67c
cg4: introduce protocol flag to signify the presence of sidedata
Raphaël Gomès <rgomes@octobus.net>
parents:
46780
diff
changeset
|
512 ) |
119790e1c67c
cg4: introduce protocol flag to signify the presence of sidedata
Raphaël Gomès <rgomes@octobus.net>
parents:
46780
diff
changeset
|
513 |
39230
b518d495a560
repository: formalize interfaces for revision deltas and requests
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38835
diff
changeset
|
514 |
37810
856f381ad74b
interfaceutil: module to stub out zope.interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37650
diff
changeset
|
515 class ifilerevisionssequence(interfaceutil.Interface): |
37440
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
516 """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
|
517 |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
518 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
|
519 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
|
520 index metadata. |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
521 |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
522 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
|
523 in the index. |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
524 """ |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
525 |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
526 def __len__(): |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
527 """The total number of revisions.""" |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
528 |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
529 def __getitem__(rev): |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
530 """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
|
531 |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
532 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
|
533 |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
534 offset+flags |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
535 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
|
536 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
|
537 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
|
538 compressed size |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
539 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
|
540 needed by the store. |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
541 uncompressed size |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
542 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
|
543 base revision |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
544 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
|
545 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
|
546 link revision |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
547 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
|
548 p1 revision |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
549 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
|
550 p2 revision |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
551 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
|
552 node |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
553 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
|
554 |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
555 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
|
556 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
|
557 recent revision. |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
558 """ |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
559 |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
560 def __contains__(rev): |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
561 """Whether a revision number exists.""" |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
562 |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
563 def insert(self, i, entry): |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
564 """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
|
565 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43032
diff
changeset
|
566 |
37810
856f381ad74b
interfaceutil: module to stub out zope.interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37650
diff
changeset
|
567 class ifileindex(interfaceutil.Interface): |
37440
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
568 """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
|
569 |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
570 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
|
571 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
|
572 |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
573 The index logically consists of: |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
574 |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
575 * 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
|
576 * 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
|
577 * Metadata to facilitate storage. |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
578 """ |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43032
diff
changeset
|
579 |
46780
6266d19556ad
node: introduce nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents:
46713
diff
changeset
|
580 nullid = interfaceutil.Attribute( |
6266d19556ad
node: introduce nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents:
46713
diff
changeset
|
581 """node for the null revision for use as delta base.""" |
6266d19556ad
node: introduce nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents:
46713
diff
changeset
|
582 ) |
6266d19556ad
node: introduce nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents:
46713
diff
changeset
|
583 |
37440
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
584 def __len__(): |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
585 """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
|
586 |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
587 def __iter__(): |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
588 """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
|
589 |
40387
f1a39128da95
filelog: add a hasnode() method (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40279
diff
changeset
|
590 def hasnode(node): |
f1a39128da95
filelog: add a hasnode() method (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40279
diff
changeset
|
591 """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
|
592 |
f1a39128da95
filelog: add a hasnode() method (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40279
diff
changeset
|
593 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
|
594 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
|
595 rejected. |
f1a39128da95
filelog: add a hasnode() method (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40279
diff
changeset
|
596 |
f1a39128da95
filelog: add a hasnode() method (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40279
diff
changeset
|
597 The null node is never present. |
f1a39128da95
filelog: add a hasnode() method (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40279
diff
changeset
|
598 """ |
f1a39128da95
filelog: add a hasnode() method (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40279
diff
changeset
|
599 |
37440
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
600 def revs(start=0, stop=None): |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
601 """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
|
602 |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
603 def parents(node): |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
604 """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
|
605 |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
606 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
|
607 """ |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
608 |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
609 def parentrevs(rev): |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
610 """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
|
611 |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
612 def rev(node): |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
613 """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
|
614 |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
615 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
|
616 """ |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
617 |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
618 def node(rev): |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
619 """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
|
620 |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
621 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
|
622 """ |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
623 |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
624 def lookup(node): |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
625 """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
|
626 |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
627 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
|
628 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
|
629 |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
630 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
|
631 """ |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
632 |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
633 def linkrev(rev): |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
634 """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
|
635 |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
636 def iscensored(rev): |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
637 """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
|
638 |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
639 def commonancestorsheads(node1, node2): |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
640 """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
|
641 |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
642 See ``ancestor.commonancestorsheads()``. |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
643 """ |
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 def descendants(revs): |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
646 """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
|
647 |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
648 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
|
649 """ |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
650 |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
651 def heads(start=None, stop=None): |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
652 """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
|
653 |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
654 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
|
655 ``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
|
656 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
|
657 ``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
|
658 encountered. |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
659 """ |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
660 |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
661 def children(node): |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
662 """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
|
663 |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
664 Returns a list of nodes. |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
665 """ |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
666 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43032
diff
changeset
|
667 |
37810
856f381ad74b
interfaceutil: module to stub out zope.interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37650
diff
changeset
|
668 class ifiledata(interfaceutil.Interface): |
37440
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
669 """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
|
670 |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
671 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
|
672 data for a tracked file. |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
673 """ |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43032
diff
changeset
|
674 |
37440
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
675 def size(rev): |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
676 """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
|
677 |
39875
d909c44d29e1
filelog: stop proxying rawsize() (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39873
diff
changeset
|
678 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
|
679 """ |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
680 |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
681 def revision(node, raw=False): |
45946
464539c305aa
formatting: drop a few extra double quotes in docstrings
Matt Harbison <matt_harbison@yahoo.com>
parents:
45942
diff
changeset
|
682 """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
|
683 |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
684 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
|
685 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
|
686 are not applied. |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
687 |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
688 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
|
689 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
|
690 """ |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
691 |
42727
bbe71b5afd02
rawdata: register the method for `ifiledata`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42723
diff
changeset
|
692 def rawdata(node): |
45942
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45788
diff
changeset
|
693 """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
|
694 |
37440
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
695 def read(node): |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
696 """Resolve file fulltext data. |
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 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
|
699 headers is stripped. |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
700 """ |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
701 |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
702 def renamed(node): |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
703 """Obtain copy metadata for a node. |
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 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
|
706 (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
|
707 """ |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
708 |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
709 def cmp(node, fulltext): |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
710 """Compare fulltext to another revision. |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
711 |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
712 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
|
713 |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
714 This takes copy metadata into account. |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
715 |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
716 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
|
717 """ |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
718 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43032
diff
changeset
|
719 def emitrevisions( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43032
diff
changeset
|
720 nodes, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43032
diff
changeset
|
721 nodesorder=None, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43032
diff
changeset
|
722 revisiondata=False, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43032
diff
changeset
|
723 assumehaveparentrevisions=False, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43032
diff
changeset
|
724 deltamode=CG_DELTAMODE_STD, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43032
diff
changeset
|
725 ): |
39862
5a9ab91e0a45
revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39860
diff
changeset
|
726 """Produce ``irevisiondelta`` for revisions. |
5a9ab91e0a45
revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39860
diff
changeset
|
727 |
5a9ab91e0a45
revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39860
diff
changeset
|
728 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
|
729 ``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
|
730 |
5a9ab91e0a45
revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39860
diff
changeset
|
731 This method is a generator. |
5a9ab91e0a45
revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39860
diff
changeset
|
732 |
5a9ab91e0a45
revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39860
diff
changeset
|
733 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
|
734 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
|
735 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
|
736 ``nodes`` have also been emitted. |
5a9ab91e0a45
revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39860
diff
changeset
|
737 |
5a9ab91e0a45
revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39860
diff
changeset
|
738 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
|
739 ``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
|
740 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
|
741 |
5a9ab91e0a45
revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39860
diff
changeset
|
742 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
|
743 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
|
744 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
|
745 fulltext is available to the receiver. |
5a9ab91e0a45
revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39860
diff
changeset
|
746 |
5a9ab91e0a45
revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39860
diff
changeset
|
747 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
|
748 the following are met: |
5a9ab91e0a45
revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39860
diff
changeset
|
749 |
5a9ab91e0a45
revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39860
diff
changeset
|
750 * 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
|
751 * 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
|
752 * ``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
|
753 parent of the node. |
5a9ab91e0a45
revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39860
diff
changeset
|
754 |
5a9ab91e0a45
revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39860
diff
changeset
|
755 ``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
|
756 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
|
757 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
|
758 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
|
759 ``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
|
760 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
|
761 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
|
762 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
|
763 use it with care. |
5a9ab91e0a45
revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39860
diff
changeset
|
764 |
5a9ab91e0a45
revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39860
diff
changeset
|
765 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
|
766 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
|
767 |
40430
6a917075535a
storage: also use `deltamode argument` for ifiledata
Boris Feld <boris.feld@octobus.net>
parents:
40427
diff
changeset
|
768 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
|
769 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
|
770 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
|
771 1st parent. |
39862
5a9ab91e0a45
revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39860
diff
changeset
|
772 """ |
5a9ab91e0a45
revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39860
diff
changeset
|
773 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43032
diff
changeset
|
774 |
37810
856f381ad74b
interfaceutil: module to stub out zope.interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37650
diff
changeset
|
775 class ifilemutation(interfaceutil.Interface): |
37440
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
776 """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
|
777 |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
778 def add(filedata, meta, transaction, linkrev, p1, p2): |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
779 """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
|
780 |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
781 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
|
782 and parent nodes. |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
783 |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
784 Returns the node that was added. |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
785 |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
786 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
|
787 """ |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
788 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43032
diff
changeset
|
789 def addrevision( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43032
diff
changeset
|
790 revisiondata, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43032
diff
changeset
|
791 transaction, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43032
diff
changeset
|
792 linkrev, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43032
diff
changeset
|
793 p1, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43032
diff
changeset
|
794 p2, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43032
diff
changeset
|
795 node=None, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43032
diff
changeset
|
796 flags=0, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43032
diff
changeset
|
797 cachedelta=None, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43032
diff
changeset
|
798 ): |
46508
f7b61ad3c64a
revlog: change addrevision to return the new revision, not node
Joerg Sonnenberger <joerg@bec.de>
parents:
46373
diff
changeset
|
799 """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
|
800 |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
801 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
|
802 |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
803 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
|
804 |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
805 ``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
|
806 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
|
807 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
|
808 |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
809 ``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
|
810 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
|
811 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
|
812 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
|
813 """ |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
814 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43032
diff
changeset
|
815 def addgroup( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43032
diff
changeset
|
816 deltas, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43032
diff
changeset
|
817 linkmapper, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43032
diff
changeset
|
818 transaction, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43032
diff
changeset
|
819 addrevisioncb=None, |
45788
a5206e71c536
revlog: extend addgroup() with callback for duplicates
Joerg Sonnenberger <joerg@bec.de>
parents:
45671
diff
changeset
|
820 duplicaterevisioncb=None, |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43032
diff
changeset
|
821 maybemissingparents=False, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43032
diff
changeset
|
822 ): |
37440
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
823 """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
|
824 |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
825 ``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
|
826 (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
|
827 to add. |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
828 |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
829 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
|
830 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
|
831 ``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
|
832 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
|
833 |
46373
711ba0f1057e
revlog: decouple caching from addrevision callback for addgroup
Joerg Sonnenberger <joerg@bec.de>
parents:
46371
diff
changeset
|
834 ``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
|
835 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
|
836 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
|
837 Mercurial 5.8. |
711ba0f1057e
revlog: decouple caching from addrevision callback for addgroup
Joerg Sonnenberger <joerg@bec.de>
parents:
46371
diff
changeset
|
838 |
46509
7a93b7b3dc2d
revlog: change addgroup callbacks to take revision numbers
Joerg Sonnenberger <joerg@bec.de>
parents:
46508
diff
changeset
|
839 ``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
|
840 ``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
|
841 pre-existing node. |
37440
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
842 |
40389
1b183edbb68e
repository: teach addgroup() to receive data with missing parents
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40387
diff
changeset
|
843 ``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
|
844 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
|
845 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
|
846 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
|
847 |
37440
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
848 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
|
849 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
|
850 """ |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
851 |
39778
a6b3c4c1019f
revlog: move censor logic out of censor extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39776
diff
changeset
|
852 def censorrevision(tr, node, tombstone=b''): |
a6b3c4c1019f
revlog: move censor logic out of censor extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39776
diff
changeset
|
853 """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
|
854 |
a6b3c4c1019f
revlog: move censor logic out of censor extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39776
diff
changeset
|
855 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
|
856 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
|
857 result in failure. |
a6b3c4c1019f
revlog: move censor logic out of censor extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39776
diff
changeset
|
858 |
a6b3c4c1019f
revlog: move censor logic out of censor extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39776
diff
changeset
|
859 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
|
860 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
|
861 data. |
a6b3c4c1019f
revlog: move censor logic out of censor extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39776
diff
changeset
|
862 |
a6b3c4c1019f
revlog: move censor logic out of censor extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39776
diff
changeset
|
863 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
|
864 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
|
865 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
|
866 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
|
867 """ |
a6b3c4c1019f
revlog: move censor logic out of censor extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39776
diff
changeset
|
868 |
37440
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
869 def getstrippoint(minlink): |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
870 """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
|
871 |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
872 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
|
873 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
|
874 |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
875 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
|
876 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
|
877 """ |
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 def strip(minlink, transaction): |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
880 """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
|
881 |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
882 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
|
883 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
|
884 |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
885 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
|
886 higher-level deletion API. |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
887 """ |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
888 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43032
diff
changeset
|
889 |
37440
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
890 class ifilestorage(ifileindex, ifiledata, ifilemutation): |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
891 """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
|
892 |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
893 def files(): |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
894 """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
|
895 |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
896 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
|
897 be a better API for that. |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
898 """ |
4335a75f0bd0
repository: define existing interface for file storage
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37351
diff
changeset
|
899 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43032
diff
changeset
|
900 def storageinfo( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43032
diff
changeset
|
901 exclusivefiles=False, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43032
diff
changeset
|
902 sharedfiles=False, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43032
diff
changeset
|
903 revisionscount=False, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43032
diff
changeset
|
904 trackedsize=False, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43032
diff
changeset
|
905 storedsize=False, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43032
diff
changeset
|
906 ): |
39869
14e500b58263
revlog: add method for obtaining storage info (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39867
diff
changeset
|
907 """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
|
908 |
14e500b58263
revlog: add method for obtaining storage info (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39867
diff
changeset
|
909 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
|
910 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
|
911 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
|
912 |
14e500b58263
revlog: add method for obtaining storage info (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39867
diff
changeset
|
913 exclusivefiles |
14e500b58263
revlog: add method for obtaining storage info (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39867
diff
changeset
|
914 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
|
915 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
|
916 |
14e500b58263
revlog: add method for obtaining storage info (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39867
diff
changeset
|
917 sharedfiles |
14e500b58263
revlog: add method for obtaining storage info (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39867
diff
changeset
|
918 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
|
919 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
|
920 for other stored entities. |
14e500b58263
revlog: add method for obtaining storage info (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39867
diff
changeset
|
921 |
14e500b58263
revlog: add method for obtaining storage info (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39867
diff
changeset
|
922 revisionscount |
14e500b58263
revlog: add method for obtaining storage info (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39867
diff
changeset
|
923 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
|
924 |
14e500b58263
revlog: add method for obtaining storage info (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39867
diff
changeset
|
925 trackedsize |
14e500b58263
revlog: add method for obtaining storage info (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39867
diff
changeset
|
926 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
|
927 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
|
928 |
14e500b58263
revlog: add method for obtaining storage info (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39867
diff
changeset
|
929 storedsize |
14e500b58263
revlog: add method for obtaining storage info (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39867
diff
changeset
|
930 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
|
931 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
|
932 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
|
933 |
14e500b58263
revlog: add method for obtaining storage info (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39867
diff
changeset
|
934 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
|
935 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
|
936 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
|
937 """ |
14e500b58263
revlog: add method for obtaining storage info (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39867
diff
changeset
|
938 |
39842
97986c9c69d3
verify: start to abstract file verification
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39785
diff
changeset
|
939 def verifyintegrity(state): |
97986c9c69d3
verify: start to abstract file verification
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39785
diff
changeset
|
940 """Verifies the integrity of file storage. |
97986c9c69d3
verify: start to abstract file verification
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39785
diff
changeset
|
941 |
97986c9c69d3
verify: start to abstract file verification
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39785
diff
changeset
|
942 ``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
|
943 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
|
944 primitives. |
97986c9c69d3
verify: start to abstract file verification
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39785
diff
changeset
|
945 |
39872
733db72f0f54
revlog: move revision verification out of verify
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39869
diff
changeset
|
946 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
|
947 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
|
948 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
|
949 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
|
950 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
|
951 |
39842
97986c9c69d3
verify: start to abstract file verification
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39785
diff
changeset
|
952 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
|
953 interface. |
97986c9c69d3
verify: start to abstract file verification
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39785
diff
changeset
|
954 """ |
97986c9c69d3
verify: start to abstract file verification
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39785
diff
changeset
|
955 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43032
diff
changeset
|
956 |
38530
c82ea938efbb
repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38509
diff
changeset
|
957 class idirs(interfaceutil.Interface): |
c82ea938efbb
repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38509
diff
changeset
|
958 """Interface representing a collection of directories from paths. |
c82ea938efbb
repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38509
diff
changeset
|
959 |
c82ea938efbb
repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38509
diff
changeset
|
960 This interface is essentially a derived data structure representing |
c82ea938efbb
repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38509
diff
changeset
|
961 directories from a collection of paths. |
c82ea938efbb
repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38509
diff
changeset
|
962 """ |
c82ea938efbb
repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38509
diff
changeset
|
963 |
c82ea938efbb
repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38509
diff
changeset
|
964 def addpath(path): |
c82ea938efbb
repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38509
diff
changeset
|
965 """Add a path to the collection. |
c82ea938efbb
repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38509
diff
changeset
|
966 |
c82ea938efbb
repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38509
diff
changeset
|
967 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
|
968 """ |
c82ea938efbb
repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38509
diff
changeset
|
969 |
c82ea938efbb
repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38509
diff
changeset
|
970 def delpath(path): |
c82ea938efbb
repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38509
diff
changeset
|
971 """Remove a path from the collection. |
c82ea938efbb
repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38509
diff
changeset
|
972 |
c82ea938efbb
repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38509
diff
changeset
|
973 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
|
974 directory is removed from the collection. |
c82ea938efbb
repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38509
diff
changeset
|
975 """ |
c82ea938efbb
repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38509
diff
changeset
|
976 |
c82ea938efbb
repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38509
diff
changeset
|
977 def __iter__(): |
c82ea938efbb
repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38509
diff
changeset
|
978 """Iterate over the directories in this collection of paths.""" |
c82ea938efbb
repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38509
diff
changeset
|
979 |
c82ea938efbb
repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38509
diff
changeset
|
980 def __contains__(path): |
c82ea938efbb
repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38509
diff
changeset
|
981 """Whether a specific directory is in this collection.""" |
c82ea938efbb
repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38509
diff
changeset
|
982 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43032
diff
changeset
|
983 |
38530
c82ea938efbb
repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38509
diff
changeset
|
984 class imanifestdict(interfaceutil.Interface): |
c82ea938efbb
repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38509
diff
changeset
|
985 """Interface representing a manifest data structure. |
c82ea938efbb
repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38509
diff
changeset
|
986 |
c82ea938efbb
repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38509
diff
changeset
|
987 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
|
988 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
|
989 """ |
c82ea938efbb
repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38509
diff
changeset
|
990 |
c82ea938efbb
repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38509
diff
changeset
|
991 def __getitem__(path): |
c82ea938efbb
repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38509
diff
changeset
|
992 """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
|
993 |
c82ea938efbb
repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38509
diff
changeset
|
994 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
|
995 |
c82ea938efbb
repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38509
diff
changeset
|
996 Equivalent to ``self.find(path)[0]``. |
c82ea938efbb
repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38509
diff
changeset
|
997 """ |
c82ea938efbb
repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38509
diff
changeset
|
998 |
c82ea938efbb
repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38509
diff
changeset
|
999 def find(path): |
c82ea938efbb
repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38509
diff
changeset
|
1000 """Returns the entry for a path in the manifest. |
c82ea938efbb
repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38509
diff
changeset
|
1001 |
c82ea938efbb
repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38509
diff
changeset
|
1002 Returns a 2-tuple of (node, flags). |
c82ea938efbb
repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38509
diff
changeset
|
1003 |
c82ea938efbb
repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38509
diff
changeset
|
1004 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
|
1005 """ |
c82ea938efbb
repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38509
diff
changeset
|
1006 |
c82ea938efbb
repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38509
diff
changeset
|
1007 def __len__(): |
c82ea938efbb
repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38509
diff
changeset
|
1008 """Return the number of entries in the manifest.""" |
c82ea938efbb
repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38509
diff
changeset
|
1009 |
c82ea938efbb
repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38509
diff
changeset
|
1010 def __nonzero__(): |
c82ea938efbb
repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38509
diff
changeset
|
1011 """Returns True if the manifest has entries, False otherwise.""" |
c82ea938efbb
repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38509
diff
changeset
|
1012 |
c82ea938efbb
repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38509
diff
changeset
|
1013 __bool__ = __nonzero__ |
c82ea938efbb
repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38509
diff
changeset
|
1014 |
c82ea938efbb
repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38509
diff
changeset
|
1015 def __setitem__(path, node): |
c82ea938efbb
repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38509
diff
changeset
|
1016 """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
|
1017 |
c82ea938efbb
repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38509
diff
changeset
|
1018 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
|
1019 the new entry. |
c82ea938efbb
repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38509
diff
changeset
|
1020 """ |
c82ea938efbb
repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38509
diff
changeset
|
1021 |
c82ea938efbb
repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38509
diff
changeset
|
1022 def __contains__(path): |
c82ea938efbb
repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38509
diff
changeset
|
1023 """Whether a path exists in the manifest.""" |
c82ea938efbb
repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38509
diff
changeset
|
1024 |
c82ea938efbb
repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38509
diff
changeset
|
1025 def __delitem__(path): |
c82ea938efbb
repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38509
diff
changeset
|
1026 """Remove a path from the manifest. |
c82ea938efbb
repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38509
diff
changeset
|
1027 |
c82ea938efbb
repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38509
diff
changeset
|
1028 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
|
1029 """ |
c82ea938efbb
repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38509
diff
changeset
|
1030 |
c82ea938efbb
repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38509
diff
changeset
|
1031 def __iter__(): |
c82ea938efbb
repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38509
diff
changeset
|
1032 """Iterate over paths in the manifest.""" |
c82ea938efbb
repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38509
diff
changeset
|
1033 |
c82ea938efbb
repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38509
diff
changeset
|
1034 def iterkeys(): |
c82ea938efbb
repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38509
diff
changeset
|
1035 """Iterate over paths in the manifest.""" |
c82ea938efbb
repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38509
diff
changeset
|
1036 |
c82ea938efbb
repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38509
diff
changeset
|
1037 def keys(): |
c82ea938efbb
repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38509
diff
changeset
|
1038 """Obtain a list of paths in the manifest.""" |
c82ea938efbb
repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38509
diff
changeset
|
1039 |
c82ea938efbb
repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38509
diff
changeset
|
1040 def filesnotin(other, match=None): |
c82ea938efbb
repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38509
diff
changeset
|
1041 """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
|
1042 |
c82ea938efbb
repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38509
diff
changeset
|
1043 ``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
|
1044 manifests. |
c82ea938efbb
repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38509
diff
changeset
|
1045 |
c82ea938efbb
repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38509
diff
changeset
|
1046 Returns a set of paths. |
c82ea938efbb
repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38509
diff
changeset
|
1047 """ |
c82ea938efbb
repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38509
diff
changeset
|
1048 |
c82ea938efbb
repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38509
diff
changeset
|
1049 def dirs(): |
c82ea938efbb
repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38509
diff
changeset
|
1050 """Returns an object implementing the ``idirs`` interface.""" |
c82ea938efbb
repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38509
diff
changeset
|
1051 |
c82ea938efbb
repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38509
diff
changeset
|
1052 def hasdir(dir): |
c82ea938efbb
repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38509
diff
changeset
|
1053 """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
|
1054 |
c82ea938efbb
repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38509
diff
changeset
|
1055 def walk(match): |
c82ea938efbb
repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38509
diff
changeset
|
1056 """Generator of paths in manifest satisfying a matcher. |
c82ea938efbb
repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38509
diff
changeset
|
1057 |
c82ea938efbb
repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38509
diff
changeset
|
1058 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
|
1059 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
|
1060 """ |
c82ea938efbb
repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38509
diff
changeset
|
1061 |
c82ea938efbb
repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38509
diff
changeset
|
1062 def diff(other, match=None, clean=False): |
c82ea938efbb
repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38509
diff
changeset
|
1063 """Find differences between this manifest and another. |
c82ea938efbb
repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38509
diff
changeset
|
1064 |
c82ea938efbb
repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38509
diff
changeset
|
1065 This manifest is compared to ``other``. |
c82ea938efbb
repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38509
diff
changeset
|
1066 |
c82ea938efbb
repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38509
diff
changeset
|
1067 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
|
1068 matcher and only entries satisfying the matcher are compared. |
c82ea938efbb
repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38509
diff
changeset
|
1069 |
c82ea938efbb
repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38509
diff
changeset
|
1070 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
|
1071 object. |
c82ea938efbb
repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38509
diff
changeset
|
1072 |
c82ea938efbb
repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38509
diff
changeset
|
1073 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
|
1074 the form ``((node1, flag1), (node2, flag2))`` where ``(node1, flag1)`` |
c82ea938efbb
repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38509
diff
changeset
|
1075 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
|
1076 are the same for the other manifest. |
c82ea938efbb
repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38509
diff
changeset
|
1077 """ |
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 def setflag(path, flag): |
c82ea938efbb
repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38509
diff
changeset
|
1080 """Set the flag value for a given path. |
c82ea938efbb
repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38509
diff
changeset
|
1081 |
c82ea938efbb
repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38509
diff
changeset
|
1082 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
|
1083 """ |
c82ea938efbb
repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38509
diff
changeset
|
1084 |
c82ea938efbb
repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38509
diff
changeset
|
1085 def get(path, default=None): |
c82ea938efbb
repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38509
diff
changeset
|
1086 """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
|
1087 |
44257
dbbae122f5e4
manifest: remove optional default= argument on flags(path)
Augie Fackler <augie@google.com>
parents:
44073
diff
changeset
|
1088 def flags(path): |
dbbae122f5e4
manifest: remove optional default= argument on flags(path)
Augie Fackler <augie@google.com>
parents:
44073
diff
changeset
|
1089 """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
|
1090 |
c82ea938efbb
repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38509
diff
changeset
|
1091 def copy(): |
c82ea938efbb
repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38509
diff
changeset
|
1092 """Return a copy of this manifest.""" |
c82ea938efbb
repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38509
diff
changeset
|
1093 |
c82ea938efbb
repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38509
diff
changeset
|
1094 def items(): |
c82ea938efbb
repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38509
diff
changeset
|
1095 """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
|
1096 |
c82ea938efbb
repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38509
diff
changeset
|
1097 def iteritems(): |
c82ea938efbb
repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38509
diff
changeset
|
1098 """Identical to items().""" |
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 def iterentries(): |
c82ea938efbb
repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38509
diff
changeset
|
1101 """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
|
1102 |
c82ea938efbb
repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38509
diff
changeset
|
1103 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
|
1104 flags. |
c82ea938efbb
repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38509
diff
changeset
|
1105 """ |
c82ea938efbb
repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38509
diff
changeset
|
1106 |
c82ea938efbb
repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38509
diff
changeset
|
1107 def text(): |
c82ea938efbb
repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38509
diff
changeset
|
1108 """Obtain the raw data representation for this 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 Result is used to create a manifest revision. |
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 |
c82ea938efbb
repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38509
diff
changeset
|
1113 def fastdelta(base, changes): |
c82ea938efbb
repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38509
diff
changeset
|
1114 """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
|
1115 |
c82ea938efbb
repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38509
diff
changeset
|
1116 ``base`` in the raw data representation for another manifest. |
c82ea938efbb
repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38509
diff
changeset
|
1117 |
c82ea938efbb
repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38509
diff
changeset
|
1118 ``changes`` is an iterable of ``(path, to_delete)``. |
c82ea938efbb
repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38509
diff
changeset
|
1119 |
c82ea938efbb
repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38509
diff
changeset
|
1120 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
|
1121 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
|
1122 |
948fac24bc39
manifest: introduce new exception to signal unavailability of fastdelta()
Augie Fackler <augie@google.com>
parents:
44352
diff
changeset
|
1123 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
|
1124 raise ``mercurial.manifest.FastdeltaUnavailable``. |
38530
c82ea938efbb
repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38509
diff
changeset
|
1125 """ |
c82ea938efbb
repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38509
diff
changeset
|
1126 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43032
diff
changeset
|
1127 |
38530
c82ea938efbb
repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38509
diff
changeset
|
1128 class imanifestrevisionbase(interfaceutil.Interface): |
c82ea938efbb
repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38509
diff
changeset
|
1129 """Base interface representing a single revision of a manifest. |
c82ea938efbb
repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38509
diff
changeset
|
1130 |
c82ea938efbb
repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38509
diff
changeset
|
1131 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
|
1132 as part of a larger interface. |
c82ea938efbb
repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38509
diff
changeset
|
1133 """ |
c82ea938efbb
repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38509
diff
changeset
|
1134 |
c82ea938efbb
repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38509
diff
changeset
|
1135 def copy(): |
c82ea938efbb
repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38509
diff
changeset
|
1136 """Obtain a copy of this manifest instance. |
c82ea938efbb
repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38509
diff
changeset
|
1137 |
c82ea938efbb
repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38509
diff
changeset
|
1138 Returns an object conforming to the ``imanifestrevisionwritable`` |
c82ea938efbb
repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38509
diff
changeset
|
1139 interface. The instance will be associated with the same |
c82ea938efbb
repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38509
diff
changeset
|
1140 ``imanifestlog`` collection as this instance. |
c82ea938efbb
repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38509
diff
changeset
|
1141 """ |
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 def read(): |
c82ea938efbb
repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38509
diff
changeset
|
1144 """Obtain the parsed manifest data structure. |
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 The returned object conforms to the ``imanifestdict`` interface. |
c82ea938efbb
repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38509
diff
changeset
|
1147 """ |
c82ea938efbb
repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38509
diff
changeset
|
1148 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43032
diff
changeset
|
1149 |
38530
c82ea938efbb
repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38509
diff
changeset
|
1150 class imanifestrevisionstored(imanifestrevisionbase): |
c82ea938efbb
repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38509
diff
changeset
|
1151 """Interface representing a manifest revision committed to storage.""" |
c82ea938efbb
repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38509
diff
changeset
|
1152 |
c82ea938efbb
repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38509
diff
changeset
|
1153 def node(): |
c82ea938efbb
repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38509
diff
changeset
|
1154 """The binary node for this manifest.""" |
c82ea938efbb
repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38509
diff
changeset
|
1155 |
c82ea938efbb
repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38509
diff
changeset
|
1156 parents = interfaceutil.Attribute( |
c82ea938efbb
repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38509
diff
changeset
|
1157 """List of binary nodes that are parents for this manifest revision.""" |
c82ea938efbb
repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38509
diff
changeset
|
1158 ) |
c82ea938efbb
repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38509
diff
changeset
|
1159 |
c82ea938efbb
repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38509
diff
changeset
|
1160 def readdelta(shallow=False): |
c82ea938efbb
repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38509
diff
changeset
|
1161 """Obtain the manifest data structure representing changes from parent. |
c82ea938efbb
repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38509
diff
changeset
|
1162 |
c82ea938efbb
repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38509
diff
changeset
|
1163 This manifest is compared to its 1st parent. A new manifest representing |
c82ea938efbb
repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38509
diff
changeset
|
1164 those differences is constructed. |
c82ea938efbb
repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38509
diff
changeset
|
1165 |
c82ea938efbb
repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38509
diff
changeset
|
1166 The returned object conforms to the ``imanifestdict`` interface. |
c82ea938efbb
repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38509
diff
changeset
|
1167 """ |
c82ea938efbb
repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38509
diff
changeset
|
1168 |
c82ea938efbb
repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38509
diff
changeset
|
1169 def readfast(shallow=False): |
c82ea938efbb
repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38509
diff
changeset
|
1170 """Calls either ``read()`` or ``readdelta()``. |
c82ea938efbb
repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38509
diff
changeset
|
1171 |
c82ea938efbb
repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38509
diff
changeset
|
1172 The faster of the two options is called. |
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 |
c82ea938efbb
repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38509
diff
changeset
|
1175 def find(key): |
c82ea938efbb
repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38509
diff
changeset
|
1176 """Calls self.read().find(key)``. |
c82ea938efbb
repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38509
diff
changeset
|
1177 |
c82ea938efbb
repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38509
diff
changeset
|
1178 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
|
1179 """ |
c82ea938efbb
repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38509
diff
changeset
|
1180 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43032
diff
changeset
|
1181 |
38530
c82ea938efbb
repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38509
diff
changeset
|
1182 class imanifestrevisionwritable(imanifestrevisionbase): |
c82ea938efbb
repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38509
diff
changeset
|
1183 """Interface representing a manifest revision that can be committed.""" |
c82ea938efbb
repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38509
diff
changeset
|
1184 |
39668
24870f1be088
narrow: when writing treemanifests, skip inspecting directories outside narrow
spectral <spectral@google.com>
parents:
39315
diff
changeset
|
1185 def write(transaction, linkrev, p1node, p2node, added, removed, match=None): |
38530
c82ea938efbb
repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38509
diff
changeset
|
1186 """Add this revision to storage. |
c82ea938efbb
repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38509
diff
changeset
|
1187 |
c82ea938efbb
repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38509
diff
changeset
|
1188 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
|
1189 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
|
1190 removed paths. |
c82ea938efbb
repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38509
diff
changeset
|
1191 |
39668
24870f1be088
narrow: when writing treemanifests, skip inspecting directories outside narrow
spectral <spectral@google.com>
parents:
39315
diff
changeset
|
1192 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
|
1193 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
|
1194 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
|
1195 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
|
1196 |
38530
c82ea938efbb
repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38509
diff
changeset
|
1197 Returns the binary node of the created revision. |
c82ea938efbb
repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38509
diff
changeset
|
1198 """ |
c82ea938efbb
repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38509
diff
changeset
|
1199 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43032
diff
changeset
|
1200 |
39314
7f5e6d3e9032
manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39244
diff
changeset
|
1201 class imanifeststorage(interfaceutil.Interface): |
7f5e6d3e9032
manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39244
diff
changeset
|
1202 """Storage interface for manifest data.""" |
7f5e6d3e9032
manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39244
diff
changeset
|
1203 |
46780
6266d19556ad
node: introduce nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents:
46713
diff
changeset
|
1204 nodeconstants = interfaceutil.Attribute( |
6266d19556ad
node: introduce nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents:
46713
diff
changeset
|
1205 """nodeconstants used by the current repository.""" |
6266d19556ad
node: introduce nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents:
46713
diff
changeset
|
1206 ) |
6266d19556ad
node: introduce nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents:
46713
diff
changeset
|
1207 |
39315
57c3864f3aad
manifest: make tree a public attribute
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39314
diff
changeset
|
1208 tree = interfaceutil.Attribute( |
57c3864f3aad
manifest: make tree a public attribute
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39314
diff
changeset
|
1209 """The path to the directory this manifest tracks. |
57c3864f3aad
manifest: make tree a public attribute
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39314
diff
changeset
|
1210 |
57c3864f3aad
manifest: make tree a public attribute
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39314
diff
changeset
|
1211 The empty bytestring represents the root manifest. |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43032
diff
changeset
|
1212 """ |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43032
diff
changeset
|
1213 ) |
39315
57c3864f3aad
manifest: make tree a public attribute
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39314
diff
changeset
|
1214 |
39314
7f5e6d3e9032
manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39244
diff
changeset
|
1215 index = interfaceutil.Attribute( |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43032
diff
changeset
|
1216 """An ``ifilerevisionssequence`` instance.""" |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43032
diff
changeset
|
1217 ) |
39314
7f5e6d3e9032
manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39244
diff
changeset
|
1218 |
7f5e6d3e9032
manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39244
diff
changeset
|
1219 opener = interfaceutil.Attribute( |
7f5e6d3e9032
manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39244
diff
changeset
|
1220 """VFS opener to use to access underlying files used for storage. |
7f5e6d3e9032
manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39244
diff
changeset
|
1221 |
7f5e6d3e9032
manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39244
diff
changeset
|
1222 TODO this is revlog specific and should not be exposed. |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43032
diff
changeset
|
1223 """ |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43032
diff
changeset
|
1224 ) |
39314
7f5e6d3e9032
manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39244
diff
changeset
|
1225 |
7f5e6d3e9032
manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39244
diff
changeset
|
1226 _generaldelta = interfaceutil.Attribute( |
7f5e6d3e9032
manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39244
diff
changeset
|
1227 """Whether generaldelta storage is being used. |
7f5e6d3e9032
manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39244
diff
changeset
|
1228 |
7f5e6d3e9032
manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39244
diff
changeset
|
1229 TODO this is revlog specific and should not be exposed. |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43032
diff
changeset
|
1230 """ |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43032
diff
changeset
|
1231 ) |
39314
7f5e6d3e9032
manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39244
diff
changeset
|
1232 |
7f5e6d3e9032
manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39244
diff
changeset
|
1233 fulltextcache = interfaceutil.Attribute( |
7f5e6d3e9032
manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39244
diff
changeset
|
1234 """Dict with cache of fulltexts. |
7f5e6d3e9032
manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39244
diff
changeset
|
1235 |
7f5e6d3e9032
manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39244
diff
changeset
|
1236 TODO this doesn't feel appropriate for the storage interface. |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43032
diff
changeset
|
1237 """ |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43032
diff
changeset
|
1238 ) |
39314
7f5e6d3e9032
manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39244
diff
changeset
|
1239 |
7f5e6d3e9032
manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39244
diff
changeset
|
1240 def __len__(): |
7f5e6d3e9032
manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39244
diff
changeset
|
1241 """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
|
1242 |
7f5e6d3e9032
manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39244
diff
changeset
|
1243 def __iter__(): |
7f5e6d3e9032
manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39244
diff
changeset
|
1244 """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
|
1245 |
7f5e6d3e9032
manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39244
diff
changeset
|
1246 def rev(node): |
7f5e6d3e9032
manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39244
diff
changeset
|
1247 """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
|
1248 |
7f5e6d3e9032
manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39244
diff
changeset
|
1249 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
|
1250 """ |
7f5e6d3e9032
manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39244
diff
changeset
|
1251 |
7f5e6d3e9032
manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39244
diff
changeset
|
1252 def node(rev): |
7f5e6d3e9032
manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39244
diff
changeset
|
1253 """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
|
1254 |
7f5e6d3e9032
manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39244
diff
changeset
|
1255 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
|
1256 """ |
7f5e6d3e9032
manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39244
diff
changeset
|
1257 |
7f5e6d3e9032
manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39244
diff
changeset
|
1258 def lookup(value): |
7f5e6d3e9032
manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39244
diff
changeset
|
1259 """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
|
1260 |
7f5e6d3e9032
manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39244
diff
changeset
|
1261 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
|
1262 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
|
1263 |
7f5e6d3e9032
manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39244
diff
changeset
|
1264 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
|
1265 """ |
7f5e6d3e9032
manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39244
diff
changeset
|
1266 |
7f5e6d3e9032
manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39244
diff
changeset
|
1267 def parents(node): |
7f5e6d3e9032
manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39244
diff
changeset
|
1268 """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
|
1269 |
7f5e6d3e9032
manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39244
diff
changeset
|
1270 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
|
1271 """ |
7f5e6d3e9032
manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39244
diff
changeset
|
1272 |
7f5e6d3e9032
manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39244
diff
changeset
|
1273 def parentrevs(rev): |
7f5e6d3e9032
manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39244
diff
changeset
|
1274 """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
|
1275 |
7f5e6d3e9032
manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39244
diff
changeset
|
1276 def linkrev(rev): |
7f5e6d3e9032
manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39244
diff
changeset
|
1277 """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
|
1278 |
48529
c514936d92b4
revlog: remove deprecated APIs
Raphaël Gomès <rgomes@octobus.net>
parents:
47299
diff
changeset
|
1279 def revision(node, _df=None): |
39314
7f5e6d3e9032
manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39244
diff
changeset
|
1280 """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
|
1281 |
42723
2128c76c8970
rawdata: forward `rawdata` call on `manifestlog`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42620
diff
changeset
|
1282 def rawdata(node, _df=None): |
2128c76c8970
rawdata: forward `rawdata` call on `manifestlog`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42620
diff
changeset
|
1283 """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
|
1284 |
39314
7f5e6d3e9032
manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39244
diff
changeset
|
1285 def revdiff(rev1, rev2): |
7f5e6d3e9032
manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39244
diff
changeset
|
1286 """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
|
1287 |
7f5e6d3e9032
manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39244
diff
changeset
|
1288 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
|
1289 revision data. |
7f5e6d3e9032
manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39244
diff
changeset
|
1290 """ |
7f5e6d3e9032
manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39244
diff
changeset
|
1291 |
7f5e6d3e9032
manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39244
diff
changeset
|
1292 def cmp(node, fulltext): |
7f5e6d3e9032
manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39244
diff
changeset
|
1293 """Compare fulltext to another revision. |
7f5e6d3e9032
manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39244
diff
changeset
|
1294 |
7f5e6d3e9032
manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39244
diff
changeset
|
1295 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
|
1296 """ |
7f5e6d3e9032
manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39244
diff
changeset
|
1297 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43032
diff
changeset
|
1298 def emitrevisions( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43032
diff
changeset
|
1299 nodes, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43032
diff
changeset
|
1300 nodesorder=None, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43032
diff
changeset
|
1301 revisiondata=False, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43032
diff
changeset
|
1302 assumehaveparentrevisions=False, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43032
diff
changeset
|
1303 ): |
39862
5a9ab91e0a45
revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39860
diff
changeset
|
1304 """Produce ``irevisiondelta`` describing revisions. |
5a9ab91e0a45
revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39860
diff
changeset
|
1305 |
5a9ab91e0a45
revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39860
diff
changeset
|
1306 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
|
1307 """ |
5a9ab91e0a45
revlog: new API to emit revision data
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39860
diff
changeset
|
1308 |
45788
a5206e71c536
revlog: extend addgroup() with callback for duplicates
Joerg Sonnenberger <joerg@bec.de>
parents:
45671
diff
changeset
|
1309 def addgroup( |
a5206e71c536
revlog: extend addgroup() with callback for duplicates
Joerg Sonnenberger <joerg@bec.de>
parents:
45671
diff
changeset
|
1310 deltas, |
a5206e71c536
revlog: extend addgroup() with callback for duplicates
Joerg Sonnenberger <joerg@bec.de>
parents:
45671
diff
changeset
|
1311 linkmapper, |
a5206e71c536
revlog: extend addgroup() with callback for duplicates
Joerg Sonnenberger <joerg@bec.de>
parents:
45671
diff
changeset
|
1312 transaction, |
a5206e71c536
revlog: extend addgroup() with callback for duplicates
Joerg Sonnenberger <joerg@bec.de>
parents:
45671
diff
changeset
|
1313 addrevisioncb=None, |
a5206e71c536
revlog: extend addgroup() with callback for duplicates
Joerg Sonnenberger <joerg@bec.de>
parents:
45671
diff
changeset
|
1314 duplicaterevisioncb=None, |
a5206e71c536
revlog: extend addgroup() with callback for duplicates
Joerg Sonnenberger <joerg@bec.de>
parents:
45671
diff
changeset
|
1315 ): |
39314
7f5e6d3e9032
manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39244
diff
changeset
|
1316 """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
|
1317 |
7f5e6d3e9032
manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39244
diff
changeset
|
1318 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
|
1319 """ |
7f5e6d3e9032
manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39244
diff
changeset
|
1320 |
39858
9534fe1e5d28
manifest: add rawsize() proxy (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39851
diff
changeset
|
1321 def rawsize(rev): |
9534fe1e5d28
manifest: add rawsize() proxy (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39851
diff
changeset
|
1322 """Obtain the size of tracked data. |
9534fe1e5d28
manifest: add rawsize() proxy (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39851
diff
changeset
|
1323 |
42779
83d090ebec0c
rawdata: update callers in repository
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42727
diff
changeset
|
1324 Is equivalent to ``len(m.rawdata(node))``. |
39858
9534fe1e5d28
manifest: add rawsize() proxy (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39851
diff
changeset
|
1325 |
9534fe1e5d28
manifest: add rawsize() proxy (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39851
diff
changeset
|
1326 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
|
1327 """ |
9534fe1e5d28
manifest: add rawsize() proxy (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39851
diff
changeset
|
1328 |
39314
7f5e6d3e9032
manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39244
diff
changeset
|
1329 def getstrippoint(minlink): |
7f5e6d3e9032
manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39244
diff
changeset
|
1330 """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
|
1331 |
7f5e6d3e9032
manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39244
diff
changeset
|
1332 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
|
1333 """ |
7f5e6d3e9032
manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39244
diff
changeset
|
1334 |
7f5e6d3e9032
manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39244
diff
changeset
|
1335 def strip(minlink, transaction): |
7f5e6d3e9032
manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39244
diff
changeset
|
1336 """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
|
1337 |
7f5e6d3e9032
manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39244
diff
changeset
|
1338 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
|
1339 """ |
7f5e6d3e9032
manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39244
diff
changeset
|
1340 |
7f5e6d3e9032
manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39244
diff
changeset
|
1341 def checksize(): |
7f5e6d3e9032
manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39244
diff
changeset
|
1342 """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
|
1343 |
7f5e6d3e9032
manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39244
diff
changeset
|
1344 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
|
1345 """ |
7f5e6d3e9032
manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39244
diff
changeset
|
1346 |
7f5e6d3e9032
manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39244
diff
changeset
|
1347 def files(): |
7f5e6d3e9032
manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39244
diff
changeset
|
1348 """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
|
1349 |
7f5e6d3e9032
manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39244
diff
changeset
|
1350 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
|
1351 for this functionality. |
7f5e6d3e9032
manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39244
diff
changeset
|
1352 """ |
7f5e6d3e9032
manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39244
diff
changeset
|
1353 |
7f5e6d3e9032
manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39244
diff
changeset
|
1354 def deltaparent(rev): |
7f5e6d3e9032
manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39244
diff
changeset
|
1355 """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
|
1356 |
7f5e6d3e9032
manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39244
diff
changeset
|
1357 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
|
1358 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
|
1359 """ |
7f5e6d3e9032
manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39244
diff
changeset
|
1360 |
7f5e6d3e9032
manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39244
diff
changeset
|
1361 def clone(tr, dest, **kwargs): |
7f5e6d3e9032
manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39244
diff
changeset
|
1362 """Clone this instance to another.""" |
7f5e6d3e9032
manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39244
diff
changeset
|
1363 |
7f5e6d3e9032
manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39244
diff
changeset
|
1364 def clearcaches(clear_persisted_data=False): |
7f5e6d3e9032
manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39244
diff
changeset
|
1365 """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
|
1366 |
7f5e6d3e9032
manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39244
diff
changeset
|
1367 def dirlog(d): |
7f5e6d3e9032
manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39244
diff
changeset
|
1368 """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
|
1369 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43032
diff
changeset
|
1370 def add( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43032
diff
changeset
|
1371 m, transaction, link, p1, p2, added, removed, readtree=None, match=None |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43032
diff
changeset
|
1372 ): |
39314
7f5e6d3e9032
manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39244
diff
changeset
|
1373 """Add a revision to storage. |
7f5e6d3e9032
manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39244
diff
changeset
|
1374 |
7f5e6d3e9032
manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39244
diff
changeset
|
1375 ``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
|
1376 |
7f5e6d3e9032
manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39244
diff
changeset
|
1377 ``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
|
1378 |
7f5e6d3e9032
manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39244
diff
changeset
|
1379 ``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
|
1380 |
7f5e6d3e9032
manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39244
diff
changeset
|
1381 ``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
|
1382 respectively. |
39668
24870f1be088
narrow: when writing treemanifests, skip inspecting directories outside narrow
spectral <spectral@google.com>
parents:
39315
diff
changeset
|
1383 |
24870f1be088
narrow: when writing treemanifests, skip inspecting directories outside narrow
spectral <spectral@google.com>
parents:
39315
diff
changeset
|
1384 ``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
|
1385 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
|
1386 treemanifets. |
24870f1be088
narrow: when writing treemanifests, skip inspecting directories outside narrow
spectral <spectral@google.com>
parents:
39315
diff
changeset
|
1387 |
24870f1be088
narrow: when writing treemanifests, skip inspecting directories outside narrow
spectral <spectral@google.com>
parents:
39315
diff
changeset
|
1388 ``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
|
1389 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
|
1390 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
|
1391 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
|
1392 """ |
7f5e6d3e9032
manifest: proxy to revlog instance instead of inheriting
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39244
diff
changeset
|
1393 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43032
diff
changeset
|
1394 def storageinfo( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43032
diff
changeset
|
1395 exclusivefiles=False, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43032
diff
changeset
|
1396 sharedfiles=False, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43032
diff
changeset
|
1397 revisionscount=False, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43032
diff
changeset
|
1398 trackedsize=False, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43032
diff
changeset
|
1399 storedsize=False, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43032
diff
changeset
|
1400 ): |
39869
14e500b58263
revlog: add method for obtaining storage info (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39867
diff
changeset
|
1401 """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
|
1402 |
14e500b58263
revlog: add method for obtaining storage info (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39867
diff
changeset
|
1403 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
|
1404 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
|
1405 """ |
14e500b58263
revlog: add method for obtaining storage info (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39867
diff
changeset
|
1406 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43032
diff
changeset
|
1407 |
38530
c82ea938efbb
repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38509
diff
changeset
|
1408 class imanifestlog(interfaceutil.Interface): |
39240
2af6b2d8d1d8
repository: clarify role of imanifestlog
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39235
diff
changeset
|
1409 """Interface representing a collection of manifest snapshots. |
2af6b2d8d1d8
repository: clarify role of imanifestlog
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39235
diff
changeset
|
1410 |
2af6b2d8d1d8
repository: clarify role of imanifestlog
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39235
diff
changeset
|
1411 Represents the root manifest in a repository. |
2af6b2d8d1d8
repository: clarify role of imanifestlog
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39235
diff
changeset
|
1412 |
2af6b2d8d1d8
repository: clarify role of imanifestlog
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39235
diff
changeset
|
1413 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
|
1414 tree manifests. |
2af6b2d8d1d8
repository: clarify role of imanifestlog
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39235
diff
changeset
|
1415 """ |
38530
c82ea938efbb
repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38509
diff
changeset
|
1416 |
46780
6266d19556ad
node: introduce nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents:
46713
diff
changeset
|
1417 nodeconstants = interfaceutil.Attribute( |
6266d19556ad
node: introduce nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents:
46713
diff
changeset
|
1418 """nodeconstants used by the current repository.""" |
6266d19556ad
node: introduce nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents:
46713
diff
changeset
|
1419 ) |
6266d19556ad
node: introduce nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents:
46713
diff
changeset
|
1420 |
38530
c82ea938efbb
repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38509
diff
changeset
|
1421 def __getitem__(node): |
c82ea938efbb
repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38509
diff
changeset
|
1422 """Obtain a manifest instance for a given binary node. |
c82ea938efbb
repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38509
diff
changeset
|
1423 |
c82ea938efbb
repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38509
diff
changeset
|
1424 Equivalent to calling ``self.get('', node)``. |
c82ea938efbb
repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38509
diff
changeset
|
1425 |
c82ea938efbb
repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38509
diff
changeset
|
1426 The returned object conforms to the ``imanifestrevisionstored`` |
c82ea938efbb
repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38509
diff
changeset
|
1427 interface. |
c82ea938efbb
repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38509
diff
changeset
|
1428 """ |
c82ea938efbb
repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38509
diff
changeset
|
1429 |
39235
43387fd2aa1f
manifest: rename dir to tree to avoid shadowing built-in
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39234
diff
changeset
|
1430 def get(tree, node, verify=True): |
38530
c82ea938efbb
repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38509
diff
changeset
|
1431 """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
|
1432 |
c82ea938efbb
repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38509
diff
changeset
|
1433 ``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
|
1434 the only manifest if flat manifests are being used). |
c82ea938efbb
repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38509
diff
changeset
|
1435 |
39235
43387fd2aa1f
manifest: rename dir to tree to avoid shadowing built-in
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39234
diff
changeset
|
1436 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
|
1437 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
|
1438 (requires tree manifests). |
38530
c82ea938efbb
repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38509
diff
changeset
|
1439 |
c82ea938efbb
repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38509
diff
changeset
|
1440 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
|
1441 known. |
c82ea938efbb
repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38509
diff
changeset
|
1442 |
c82ea938efbb
repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38509
diff
changeset
|
1443 The returned object conforms to the ``imanifestrevisionstored`` |
c82ea938efbb
repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38509
diff
changeset
|
1444 interface. |
c82ea938efbb
repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38509
diff
changeset
|
1445 """ |
c82ea938efbb
repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38509
diff
changeset
|
1446 |
39244
73cf21b2e8a6
manifest: add getstorage() to manifestlog and use it globally
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39241
diff
changeset
|
1447 def getstorage(tree): |
73cf21b2e8a6
manifest: add getstorage() to manifestlog and use it globally
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39241
diff
changeset
|
1448 """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
|
1449 |
73cf21b2e8a6
manifest: add getstorage() to manifestlog and use it globally
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39241
diff
changeset
|
1450 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
|
1451 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
|
1452 |
73cf21b2e8a6
manifest: add getstorage() to manifestlog and use it globally
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39241
diff
changeset
|
1453 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
|
1454 """ |
73cf21b2e8a6
manifest: add getstorage() to manifestlog and use it globally
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39241
diff
changeset
|
1455 |
38530
c82ea938efbb
repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38509
diff
changeset
|
1456 def clearcaches(): |
c82ea938efbb
repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38509
diff
changeset
|
1457 """Clear caches associated with this collection.""" |
c82ea938efbb
repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38509
diff
changeset
|
1458 |
38555
f2f9bacf0587
manifest: define and implement rev() on manifestlog
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38530
diff
changeset
|
1459 def rev(node): |
f2f9bacf0587
manifest: define and implement rev() on manifestlog
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38530
diff
changeset
|
1460 """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
|
1461 |
f2f9bacf0587
manifest: define and implement rev() on manifestlog
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38530
diff
changeset
|
1462 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
|
1463 """ |
f2f9bacf0587
manifest: define and implement rev() on manifestlog
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38530
diff
changeset
|
1464 |
44787
97ebdb192b00
nodemap: also warm manifest nodemap with other caches
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44663
diff
changeset
|
1465 def update_caches(transaction): |
97ebdb192b00
nodemap: also warm manifest nodemap with other caches
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
44663
diff
changeset
|
1466 """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
|
1467 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43032
diff
changeset
|
1468 |
39764
e4e881572382
localrepo: iteratively derive local repository type
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39700
diff
changeset
|
1469 class ilocalrepositoryfilestorage(interfaceutil.Interface): |
e4e881572382
localrepo: iteratively derive local repository type
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39700
diff
changeset
|
1470 """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
|
1471 |
e4e881572382
localrepo: iteratively derive local repository type
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39700
diff
changeset
|
1472 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
|
1473 tracked file path. |
e4e881572382
localrepo: iteratively derive local repository type
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39700
diff
changeset
|
1474 """ |
e4e881572382
localrepo: iteratively derive local repository type
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39700
diff
changeset
|
1475 |
e4e881572382
localrepo: iteratively derive local repository type
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39700
diff
changeset
|
1476 def file(f): |
e4e881572382
localrepo: iteratively derive local repository type
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39700
diff
changeset
|
1477 """Obtain a filelog for a tracked path. |
e4e881572382
localrepo: iteratively derive local repository type
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39700
diff
changeset
|
1478 |
e4e881572382
localrepo: iteratively derive local repository type
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39700
diff
changeset
|
1479 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
|
1480 """ |
e4e881572382
localrepo: iteratively derive local repository type
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39700
diff
changeset
|
1481 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43032
diff
changeset
|
1482 |
39764
e4e881572382
localrepo: iteratively derive local repository type
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39700
diff
changeset
|
1483 class ilocalrepositorymain(interfaceutil.Interface): |
e4e881572382
localrepo: iteratively derive local repository type
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39700
diff
changeset
|
1484 """Main interface for local repositories. |
37181
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
1485 |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
1486 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
|
1487 """ |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
1488 |
46780
6266d19556ad
node: introduce nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents:
46713
diff
changeset
|
1489 nodeconstants = interfaceutil.Attribute( |
6266d19556ad
node: introduce nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents:
46713
diff
changeset
|
1490 """Constant nodes matching the hash function used by the repository.""" |
6266d19556ad
node: introduce nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents:
46713
diff
changeset
|
1491 ) |
6266d19556ad
node: introduce nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents:
46713
diff
changeset
|
1492 nullid = interfaceutil.Attribute( |
6266d19556ad
node: introduce nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents:
46713
diff
changeset
|
1493 """null revision for the hash function used by the repository.""" |
6266d19556ad
node: introduce nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents:
46713
diff
changeset
|
1494 ) |
6266d19556ad
node: introduce nodeconstants class
Joerg Sonnenberger <joerg@bec.de>
parents:
46713
diff
changeset
|
1495 |
37810
856f381ad74b
interfaceutil: module to stub out zope.interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37650
diff
changeset
|
1496 supported = interfaceutil.Attribute( |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43032
diff
changeset
|
1497 """Set of requirements that this repo is capable of opening.""" |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43032
diff
changeset
|
1498 ) |
37181
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
1499 |
37810
856f381ad74b
interfaceutil: module to stub out zope.interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37650
diff
changeset
|
1500 requirements = interfaceutil.Attribute( |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43032
diff
changeset
|
1501 """Set of requirements this repo uses.""" |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43032
diff
changeset
|
1502 ) |
37181
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
1503 |
39850
d89d5bc06eaa
localrepo: define "features" on repository instances (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39844
diff
changeset
|
1504 features = interfaceutil.Attribute( |
d89d5bc06eaa
localrepo: define "features" on repository instances (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39844
diff
changeset
|
1505 """Set of "features" this repository supports. |
d89d5bc06eaa
localrepo: define "features" on repository instances (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39844
diff
changeset
|
1506 |
d89d5bc06eaa
localrepo: define "features" on repository instances (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39844
diff
changeset
|
1507 A "feature" is a loosely-defined term. It can refer to a feature |
d89d5bc06eaa
localrepo: define "features" on repository instances (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39844
diff
changeset
|
1508 in the classical sense or can describe an implementation detail |
d89d5bc06eaa
localrepo: define "features" on repository instances (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39844
diff
changeset
|
1509 of the repository. For example, a ``readonly`` feature may denote |
d89d5bc06eaa
localrepo: define "features" on repository instances (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39844
diff
changeset
|
1510 the repository as read-only. Or a ``revlogfilestore`` feature may |
d89d5bc06eaa
localrepo: define "features" on repository instances (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39844
diff
changeset
|
1511 denote that the repository is using revlogs for file storage. |
d89d5bc06eaa
localrepo: define "features" on repository instances (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39844
diff
changeset
|
1512 |
d89d5bc06eaa
localrepo: define "features" on repository instances (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39844
diff
changeset
|
1513 The intent of features is to provide a machine-queryable mechanism |
d89d5bc06eaa
localrepo: define "features" on repository instances (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39844
diff
changeset
|
1514 for repo consumers to test for various repository characteristics. |
d89d5bc06eaa
localrepo: define "features" on repository instances (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39844
diff
changeset
|
1515 |
d89d5bc06eaa
localrepo: define "features" on repository instances (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39844
diff
changeset
|
1516 Features are similar to ``requirements``. The main difference is that |
d89d5bc06eaa
localrepo: define "features" on repository instances (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39844
diff
changeset
|
1517 requirements are stored on-disk and represent requirements to open the |
d89d5bc06eaa
localrepo: define "features" on repository instances (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39844
diff
changeset
|
1518 repository. Features are more run-time capabilities of the repository |
d89d5bc06eaa
localrepo: define "features" on repository instances (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39844
diff
changeset
|
1519 and more granular capabilities (which may be derived from requirements). |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43032
diff
changeset
|
1520 """ |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43032
diff
changeset
|
1521 ) |
39850
d89d5bc06eaa
localrepo: define "features" on repository instances (API)
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39844
diff
changeset
|
1522 |
37810
856f381ad74b
interfaceutil: module to stub out zope.interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37650
diff
changeset
|
1523 filtername = interfaceutil.Attribute( |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43032
diff
changeset
|
1524 """Name of the repoview that is active on this repo.""" |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43032
diff
changeset
|
1525 ) |
37181
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
1526 |
50281
f34887316f1f
undo-files: factor the vfs map in a repository property
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49753
diff
changeset
|
1527 vfs_map = interfaceutil.Attribute( |
f34887316f1f
undo-files: factor the vfs map in a repository property
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49753
diff
changeset
|
1528 """a bytes-key → vfs mapping used by transaction and others""" |
f34887316f1f
undo-files: factor the vfs map in a repository property
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49753
diff
changeset
|
1529 ) |
f34887316f1f
undo-files: factor the vfs map in a repository property
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49753
diff
changeset
|
1530 |
37810
856f381ad74b
interfaceutil: module to stub out zope.interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37650
diff
changeset
|
1531 wvfs = interfaceutil.Attribute( |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43032
diff
changeset
|
1532 """VFS used to access the working directory.""" |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43032
diff
changeset
|
1533 ) |
37181
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
1534 |
37810
856f381ad74b
interfaceutil: module to stub out zope.interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37650
diff
changeset
|
1535 vfs = interfaceutil.Attribute( |
37181
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
1536 """VFS rooted at the .hg directory. |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
1537 |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
1538 Used to access repository data not in the store. |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43032
diff
changeset
|
1539 """ |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43032
diff
changeset
|
1540 ) |
37181
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
1541 |
37810
856f381ad74b
interfaceutil: module to stub out zope.interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37650
diff
changeset
|
1542 svfs = interfaceutil.Attribute( |
37181
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
1543 """VFS rooted at the store. |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
1544 |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
1545 Used to access repository data in the store. Typically .hg/store. |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
1546 But can point elsewhere if the store is shared. |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43032
diff
changeset
|
1547 """ |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43032
diff
changeset
|
1548 ) |
37181
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
1549 |
37810
856f381ad74b
interfaceutil: module to stub out zope.interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37650
diff
changeset
|
1550 root = interfaceutil.Attribute( |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43032
diff
changeset
|
1551 """Path to the root of the working directory.""" |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43032
diff
changeset
|
1552 ) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43032
diff
changeset
|
1553 |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43032
diff
changeset
|
1554 path = interfaceutil.Attribute("""Path to the .hg directory.""") |
37181
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
1555 |
37810
856f381ad74b
interfaceutil: module to stub out zope.interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37650
diff
changeset
|
1556 origroot = interfaceutil.Attribute( |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43032
diff
changeset
|
1557 """The filesystem path that was used to construct the repo.""" |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43032
diff
changeset
|
1558 ) |
37181
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
1559 |
37810
856f381ad74b
interfaceutil: module to stub out zope.interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37650
diff
changeset
|
1560 auditor = interfaceutil.Attribute( |
37181
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
1561 """A pathauditor for the working directory. |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
1562 |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
1563 This checks if a path refers to a nested repository. |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
1564 |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
1565 Operates on the filesystem. |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43032
diff
changeset
|
1566 """ |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43032
diff
changeset
|
1567 ) |
37181
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
1568 |
37810
856f381ad74b
interfaceutil: module to stub out zope.interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37650
diff
changeset
|
1569 nofsauditor = interfaceutil.Attribute( |
37181
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
1570 """A pathauditor for the working directory. |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
1571 |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
1572 This is like ``auditor`` except it doesn't do filesystem checks. |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43032
diff
changeset
|
1573 """ |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43032
diff
changeset
|
1574 ) |
37181
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
1575 |
37810
856f381ad74b
interfaceutil: module to stub out zope.interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37650
diff
changeset
|
1576 baseui = interfaceutil.Attribute( |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43032
diff
changeset
|
1577 """Original ui instance passed into constructor.""" |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43032
diff
changeset
|
1578 ) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43032
diff
changeset
|
1579 |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43032
diff
changeset
|
1580 ui = interfaceutil.Attribute("""Main ui instance for this instance.""") |
37181
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
1581 |
37810
856f381ad74b
interfaceutil: module to stub out zope.interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37650
diff
changeset
|
1582 sharedpath = interfaceutil.Attribute( |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43032
diff
changeset
|
1583 """Path to the .hg directory of the repo this repo was shared from.""" |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43032
diff
changeset
|
1584 ) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43032
diff
changeset
|
1585 |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43032
diff
changeset
|
1586 store = interfaceutil.Attribute("""A store instance.""") |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43032
diff
changeset
|
1587 |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43032
diff
changeset
|
1588 spath = interfaceutil.Attribute("""Path to the store.""") |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43032
diff
changeset
|
1589 |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43032
diff
changeset
|
1590 sjoin = interfaceutil.Attribute("""Alias to self.store.join.""") |
37181
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
1591 |
37810
856f381ad74b
interfaceutil: module to stub out zope.interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37650
diff
changeset
|
1592 cachevfs = interfaceutil.Attribute( |
37181
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
1593 """A VFS used to access the cache directory. |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
1594 |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
1595 Typically .hg/cache. |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43032
diff
changeset
|
1596 """ |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43032
diff
changeset
|
1597 ) |
37181
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
1598 |
40795
e1c3a2e9df59
repo: add a `wcachevfs` to access the `.hg/wcache/` directory
Boris Feld <boris.feld@octobus.net>
parents:
40432
diff
changeset
|
1599 wcachevfs = interfaceutil.Attribute( |
e1c3a2e9df59
repo: add a `wcachevfs` to access the `.hg/wcache/` directory
Boris Feld <boris.feld@octobus.net>
parents:
40432
diff
changeset
|
1600 """A VFS used to access the cache directory dedicated to working copy |
e1c3a2e9df59
repo: add a `wcachevfs` to access the `.hg/wcache/` directory
Boris Feld <boris.feld@octobus.net>
parents:
40432
diff
changeset
|
1601 |
e1c3a2e9df59
repo: add a `wcachevfs` to access the `.hg/wcache/` directory
Boris Feld <boris.feld@octobus.net>
parents:
40432
diff
changeset
|
1602 Typically .hg/wcache. |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43032
diff
changeset
|
1603 """ |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43032
diff
changeset
|
1604 ) |
40795
e1c3a2e9df59
repo: add a `wcachevfs` to access the `.hg/wcache/` directory
Boris Feld <boris.feld@octobus.net>
parents:
40432
diff
changeset
|
1605 |
37810
856f381ad74b
interfaceutil: module to stub out zope.interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37650
diff
changeset
|
1606 filteredrevcache = interfaceutil.Attribute( |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43032
diff
changeset
|
1607 """Holds sets of revisions to be filtered.""" |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43032
diff
changeset
|
1608 ) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43032
diff
changeset
|
1609 |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43032
diff
changeset
|
1610 names = interfaceutil.Attribute("""A ``namespaces`` instance.""") |
37181
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
1611 |
43142
beed7ce61681
sidedatacopies: write copies information in sidedata when applicable
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43077
diff
changeset
|
1612 filecopiesmode = interfaceutil.Attribute( |
beed7ce61681
sidedatacopies: write copies information in sidedata when applicable
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43077
diff
changeset
|
1613 """The way files copies should be dealt with in this repo.""" |
beed7ce61681
sidedatacopies: write copies information in sidedata when applicable
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43077
diff
changeset
|
1614 ) |
beed7ce61681
sidedatacopies: write copies information in sidedata when applicable
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43077
diff
changeset
|
1615 |
37181
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
1616 def close(): |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
1617 """Close the handle on this repository.""" |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
1618 |
49753
ff7134e03629
peer: have `repo.peer` take an optional `path` argument
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49752
diff
changeset
|
1619 def peer(path=None): |
37181
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
1620 """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
|
1621 |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
1622 def unfiltered(): |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
1623 """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
|
1624 |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
1625 def filtered(name, visibilityexceptions=None): |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
1626 """Obtain a named view of this repository.""" |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
1627 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43032
diff
changeset
|
1628 obsstore = interfaceutil.Attribute("""A store of obsolescence data.""") |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43032
diff
changeset
|
1629 |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43032
diff
changeset
|
1630 changelog = interfaceutil.Attribute("""A handle on the changelog revlog.""") |
37181
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
1631 |
37810
856f381ad74b
interfaceutil: module to stub out zope.interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37650
diff
changeset
|
1632 manifestlog = interfaceutil.Attribute( |
38530
c82ea938efbb
repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38509
diff
changeset
|
1633 """An instance conforming to the ``imanifestlog`` interface. |
c82ea938efbb
repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38509
diff
changeset
|
1634 |
c82ea938efbb
repository: define manifest interfaces
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38509
diff
changeset
|
1635 Provides access to manifests for the repository. |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43032
diff
changeset
|
1636 """ |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43032
diff
changeset
|
1637 ) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43032
diff
changeset
|
1638 |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43032
diff
changeset
|
1639 dirstate = interfaceutil.Attribute("""Working directory state.""") |
37181
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
1640 |
37810
856f381ad74b
interfaceutil: module to stub out zope.interface
Gregory Szorc <gregory.szorc@gmail.com>
parents:
37650
diff
changeset
|
1641 narrowpats = interfaceutil.Attribute( |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43032
diff
changeset
|
1642 """Matcher patterns for this repository's narrowspec.""" |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43032
diff
changeset
|
1643 ) |
37181
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
1644 |
41029
b2de94e59702
repository: update interface signature of narrowmatch()
Martin von Zweigbergk <martinvonz@google.com>
parents:
40795
diff
changeset
|
1645 def narrowmatch(match=None, includeexact=False): |
37181
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
1646 """Obtain a matcher for the narrowspec.""" |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
1647 |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
1648 def setnarrowpats(newincludes, newexcludes): |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
1649 """Define the narrowspec for this repository.""" |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
1650 |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
1651 def __getitem__(changeid): |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
1652 """Try to resolve a changectx.""" |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
1653 |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
1654 def __contains__(changeid): |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
1655 """Whether a changeset exists.""" |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
1656 |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
1657 def __nonzero__(): |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
1658 """Always returns True.""" |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
1659 return True |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
1660 |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
1661 __bool__ = __nonzero__ |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
1662 |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
1663 def __len__(): |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
1664 """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
|
1665 |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
1666 def __iter__(): |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
1667 """Iterate over revisions in the changelog.""" |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
1668 |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
1669 def revs(expr, *args): |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
1670 """Evaluate a revset. |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
1671 |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
1672 Emits revisions. |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
1673 """ |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
1674 |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
1675 def set(expr, *args): |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
1676 """Evaluate a revset. |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
1677 |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
1678 Emits changectx instances. |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
1679 """ |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
1680 |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
1681 def anyrevs(specs, user=False, localalias=None): |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
1682 """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
|
1683 |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
1684 def url(): |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
1685 """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
|
1686 |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
1687 def hook(name, throw=False, **args): |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
1688 """Call a hook.""" |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
1689 |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
1690 def tags(): |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
1691 """Return a mapping of tag to node.""" |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
1692 |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
1693 def tagtype(tagname): |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
1694 """Return the type of a given tag.""" |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
1695 |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
1696 def tagslist(): |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
1697 """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
|
1698 |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
1699 def nodetags(node): |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
1700 """Return the tags associated with a node.""" |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
1701 |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
1702 def nodebookmarks(node): |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
1703 """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
|
1704 |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
1705 def branchmap(): |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
1706 """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
|
1707 |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
1708 def revbranchcache(): |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
1709 pass |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
1710 |
46371
0903d6b9b1df
repository: introduce register_changeset callback
Joerg Sonnenberger <joerg@bec.de>
parents:
45946
diff
changeset
|
1711 def register_changeset(rev, changelogrevision): |
0903d6b9b1df
repository: introduce register_changeset callback
Joerg Sonnenberger <joerg@bec.de>
parents:
45946
diff
changeset
|
1712 """Extension point for caches for new nodes. |
0903d6b9b1df
repository: introduce register_changeset callback
Joerg Sonnenberger <joerg@bec.de>
parents:
45946
diff
changeset
|
1713 |
0903d6b9b1df
repository: introduce register_changeset callback
Joerg Sonnenberger <joerg@bec.de>
parents:
45946
diff
changeset
|
1714 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
|
1715 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
|
1716 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
|
1717 pass |
0903d6b9b1df
repository: introduce register_changeset callback
Joerg Sonnenberger <joerg@bec.de>
parents:
45946
diff
changeset
|
1718 |
37181
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
1719 def branchtip(branchtip, ignoremissing=False): |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
1720 """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
|
1721 |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
1722 def lookup(key): |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
1723 """Resolve the node for a revision.""" |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
1724 |
37351
fdd22bf6398f
localrepo: drop "remote" argument from lookupbranch() (API)
Martin von Zweigbergk <martinvonz@google.com>
parents:
37320
diff
changeset
|
1725 def lookupbranch(key): |
37181
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
1726 """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
|
1727 |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
1728 def known(nodes): |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
1729 """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
|
1730 |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
1731 Returns a list of bools. |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
1732 """ |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
1733 |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
1734 def local(): |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
1735 """Whether the repository is local.""" |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
1736 return True |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
1737 |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
1738 def publishing(): |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
1739 """Whether the repository is a publishing repository.""" |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
1740 |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
1741 def cancopy(): |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
1742 pass |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
1743 |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
1744 def shared(): |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
1745 """The type of shared repository or None.""" |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
1746 |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
1747 def wjoin(f, *insidef): |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
1748 """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
|
1749 |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
1750 def setparents(p1, p2): |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
1751 """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
|
1752 |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
1753 def filectx(path, changeid=None, fileid=None): |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
1754 """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
|
1755 |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
1756 def getcwd(): |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
1757 """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
|
1758 |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
1759 def pathto(f, cwd=None): |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
1760 """Obtain the relative path to a file.""" |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
1761 |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
1762 def adddatafilter(name, fltr): |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
1763 pass |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
1764 |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
1765 def wread(filename): |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
1766 """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
|
1767 |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
1768 def wwrite(filename, data, flags, backgroundclose=False, **kwargs): |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
1769 """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
|
1770 |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
1771 def wwritedata(filename, data): |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
1772 """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
|
1773 |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
1774 def currenttransaction(): |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
1775 """Obtain the current transaction instance or None.""" |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
1776 |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
1777 def transaction(desc, report=None): |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
1778 """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
|
1779 |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
1780 def undofiles(): |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
1781 """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
|
1782 |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
1783 def recover(): |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
1784 """Roll back an interrupted transaction.""" |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
1785 |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
1786 def rollback(dryrun=False, force=False): |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
1787 """Undo the last transaction. |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
1788 |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
1789 DANGEROUS. |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
1790 """ |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
1791 |
48696
bf3da4e02087
interfaces: add missing caches kwarg of localrepo.updatecaches()
Anton Shestakov <av6@dwimlabs.net>
parents:
48604
diff
changeset
|
1792 def updatecaches(tr=None, full=False, caches=None): |
37181
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
1793 """Warm repo caches.""" |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
1794 |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
1795 def invalidatecaches(): |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
1796 """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
|
1797 |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
1798 def invalidatevolatilesets(): |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
1799 pass |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
1800 |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
1801 def invalidatedirstate(): |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
1802 """Invalidate the dirstate.""" |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
1803 |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
1804 def invalidate(clearfilecache=False): |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
1805 pass |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
1806 |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
1807 def invalidateall(): |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
1808 pass |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
1809 |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
1810 def lock(wait=True): |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
1811 """Lock the repository store and return a lock instance.""" |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
1812 |
50323
6901916458bd
localrepo: add a `currentlock` method
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50281
diff
changeset
|
1813 def currentlock(): |
6901916458bd
localrepo: add a `currentlock` method
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
50281
diff
changeset
|
1814 """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
|
1815 |
37181
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
1816 def wlock(wait=True): |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
1817 """Lock the non-store parts of the repository.""" |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
1818 |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
1819 def currentwlock(): |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
1820 """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
|
1821 |
43712
f965b1027fb0
commit: drop unused "vdirs" argument from repo.checkcommitpatterns()
Martin von Zweigbergk <martinvonz@google.com>
parents:
43142
diff
changeset
|
1822 def checkcommitpatterns(wctx, match, status, fail): |
37181
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
1823 pass |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
1824 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43032
diff
changeset
|
1825 def commit( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1826 text=b'', |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43032
diff
changeset
|
1827 user=None, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43032
diff
changeset
|
1828 date=None, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43032
diff
changeset
|
1829 match=None, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43032
diff
changeset
|
1830 force=False, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43032
diff
changeset
|
1831 editor=False, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43032
diff
changeset
|
1832 extra=None, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43032
diff
changeset
|
1833 ): |
37181
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
1834 """Add a new revision to the repository.""" |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
1835 |
42620
d98ec36be808
convert: add a config option to help doing identity hg->hg conversion
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents:
42158
diff
changeset
|
1836 def commitctx(ctx, error=False, origctx=None): |
37181
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
1837 """Commit a commitctx instance to the repository.""" |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
1838 |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
1839 def destroying(): |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
1840 """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
|
1841 |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
1842 def destroyed(): |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
1843 """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
|
1844 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43032
diff
changeset
|
1845 def status( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1846 node1=b'.', |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43032
diff
changeset
|
1847 node2=None, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43032
diff
changeset
|
1848 match=None, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43032
diff
changeset
|
1849 ignored=False, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43032
diff
changeset
|
1850 clean=False, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43032
diff
changeset
|
1851 unknown=False, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43032
diff
changeset
|
1852 listsubrepos=False, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43032
diff
changeset
|
1853 ): |
37181
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
1854 """Convenience method to call repo[x].status().""" |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
1855 |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
1856 def addpostdsstatus(ps): |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
1857 pass |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
1858 |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
1859 def postdsstatus(): |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
1860 pass |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
1861 |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
1862 def clearpostdsstatus(): |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
1863 pass |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
1864 |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
1865 def heads(start=None): |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
1866 """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
|
1867 |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
1868 def branchheads(branch=None, start=None, closed=False): |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
1869 pass |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
1870 |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
1871 def branches(nodes): |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
1872 pass |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
1873 |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
1874 def between(pairs): |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
1875 pass |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
1876 |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
1877 def checkpush(pushop): |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
1878 pass |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
1879 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43032
diff
changeset
|
1880 prepushoutgoinghooks = interfaceutil.Attribute("""util.hooks instance.""") |
37181
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
1881 |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
1882 def pushkey(namespace, key, old, new): |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
1883 pass |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
1884 |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
1885 def listkeys(namespace): |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
1886 pass |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
1887 |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
1888 def debugwireargs(one, two, three=None, four=None, five=None): |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
1889 pass |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
1890 |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
1891 def savecommitmessage(text): |
0dfb5672f015
repository: define interface for local repositories
Gregory Szorc <gregory.szorc@gmail.com>
parents:
33802
diff
changeset
|
1892 pass |
39764
e4e881572382
localrepo: iteratively derive local repository type
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39700
diff
changeset
|
1893 |
47083
81eb7091c494
sidedata: add a way of replacing an existing sidedata computer
Raphaël Gomès <rgomes@octobus.net>
parents:
47078
diff
changeset
|
1894 def register_sidedata_computer( |
81eb7091c494
sidedata: add a way of replacing an existing sidedata computer
Raphaël Gomès <rgomes@octobus.net>
parents:
47078
diff
changeset
|
1895 kind, category, keys, computer, flags, replace=False |
81eb7091c494
sidedata: add a way of replacing an existing sidedata computer
Raphaël Gomès <rgomes@octobus.net>
parents:
47078
diff
changeset
|
1896 ): |
46713
bc2519513ae0
sidedata-exchange: add `wanted_sidedata` and `sidedata_computers` to repos
Raphaël Gomès <rgomes@octobus.net>
parents:
46712
diff
changeset
|
1897 pass |
bc2519513ae0
sidedata-exchange: add `wanted_sidedata` and `sidedata_computers` to repos
Raphaël Gomès <rgomes@octobus.net>
parents:
46712
diff
changeset
|
1898 |
bc2519513ae0
sidedata-exchange: add `wanted_sidedata` and `sidedata_computers` to repos
Raphaël Gomès <rgomes@octobus.net>
parents:
46712
diff
changeset
|
1899 def register_wanted_sidedata(category): |
bc2519513ae0
sidedata-exchange: add `wanted_sidedata` and `sidedata_computers` to repos
Raphaël Gomès <rgomes@octobus.net>
parents:
46712
diff
changeset
|
1900 pass |
bc2519513ae0
sidedata-exchange: add `wanted_sidedata` and `sidedata_computers` to repos
Raphaël Gomès <rgomes@octobus.net>
parents:
46712
diff
changeset
|
1901 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43032
diff
changeset
|
1902 |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43032
diff
changeset
|
1903 class completelocalrepository( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43032
diff
changeset
|
1904 ilocalrepositorymain, ilocalrepositoryfilestorage |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43032
diff
changeset
|
1905 ): |
39764
e4e881572382
localrepo: iteratively derive local repository type
Gregory Szorc <gregory.szorc@gmail.com>
parents:
39700
diff
changeset
|
1906 """Complete interface for a local repository.""" |
40021
c537144fdbef
wireprotov2: support response caching
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40002
diff
changeset
|
1907 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43032
diff
changeset
|
1908 |
40021
c537144fdbef
wireprotov2: support response caching
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40002
diff
changeset
|
1909 class iwireprotocolcommandcacher(interfaceutil.Interface): |
c537144fdbef
wireprotov2: support response caching
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40002
diff
changeset
|
1910 """Represents a caching backend for wire protocol commands. |
c537144fdbef
wireprotov2: support response caching
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40002
diff
changeset
|
1911 |
c537144fdbef
wireprotov2: support response caching
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40002
diff
changeset
|
1912 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
|
1913 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
|
1914 command responses. Objects handle both cache writing and reading. |
c537144fdbef
wireprotov2: support response caching
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40002
diff
changeset
|
1915 This interface defines how that response caching mechanism works. |
c537144fdbef
wireprotov2: support response caching
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40002
diff
changeset
|
1916 |
c537144fdbef
wireprotov2: support response caching
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40002
diff
changeset
|
1917 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
|
1918 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
|
1919 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
|
1920 objects to an output layer. |
c537144fdbef
wireprotov2: support response caching
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40002
diff
changeset
|
1921 |
c537144fdbef
wireprotov2: support response caching
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40002
diff
changeset
|
1922 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
|
1923 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
|
1924 write responses to a cache for subsequent use. |
c537144fdbef
wireprotov2: support response caching
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40002
diff
changeset
|
1925 |
c537144fdbef
wireprotov2: support response caching
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40002
diff
changeset
|
1926 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
|
1927 to this interface: |
c537144fdbef
wireprotov2: support response caching
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40002
diff
changeset
|
1928 |
c537144fdbef
wireprotov2: support response caching
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40002
diff
changeset
|
1929 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
|
1930 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
|
1931 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
|
1932 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
|
1933 instance's ``adjustcachekeystate()`` method so the derivation |
c537144fdbef
wireprotov2: support response caching
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40002
diff
changeset
|
1934 can be influenced. |
c537144fdbef
wireprotov2: support response caching
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40002
diff
changeset
|
1935 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
|
1936 ``setcachekey()``. |
c537144fdbef
wireprotov2: support response caching
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40002
diff
changeset
|
1937 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
|
1938 the derived key in the cache. |
c537144fdbef
wireprotov2: support response caching
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40002
diff
changeset
|
1939 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
|
1940 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
|
1941 is discarded. |
c537144fdbef
wireprotov2: support response caching
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40002
diff
changeset
|
1942 8. The command function is invoked. |
c537144fdbef
wireprotov2: support response caching
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40002
diff
changeset
|
1943 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
|
1944 function. |
40279
4821affc154f
wireproto: fix incorrect function name in docstring
Connor Sheehan <sheehan@mozilla.com>
parents:
40171
diff
changeset
|
1945 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
|
1946 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
|
1947 |
c537144fdbef
wireprotov2: support response caching
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40002
diff
changeset
|
1948 Cache *key* derivation can be influenced by the instance. |
c537144fdbef
wireprotov2: support response caching
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40002
diff
changeset
|
1949 |
c537144fdbef
wireprotov2: support response caching
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40002
diff
changeset
|
1950 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
|
1951 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
|
1952 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
|
1953 data structure and feeding that output into a hasher. |
c537144fdbef
wireprotov2: support response caching
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40002
diff
changeset
|
1954 |
c537144fdbef
wireprotov2: support response caching
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40002
diff
changeset
|
1955 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
|
1956 via ``adjustcachekeystate()``. |
c537144fdbef
wireprotov2: support response caching
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40002
diff
changeset
|
1957 |
c537144fdbef
wireprotov2: support response caching
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40002
diff
changeset
|
1958 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
|
1959 ``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
|
1960 be consulted on subsequent operations that may require it. |
c537144fdbef
wireprotov2: support response caching
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40002
diff
changeset
|
1961 |
c537144fdbef
wireprotov2: support response caching
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40002
diff
changeset
|
1962 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
|
1963 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
|
1964 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
|
1965 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
|
1966 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
|
1967 the original Python objects, implementations typically call this function |
c537144fdbef
wireprotov2: support response caching
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40002
diff
changeset
|
1968 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
|
1969 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
|
1970 in a ``wireprototypes.encodedresponse`` instance to tell the output |
c537144fdbef
wireprotov2: support response caching
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40002
diff
changeset
|
1971 layer that they are pre-encoded. |
c537144fdbef
wireprotov2: support response caching
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40002
diff
changeset
|
1972 |
c537144fdbef
wireprotov2: support response caching
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40002
diff
changeset
|
1973 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
|
1974 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
|
1975 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
|
1976 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
|
1977 |
c537144fdbef
wireprotov2: support response caching
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40002
diff
changeset
|
1978 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
|
1979 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
|
1980 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
|
1981 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
|
1982 sorts. |
c537144fdbef
wireprotov2: support response caching
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40002
diff
changeset
|
1983 |
c537144fdbef
wireprotov2: support response caching
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40002
diff
changeset
|
1984 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
|
1985 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
|
1986 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
|
1987 output, this redundant encoding could add overhead. Implementations |
c537144fdbef
wireprotov2: support response caching
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40002
diff
changeset
|
1988 could wrap the encoded object data in ``wireprototypes.encodedresponse`` |
c537144fdbef
wireprotov2: support response caching
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40002
diff
changeset
|
1989 instances to avoid this overhead. |
c537144fdbef
wireprotov2: support response caching
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40002
diff
changeset
|
1990 """ |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
43032
diff
changeset
|
1991 |
40021
c537144fdbef
wireprotov2: support response caching
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40002
diff
changeset
|
1992 def __enter__(): |
c537144fdbef
wireprotov2: support response caching
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40002
diff
changeset
|
1993 """Marks the instance as active. |
c537144fdbef
wireprotov2: support response caching
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40002
diff
changeset
|
1994 |
c537144fdbef
wireprotov2: support response caching
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40002
diff
changeset
|
1995 Should return self. |
c537144fdbef
wireprotov2: support response caching
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40002
diff
changeset
|
1996 """ |
c537144fdbef
wireprotov2: support response caching
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40002
diff
changeset
|
1997 |
c537144fdbef
wireprotov2: support response caching
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40002
diff
changeset
|
1998 def __exit__(exctype, excvalue, exctb): |
c537144fdbef
wireprotov2: support response caching
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40002
diff
changeset
|
1999 """Called when cacher is no longer used. |
c537144fdbef
wireprotov2: support response caching
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40002
diff
changeset
|
2000 |
c537144fdbef
wireprotov2: support response caching
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40002
diff
changeset
|
2001 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
|
2002 disconnecting network sockets, aborting a partially cached response. |
c537144fdbef
wireprotov2: support response caching
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40002
diff
changeset
|
2003 """ |
c537144fdbef
wireprotov2: support response caching
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40002
diff
changeset
|
2004 |
c537144fdbef
wireprotov2: support response caching
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40002
diff
changeset
|
2005 def adjustcachekeystate(state): |
c537144fdbef
wireprotov2: support response caching
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40002
diff
changeset
|
2006 """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
|
2007 |
c537144fdbef
wireprotov2: support response caching
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40002
diff
changeset
|
2008 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
|
2009 |
c537144fdbef
wireprotov2: support response caching
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40002
diff
changeset
|
2010 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
|
2011 is wanted to influence key derivation. |
c537144fdbef
wireprotov2: support response caching
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40002
diff
changeset
|
2012 |
c537144fdbef
wireprotov2: support response caching
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40002
diff
changeset
|
2013 Implementations are *highly* encouraged to not modify or delete |
c537144fdbef
wireprotov2: support response caching
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40002
diff
changeset
|
2014 existing keys. |
c537144fdbef
wireprotov2: support response caching
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40002
diff
changeset
|
2015 """ |
c537144fdbef
wireprotov2: support response caching
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40002
diff
changeset
|
2016 |
c537144fdbef
wireprotov2: support response caching
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40002
diff
changeset
|
2017 def setcachekey(key): |
c537144fdbef
wireprotov2: support response caching
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40002
diff
changeset
|
2018 """Record the derived cache key for this request. |
c537144fdbef
wireprotov2: support response caching
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40002
diff
changeset
|
2019 |
c537144fdbef
wireprotov2: support response caching
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40002
diff
changeset
|
2020 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
|
2021 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
|
2022 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
|
2023 the cache. |
c537144fdbef
wireprotov2: support response caching
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40002
diff
changeset
|
2024 |
c537144fdbef
wireprotov2: support response caching
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40002
diff
changeset
|
2025 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
|
2026 instance. |
c537144fdbef
wireprotov2: support response caching
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40002
diff
changeset
|
2027 """ |
c537144fdbef
wireprotov2: support response caching
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40002
diff
changeset
|
2028 |
c537144fdbef
wireprotov2: support response caching
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40002
diff
changeset
|
2029 def lookup(): |
c537144fdbef
wireprotov2: support response caching
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40002
diff
changeset
|
2030 """Attempt to resolve an entry in the cache. |
c537144fdbef
wireprotov2: support response caching
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40002
diff
changeset
|
2031 |
c537144fdbef
wireprotov2: support response caching
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40002
diff
changeset
|
2032 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
|
2033 informed about via the call to ``setcachekey()``. |
c537144fdbef
wireprotov2: support response caching
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40002
diff
changeset
|
2034 |
c537144fdbef
wireprotov2: support response caching
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40002
diff
changeset
|
2035 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
|
2036 entry, ``None`` should be returned. |
c537144fdbef
wireprotov2: support response caching
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40002
diff
changeset
|
2037 |
c537144fdbef
wireprotov2: support response caching
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40002
diff
changeset
|
2038 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
|
2039 dict may have the following keys: |
c537144fdbef
wireprotov2: support response caching
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40002
diff
changeset
|
2040 |
c537144fdbef
wireprotov2: support response caching
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40002
diff
changeset
|
2041 objs |
c537144fdbef
wireprotov2: support response caching
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40002
diff
changeset
|
2042 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
|
2043 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
|
2044 would return if invoked or an equivalent representation thereof. |
c537144fdbef
wireprotov2: support response caching
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40002
diff
changeset
|
2045 """ |
c537144fdbef
wireprotov2: support response caching
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40002
diff
changeset
|
2046 |
c537144fdbef
wireprotov2: support response caching
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40002
diff
changeset
|
2047 def onobject(obj): |
c537144fdbef
wireprotov2: support response caching
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40002
diff
changeset
|
2048 """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
|
2049 |
c537144fdbef
wireprotov2: support response caching
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40002
diff
changeset
|
2050 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
|
2051 command function. |
c537144fdbef
wireprotov2: support response caching
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40002
diff
changeset
|
2052 |
c537144fdbef
wireprotov2: support response caching
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40002
diff
changeset
|
2053 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
|
2054 layer. The easiest implementation is a generator that just |
c537144fdbef
wireprotov2: support response caching
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40002
diff
changeset
|
2055 ``yield obj``. |
c537144fdbef
wireprotov2: support response caching
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40002
diff
changeset
|
2056 """ |
c537144fdbef
wireprotov2: support response caching
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40002
diff
changeset
|
2057 |
c537144fdbef
wireprotov2: support response caching
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40002
diff
changeset
|
2058 def onfinished(): |
c537144fdbef
wireprotov2: support response caching
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40002
diff
changeset
|
2059 """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
|
2060 |
c537144fdbef
wireprotov2: support response caching
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40002
diff
changeset
|
2061 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
|
2062 the output layer. |
c537144fdbef
wireprotov2: support response caching
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40002
diff
changeset
|
2063 |
c537144fdbef
wireprotov2: support response caching
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40002
diff
changeset
|
2064 This method can be a generator. |
c537144fdbef
wireprotov2: support response caching
Gregory Szorc <gregory.szorc@gmail.com>
parents:
40002
diff
changeset
|
2065 """ |