##// END OF EJS Templates
sidedata: add a new revision flag constant for side data...
marmoute -
r43300:a12a9af7 default
parent child Browse files
Show More
@@ -1,1877 +1,1880 b''
1 # repository.py - Interfaces and base classes for repositories and peers.
1 # repository.py - Interfaces and base classes for repositories and peers.
2 #
2 #
3 # Copyright 2017 Gregory Szorc <gregory.szorc@gmail.com>
3 # Copyright 2017 Gregory Szorc <gregory.szorc@gmail.com>
4 #
4 #
5 # This software may be used and distributed according to the terms of the
5 # This software may be used and distributed according to the terms of the
6 # GNU General Public License version 2 or any later version.
6 # GNU General Public License version 2 or any later version.
7
7
8 from __future__ import absolute_import
8 from __future__ import absolute_import
9
9
10 from ..i18n import _
10 from ..i18n import _
11 from .. import (
11 from .. import (
12 error,
12 error,
13 )
13 )
14 from . import (
14 from . import (
15 util as interfaceutil,
15 util as interfaceutil,
16 )
16 )
17
17
18 # When narrowing is finalized and no longer subject to format changes,
18 # When narrowing is finalized and no longer subject to format changes,
19 # we should move this to just "narrow" or similar.
19 # we should move this to just "narrow" or similar.
20 NARROW_REQUIREMENT = 'narrowhg-experimental'
20 NARROW_REQUIREMENT = 'narrowhg-experimental'
21
21
22 # Local repository feature string.
22 # Local repository feature string.
23
23
24 # Revlogs are being used for file storage.
24 # Revlogs are being used for file storage.
25 REPO_FEATURE_REVLOG_FILE_STORAGE = b'revlogfilestorage'
25 REPO_FEATURE_REVLOG_FILE_STORAGE = b'revlogfilestorage'
26 # The storage part of the repository is shared from an external source.
26 # The storage part of the repository is shared from an external source.
27 REPO_FEATURE_SHARED_STORAGE = b'sharedstore'
27 REPO_FEATURE_SHARED_STORAGE = b'sharedstore'
28 # LFS supported for backing file storage.
28 # LFS supported for backing file storage.
29 REPO_FEATURE_LFS = b'lfs'
29 REPO_FEATURE_LFS = b'lfs'
30 # Repository supports being stream cloned.
30 # Repository supports being stream cloned.
31 REPO_FEATURE_STREAM_CLONE = b'streamclone'
31 REPO_FEATURE_STREAM_CLONE = b'streamclone'
32 # Files storage may lack data for all ancestors.
32 # Files storage may lack data for all ancestors.
33 REPO_FEATURE_SHALLOW_FILE_STORAGE = b'shallowfilestorage'
33 REPO_FEATURE_SHALLOW_FILE_STORAGE = b'shallowfilestorage'
34
34
35 REVISION_FLAG_CENSORED = 1 << 15
35 REVISION_FLAG_CENSORED = 1 << 15
36 REVISION_FLAG_ELLIPSIS = 1 << 14
36 REVISION_FLAG_ELLIPSIS = 1 << 14
37 REVISION_FLAG_EXTSTORED = 1 << 13
37 REVISION_FLAG_EXTSTORED = 1 << 13
38 REVISION_FLAG_SIDEDATA = 1 << 12
38
39
39 REVISION_FLAGS_KNOWN = (
40 REVISION_FLAGS_KNOWN = (
40 REVISION_FLAG_CENSORED | REVISION_FLAG_ELLIPSIS | REVISION_FLAG_EXTSTORED)
41 REVISION_FLAG_CENSORED | REVISION_FLAG_ELLIPSIS | REVISION_FLAG_EXTSTORED
42 | REVISION_FLAG_SIDEDATA
43 )
41
44
42 CG_DELTAMODE_STD = b'default'
45 CG_DELTAMODE_STD = b'default'
43 CG_DELTAMODE_PREV = b'previous'
46 CG_DELTAMODE_PREV = b'previous'
44 CG_DELTAMODE_FULL = b'fulltext'
47 CG_DELTAMODE_FULL = b'fulltext'
45 CG_DELTAMODE_P1 = b'p1'
48 CG_DELTAMODE_P1 = b'p1'
46
49
47 class ipeerconnection(interfaceutil.Interface):
50 class ipeerconnection(interfaceutil.Interface):
48 """Represents a "connection" to a repository.
51 """Represents a "connection" to a repository.
49
52
50 This is the base interface for representing a connection to a repository.
53 This is the base interface for representing a connection to a repository.
51 It holds basic properties and methods applicable to all peer types.
54 It holds basic properties and methods applicable to all peer types.
52
55
53 This is not a complete interface definition and should not be used
56 This is not a complete interface definition and should not be used
54 outside of this module.
57 outside of this module.
55 """
58 """
56 ui = interfaceutil.Attribute("""ui.ui instance""")
59 ui = interfaceutil.Attribute("""ui.ui instance""")
57
60
58 def url():
61 def url():
59 """Returns a URL string representing this peer.
62 """Returns a URL string representing this peer.
60
63
61 Currently, implementations expose the raw URL used to construct the
64 Currently, implementations expose the raw URL used to construct the
62 instance. It may contain credentials as part of the URL. The
65 instance. It may contain credentials as part of the URL. The
63 expectations of the value aren't well-defined and this could lead to
66 expectations of the value aren't well-defined and this could lead to
64 data leakage.
67 data leakage.
65
68
66 TODO audit/clean consumers and more clearly define the contents of this
69 TODO audit/clean consumers and more clearly define the contents of this
67 value.
70 value.
68 """
71 """
69
72
70 def local():
73 def local():
71 """Returns a local repository instance.
74 """Returns a local repository instance.
72
75
73 If the peer represents a local repository, returns an object that
76 If the peer represents a local repository, returns an object that
74 can be used to interface with it. Otherwise returns ``None``.
77 can be used to interface with it. Otherwise returns ``None``.
75 """
78 """
76
79
77 def peer():
80 def peer():
78 """Returns an object conforming to this interface.
81 """Returns an object conforming to this interface.
79
82
80 Most implementations will ``return self``.
83 Most implementations will ``return self``.
81 """
84 """
82
85
83 def canpush():
86 def canpush():
84 """Returns a boolean indicating if this peer can be pushed to."""
87 """Returns a boolean indicating if this peer can be pushed to."""
85
88
86 def close():
89 def close():
87 """Close the connection to this peer.
90 """Close the connection to this peer.
88
91
89 This is called when the peer will no longer be used. Resources
92 This is called when the peer will no longer be used. Resources
90 associated with the peer should be cleaned up.
93 associated with the peer should be cleaned up.
91 """
94 """
92
95
93 class ipeercapabilities(interfaceutil.Interface):
96 class ipeercapabilities(interfaceutil.Interface):
94 """Peer sub-interface related to capabilities."""
97 """Peer sub-interface related to capabilities."""
95
98
96 def capable(name):
99 def capable(name):
97 """Determine support for a named capability.
100 """Determine support for a named capability.
98
101
99 Returns ``False`` if capability not supported.
102 Returns ``False`` if capability not supported.
100
103
101 Returns ``True`` if boolean capability is supported. Returns a string
104 Returns ``True`` if boolean capability is supported. Returns a string
102 if capability support is non-boolean.
105 if capability support is non-boolean.
103
106
104 Capability strings may or may not map to wire protocol capabilities.
107 Capability strings may or may not map to wire protocol capabilities.
105 """
108 """
106
109
107 def requirecap(name, purpose):
110 def requirecap(name, purpose):
108 """Require a capability to be present.
111 """Require a capability to be present.
109
112
110 Raises a ``CapabilityError`` if the capability isn't present.
113 Raises a ``CapabilityError`` if the capability isn't present.
111 """
114 """
112
115
113 class ipeercommands(interfaceutil.Interface):
116 class ipeercommands(interfaceutil.Interface):
114 """Client-side interface for communicating over the wire protocol.
117 """Client-side interface for communicating over the wire protocol.
115
118
116 This interface is used as a gateway to the Mercurial wire protocol.
119 This interface is used as a gateway to the Mercurial wire protocol.
117 methods commonly call wire protocol commands of the same name.
120 methods commonly call wire protocol commands of the same name.
118 """
121 """
119
122
120 def branchmap():
123 def branchmap():
121 """Obtain heads in named branches.
124 """Obtain heads in named branches.
122
125
123 Returns a dict mapping branch name to an iterable of nodes that are
126 Returns a dict mapping branch name to an iterable of nodes that are
124 heads on that branch.
127 heads on that branch.
125 """
128 """
126
129
127 def capabilities():
130 def capabilities():
128 """Obtain capabilities of the peer.
131 """Obtain capabilities of the peer.
129
132
130 Returns a set of string capabilities.
133 Returns a set of string capabilities.
131 """
134 """
132
135
133 def clonebundles():
136 def clonebundles():
134 """Obtains the clone bundles manifest for the repo.
137 """Obtains the clone bundles manifest for the repo.
135
138
136 Returns the manifest as unparsed bytes.
139 Returns the manifest as unparsed bytes.
137 """
140 """
138
141
139 def debugwireargs(one, two, three=None, four=None, five=None):
142 def debugwireargs(one, two, three=None, four=None, five=None):
140 """Used to facilitate debugging of arguments passed over the wire."""
143 """Used to facilitate debugging of arguments passed over the wire."""
141
144
142 def getbundle(source, **kwargs):
145 def getbundle(source, **kwargs):
143 """Obtain remote repository data as a bundle.
146 """Obtain remote repository data as a bundle.
144
147
145 This command is how the bulk of repository data is transferred from
148 This command is how the bulk of repository data is transferred from
146 the peer to the local repository
149 the peer to the local repository
147
150
148 Returns a generator of bundle data.
151 Returns a generator of bundle data.
149 """
152 """
150
153
151 def heads():
154 def heads():
152 """Determine all known head revisions in the peer.
155 """Determine all known head revisions in the peer.
153
156
154 Returns an iterable of binary nodes.
157 Returns an iterable of binary nodes.
155 """
158 """
156
159
157 def known(nodes):
160 def known(nodes):
158 """Determine whether multiple nodes are known.
161 """Determine whether multiple nodes are known.
159
162
160 Accepts an iterable of nodes whose presence to check for.
163 Accepts an iterable of nodes whose presence to check for.
161
164
162 Returns an iterable of booleans indicating of the corresponding node
165 Returns an iterable of booleans indicating of the corresponding node
163 at that index is known to the peer.
166 at that index is known to the peer.
164 """
167 """
165
168
166 def listkeys(namespace):
169 def listkeys(namespace):
167 """Obtain all keys in a pushkey namespace.
170 """Obtain all keys in a pushkey namespace.
168
171
169 Returns an iterable of key names.
172 Returns an iterable of key names.
170 """
173 """
171
174
172 def lookup(key):
175 def lookup(key):
173 """Resolve a value to a known revision.
176 """Resolve a value to a known revision.
174
177
175 Returns a binary node of the resolved revision on success.
178 Returns a binary node of the resolved revision on success.
176 """
179 """
177
180
178 def pushkey(namespace, key, old, new):
181 def pushkey(namespace, key, old, new):
179 """Set a value using the ``pushkey`` protocol.
182 """Set a value using the ``pushkey`` protocol.
180
183
181 Arguments correspond to the pushkey namespace and key to operate on and
184 Arguments correspond to the pushkey namespace and key to operate on and
182 the old and new values for that key.
185 the old and new values for that key.
183
186
184 Returns a string with the peer result. The value inside varies by the
187 Returns a string with the peer result. The value inside varies by the
185 namespace.
188 namespace.
186 """
189 """
187
190
188 def stream_out():
191 def stream_out():
189 """Obtain streaming clone data.
192 """Obtain streaming clone data.
190
193
191 Successful result should be a generator of data chunks.
194 Successful result should be a generator of data chunks.
192 """
195 """
193
196
194 def unbundle(bundle, heads, url):
197 def unbundle(bundle, heads, url):
195 """Transfer repository data to the peer.
198 """Transfer repository data to the peer.
196
199
197 This is how the bulk of data during a push is transferred.
200 This is how the bulk of data during a push is transferred.
198
201
199 Returns the integer number of heads added to the peer.
202 Returns the integer number of heads added to the peer.
200 """
203 """
201
204
202 class ipeerlegacycommands(interfaceutil.Interface):
205 class ipeerlegacycommands(interfaceutil.Interface):
203 """Interface for implementing support for legacy wire protocol commands.
206 """Interface for implementing support for legacy wire protocol commands.
204
207
205 Wire protocol commands transition to legacy status when they are no longer
208 Wire protocol commands transition to legacy status when they are no longer
206 used by modern clients. To facilitate identifying which commands are
209 used by modern clients. To facilitate identifying which commands are
207 legacy, the interfaces are split.
210 legacy, the interfaces are split.
208 """
211 """
209
212
210 def between(pairs):
213 def between(pairs):
211 """Obtain nodes between pairs of nodes.
214 """Obtain nodes between pairs of nodes.
212
215
213 ``pairs`` is an iterable of node pairs.
216 ``pairs`` is an iterable of node pairs.
214
217
215 Returns an iterable of iterables of nodes corresponding to each
218 Returns an iterable of iterables of nodes corresponding to each
216 requested pair.
219 requested pair.
217 """
220 """
218
221
219 def branches(nodes):
222 def branches(nodes):
220 """Obtain ancestor changesets of specific nodes back to a branch point.
223 """Obtain ancestor changesets of specific nodes back to a branch point.
221
224
222 For each requested node, the peer finds the first ancestor node that is
225 For each requested node, the peer finds the first ancestor node that is
223 a DAG root or is a merge.
226 a DAG root or is a merge.
224
227
225 Returns an iterable of iterables with the resolved values for each node.
228 Returns an iterable of iterables with the resolved values for each node.
226 """
229 """
227
230
228 def changegroup(nodes, source):
231 def changegroup(nodes, source):
229 """Obtain a changegroup with data for descendants of specified nodes."""
232 """Obtain a changegroup with data for descendants of specified nodes."""
230
233
231 def changegroupsubset(bases, heads, source):
234 def changegroupsubset(bases, heads, source):
232 pass
235 pass
233
236
234 class ipeercommandexecutor(interfaceutil.Interface):
237 class ipeercommandexecutor(interfaceutil.Interface):
235 """Represents a mechanism to execute remote commands.
238 """Represents a mechanism to execute remote commands.
236
239
237 This is the primary interface for requesting that wire protocol commands
240 This is the primary interface for requesting that wire protocol commands
238 be executed. Instances of this interface are active in a context manager
241 be executed. Instances of this interface are active in a context manager
239 and have a well-defined lifetime. When the context manager exits, all
242 and have a well-defined lifetime. When the context manager exits, all
240 outstanding requests are waited on.
243 outstanding requests are waited on.
241 """
244 """
242
245
243 def callcommand(name, args):
246 def callcommand(name, args):
244 """Request that a named command be executed.
247 """Request that a named command be executed.
245
248
246 Receives the command name and a dictionary of command arguments.
249 Receives the command name and a dictionary of command arguments.
247
250
248 Returns a ``concurrent.futures.Future`` that will resolve to the
251 Returns a ``concurrent.futures.Future`` that will resolve to the
249 result of that command request. That exact value is left up to
252 result of that command request. That exact value is left up to
250 the implementation and possibly varies by command.
253 the implementation and possibly varies by command.
251
254
252 Not all commands can coexist with other commands in an executor
255 Not all commands can coexist with other commands in an executor
253 instance: it depends on the underlying wire protocol transport being
256 instance: it depends on the underlying wire protocol transport being
254 used and the command itself.
257 used and the command itself.
255
258
256 Implementations MAY call ``sendcommands()`` automatically if the
259 Implementations MAY call ``sendcommands()`` automatically if the
257 requested command can not coexist with other commands in this executor.
260 requested command can not coexist with other commands in this executor.
258
261
259 Implementations MAY call ``sendcommands()`` automatically when the
262 Implementations MAY call ``sendcommands()`` automatically when the
260 future's ``result()`` is called. So, consumers using multiple
263 future's ``result()`` is called. So, consumers using multiple
261 commands with an executor MUST ensure that ``result()`` is not called
264 commands with an executor MUST ensure that ``result()`` is not called
262 until all command requests have been issued.
265 until all command requests have been issued.
263 """
266 """
264
267
265 def sendcommands():
268 def sendcommands():
266 """Trigger submission of queued command requests.
269 """Trigger submission of queued command requests.
267
270
268 Not all transports submit commands as soon as they are requested to
271 Not all transports submit commands as soon as they are requested to
269 run. When called, this method forces queued command requests to be
272 run. When called, this method forces queued command requests to be
270 issued. It will no-op if all commands have already been sent.
273 issued. It will no-op if all commands have already been sent.
271
274
272 When called, no more new commands may be issued with this executor.
275 When called, no more new commands may be issued with this executor.
273 """
276 """
274
277
275 def close():
278 def close():
276 """Signal that this command request is finished.
279 """Signal that this command request is finished.
277
280
278 When called, no more new commands may be issued. All outstanding
281 When called, no more new commands may be issued. All outstanding
279 commands that have previously been issued are waited on before
282 commands that have previously been issued are waited on before
280 returning. This not only includes waiting for the futures to resolve,
283 returning. This not only includes waiting for the futures to resolve,
281 but also waiting for all response data to arrive. In other words,
284 but also waiting for all response data to arrive. In other words,
282 calling this waits for all on-wire state for issued command requests
285 calling this waits for all on-wire state for issued command requests
283 to finish.
286 to finish.
284
287
285 When used as a context manager, this method is called when exiting the
288 When used as a context manager, this method is called when exiting the
286 context manager.
289 context manager.
287
290
288 This method may call ``sendcommands()`` if there are buffered commands.
291 This method may call ``sendcommands()`` if there are buffered commands.
289 """
292 """
290
293
291 class ipeerrequests(interfaceutil.Interface):
294 class ipeerrequests(interfaceutil.Interface):
292 """Interface for executing commands on a peer."""
295 """Interface for executing commands on a peer."""
293
296
294 limitedarguments = interfaceutil.Attribute(
297 limitedarguments = interfaceutil.Attribute(
295 """True if the peer cannot receive large argument value for commands."""
298 """True if the peer cannot receive large argument value for commands."""
296 )
299 )
297
300
298 def commandexecutor():
301 def commandexecutor():
299 """A context manager that resolves to an ipeercommandexecutor.
302 """A context manager that resolves to an ipeercommandexecutor.
300
303
301 The object this resolves to can be used to issue command requests
304 The object this resolves to can be used to issue command requests
302 to the peer.
305 to the peer.
303
306
304 Callers should call its ``callcommand`` method to issue command
307 Callers should call its ``callcommand`` method to issue command
305 requests.
308 requests.
306
309
307 A new executor should be obtained for each distinct set of commands
310 A new executor should be obtained for each distinct set of commands
308 (possibly just a single command) that the consumer wants to execute
311 (possibly just a single command) that the consumer wants to execute
309 as part of a single operation or round trip. This is because some
312 as part of a single operation or round trip. This is because some
310 peers are half-duplex and/or don't support persistent connections.
313 peers are half-duplex and/or don't support persistent connections.
311 e.g. in the case of HTTP peers, commands sent to an executor represent
314 e.g. in the case of HTTP peers, commands sent to an executor represent
312 a single HTTP request. While some peers may support multiple command
315 a single HTTP request. While some peers may support multiple command
313 sends over the wire per executor, consumers need to code to the least
316 sends over the wire per executor, consumers need to code to the least
314 capable peer. So it should be assumed that command executors buffer
317 capable peer. So it should be assumed that command executors buffer
315 called commands until they are told to send them and that each
318 called commands until they are told to send them and that each
316 command executor could result in a new connection or wire-level request
319 command executor could result in a new connection or wire-level request
317 being issued.
320 being issued.
318 """
321 """
319
322
320 class ipeerbase(ipeerconnection, ipeercapabilities, ipeerrequests):
323 class ipeerbase(ipeerconnection, ipeercapabilities, ipeerrequests):
321 """Unified interface for peer repositories.
324 """Unified interface for peer repositories.
322
325
323 All peer instances must conform to this interface.
326 All peer instances must conform to this interface.
324 """
327 """
325
328
326 class ipeerv2(ipeerconnection, ipeercapabilities, ipeerrequests):
329 class ipeerv2(ipeerconnection, ipeercapabilities, ipeerrequests):
327 """Unified peer interface for wire protocol version 2 peers."""
330 """Unified peer interface for wire protocol version 2 peers."""
328
331
329 apidescriptor = interfaceutil.Attribute(
332 apidescriptor = interfaceutil.Attribute(
330 """Data structure holding description of server API.""")
333 """Data structure holding description of server API.""")
331
334
332 @interfaceutil.implementer(ipeerbase)
335 @interfaceutil.implementer(ipeerbase)
333 class peer(object):
336 class peer(object):
334 """Base class for peer repositories."""
337 """Base class for peer repositories."""
335
338
336 limitedarguments = False
339 limitedarguments = False
337
340
338 def capable(self, name):
341 def capable(self, name):
339 caps = self.capabilities()
342 caps = self.capabilities()
340 if name in caps:
343 if name in caps:
341 return True
344 return True
342
345
343 name = '%s=' % name
346 name = '%s=' % name
344 for cap in caps:
347 for cap in caps:
345 if cap.startswith(name):
348 if cap.startswith(name):
346 return cap[len(name):]
349 return cap[len(name):]
347
350
348 return False
351 return False
349
352
350 def requirecap(self, name, purpose):
353 def requirecap(self, name, purpose):
351 if self.capable(name):
354 if self.capable(name):
352 return
355 return
353
356
354 raise error.CapabilityError(
357 raise error.CapabilityError(
355 _('cannot %s; remote repository does not support the '
358 _('cannot %s; remote repository does not support the '
356 '\'%s\' capability') % (purpose, name))
359 '\'%s\' capability') % (purpose, name))
357
360
358 class iverifyproblem(interfaceutil.Interface):
361 class iverifyproblem(interfaceutil.Interface):
359 """Represents a problem with the integrity of the repository.
362 """Represents a problem with the integrity of the repository.
360
363
361 Instances of this interface are emitted to describe an integrity issue
364 Instances of this interface are emitted to describe an integrity issue
362 with a repository (e.g. corrupt storage, missing data, etc).
365 with a repository (e.g. corrupt storage, missing data, etc).
363
366
364 Instances are essentially messages associated with severity.
367 Instances are essentially messages associated with severity.
365 """
368 """
366 warning = interfaceutil.Attribute(
369 warning = interfaceutil.Attribute(
367 """Message indicating a non-fatal problem.""")
370 """Message indicating a non-fatal problem.""")
368
371
369 error = interfaceutil.Attribute(
372 error = interfaceutil.Attribute(
370 """Message indicating a fatal problem.""")
373 """Message indicating a fatal problem.""")
371
374
372 node = interfaceutil.Attribute(
375 node = interfaceutil.Attribute(
373 """Revision encountering the problem.
376 """Revision encountering the problem.
374
377
375 ``None`` means the problem doesn't apply to a single revision.
378 ``None`` means the problem doesn't apply to a single revision.
376 """)
379 """)
377
380
378 class irevisiondelta(interfaceutil.Interface):
381 class irevisiondelta(interfaceutil.Interface):
379 """Represents a delta between one revision and another.
382 """Represents a delta between one revision and another.
380
383
381 Instances convey enough information to allow a revision to be exchanged
384 Instances convey enough information to allow a revision to be exchanged
382 with another repository.
385 with another repository.
383
386
384 Instances represent the fulltext revision data or a delta against
387 Instances represent the fulltext revision data or a delta against
385 another revision. Therefore the ``revision`` and ``delta`` attributes
388 another revision. Therefore the ``revision`` and ``delta`` attributes
386 are mutually exclusive.
389 are mutually exclusive.
387
390
388 Typically used for changegroup generation.
391 Typically used for changegroup generation.
389 """
392 """
390
393
391 node = interfaceutil.Attribute(
394 node = interfaceutil.Attribute(
392 """20 byte node of this revision.""")
395 """20 byte node of this revision.""")
393
396
394 p1node = interfaceutil.Attribute(
397 p1node = interfaceutil.Attribute(
395 """20 byte node of 1st parent of this revision.""")
398 """20 byte node of 1st parent of this revision.""")
396
399
397 p2node = interfaceutil.Attribute(
400 p2node = interfaceutil.Attribute(
398 """20 byte node of 2nd parent of this revision.""")
401 """20 byte node of 2nd parent of this revision.""")
399
402
400 linknode = interfaceutil.Attribute(
403 linknode = interfaceutil.Attribute(
401 """20 byte node of the changelog revision this node is linked to.""")
404 """20 byte node of the changelog revision this node is linked to.""")
402
405
403 flags = interfaceutil.Attribute(
406 flags = interfaceutil.Attribute(
404 """2 bytes of integer flags that apply to this revision.
407 """2 bytes of integer flags that apply to this revision.
405
408
406 This is a bitwise composition of the ``REVISION_FLAG_*`` constants.
409 This is a bitwise composition of the ``REVISION_FLAG_*`` constants.
407 """)
410 """)
408
411
409 basenode = interfaceutil.Attribute(
412 basenode = interfaceutil.Attribute(
410 """20 byte node of the revision this data is a delta against.
413 """20 byte node of the revision this data is a delta against.
411
414
412 ``nullid`` indicates that the revision is a full revision and not
415 ``nullid`` indicates that the revision is a full revision and not
413 a delta.
416 a delta.
414 """)
417 """)
415
418
416 baserevisionsize = interfaceutil.Attribute(
419 baserevisionsize = interfaceutil.Attribute(
417 """Size of base revision this delta is against.
420 """Size of base revision this delta is against.
418
421
419 May be ``None`` if ``basenode`` is ``nullid``.
422 May be ``None`` if ``basenode`` is ``nullid``.
420 """)
423 """)
421
424
422 revision = interfaceutil.Attribute(
425 revision = interfaceutil.Attribute(
423 """Raw fulltext of revision data for this node.""")
426 """Raw fulltext of revision data for this node.""")
424
427
425 delta = interfaceutil.Attribute(
428 delta = interfaceutil.Attribute(
426 """Delta between ``basenode`` and ``node``.
429 """Delta between ``basenode`` and ``node``.
427
430
428 Stored in the bdiff delta format.
431 Stored in the bdiff delta format.
429 """)
432 """)
430
433
431 class ifilerevisionssequence(interfaceutil.Interface):
434 class ifilerevisionssequence(interfaceutil.Interface):
432 """Contains index data for all revisions of a file.
435 """Contains index data for all revisions of a file.
433
436
434 Types implementing this behave like lists of tuples. The index
437 Types implementing this behave like lists of tuples. The index
435 in the list corresponds to the revision number. The values contain
438 in the list corresponds to the revision number. The values contain
436 index metadata.
439 index metadata.
437
440
438 The *null* revision (revision number -1) is always the last item
441 The *null* revision (revision number -1) is always the last item
439 in the index.
442 in the index.
440 """
443 """
441
444
442 def __len__():
445 def __len__():
443 """The total number of revisions."""
446 """The total number of revisions."""
444
447
445 def __getitem__(rev):
448 def __getitem__(rev):
446 """Returns the object having a specific revision number.
449 """Returns the object having a specific revision number.
447
450
448 Returns an 8-tuple with the following fields:
451 Returns an 8-tuple with the following fields:
449
452
450 offset+flags
453 offset+flags
451 Contains the offset and flags for the revision. 64-bit unsigned
454 Contains the offset and flags for the revision. 64-bit unsigned
452 integer where first 6 bytes are the offset and the next 2 bytes
455 integer where first 6 bytes are the offset and the next 2 bytes
453 are flags. The offset can be 0 if it is not used by the store.
456 are flags. The offset can be 0 if it is not used by the store.
454 compressed size
457 compressed size
455 Size of the revision data in the store. It can be 0 if it isn't
458 Size of the revision data in the store. It can be 0 if it isn't
456 needed by the store.
459 needed by the store.
457 uncompressed size
460 uncompressed size
458 Fulltext size. It can be 0 if it isn't needed by the store.
461 Fulltext size. It can be 0 if it isn't needed by the store.
459 base revision
462 base revision
460 Revision number of revision the delta for storage is encoded
463 Revision number of revision the delta for storage is encoded
461 against. -1 indicates not encoded against a base revision.
464 against. -1 indicates not encoded against a base revision.
462 link revision
465 link revision
463 Revision number of changelog revision this entry is related to.
466 Revision number of changelog revision this entry is related to.
464 p1 revision
467 p1 revision
465 Revision number of 1st parent. -1 if no 1st parent.
468 Revision number of 1st parent. -1 if no 1st parent.
466 p2 revision
469 p2 revision
467 Revision number of 2nd parent. -1 if no 1st parent.
470 Revision number of 2nd parent. -1 if no 1st parent.
468 node
471 node
469 Binary node value for this revision number.
472 Binary node value for this revision number.
470
473
471 Negative values should index off the end of the sequence. ``-1``
474 Negative values should index off the end of the sequence. ``-1``
472 should return the null revision. ``-2`` should return the most
475 should return the null revision. ``-2`` should return the most
473 recent revision.
476 recent revision.
474 """
477 """
475
478
476 def __contains__(rev):
479 def __contains__(rev):
477 """Whether a revision number exists."""
480 """Whether a revision number exists."""
478
481
479 def insert(self, i, entry):
482 def insert(self, i, entry):
480 """Add an item to the index at specific revision."""
483 """Add an item to the index at specific revision."""
481
484
482 class ifileindex(interfaceutil.Interface):
485 class ifileindex(interfaceutil.Interface):
483 """Storage interface for index data of a single file.
486 """Storage interface for index data of a single file.
484
487
485 File storage data is divided into index metadata and data storage.
488 File storage data is divided into index metadata and data storage.
486 This interface defines the index portion of the interface.
489 This interface defines the index portion of the interface.
487
490
488 The index logically consists of:
491 The index logically consists of:
489
492
490 * A mapping between revision numbers and nodes.
493 * A mapping between revision numbers and nodes.
491 * DAG data (storing and querying the relationship between nodes).
494 * DAG data (storing and querying the relationship between nodes).
492 * Metadata to facilitate storage.
495 * Metadata to facilitate storage.
493 """
496 """
494 def __len__():
497 def __len__():
495 """Obtain the number of revisions stored for this file."""
498 """Obtain the number of revisions stored for this file."""
496
499
497 def __iter__():
500 def __iter__():
498 """Iterate over revision numbers for this file."""
501 """Iterate over revision numbers for this file."""
499
502
500 def hasnode(node):
503 def hasnode(node):
501 """Returns a bool indicating if a node is known to this store.
504 """Returns a bool indicating if a node is known to this store.
502
505
503 Implementations must only return True for full, binary node values:
506 Implementations must only return True for full, binary node values:
504 hex nodes, revision numbers, and partial node matches must be
507 hex nodes, revision numbers, and partial node matches must be
505 rejected.
508 rejected.
506
509
507 The null node is never present.
510 The null node is never present.
508 """
511 """
509
512
510 def revs(start=0, stop=None):
513 def revs(start=0, stop=None):
511 """Iterate over revision numbers for this file, with control."""
514 """Iterate over revision numbers for this file, with control."""
512
515
513 def parents(node):
516 def parents(node):
514 """Returns a 2-tuple of parent nodes for a revision.
517 """Returns a 2-tuple of parent nodes for a revision.
515
518
516 Values will be ``nullid`` if the parent is empty.
519 Values will be ``nullid`` if the parent is empty.
517 """
520 """
518
521
519 def parentrevs(rev):
522 def parentrevs(rev):
520 """Like parents() but operates on revision numbers."""
523 """Like parents() but operates on revision numbers."""
521
524
522 def rev(node):
525 def rev(node):
523 """Obtain the revision number given a node.
526 """Obtain the revision number given a node.
524
527
525 Raises ``error.LookupError`` if the node is not known.
528 Raises ``error.LookupError`` if the node is not known.
526 """
529 """
527
530
528 def node(rev):
531 def node(rev):
529 """Obtain the node value given a revision number.
532 """Obtain the node value given a revision number.
530
533
531 Raises ``IndexError`` if the node is not known.
534 Raises ``IndexError`` if the node is not known.
532 """
535 """
533
536
534 def lookup(node):
537 def lookup(node):
535 """Attempt to resolve a value to a node.
538 """Attempt to resolve a value to a node.
536
539
537 Value can be a binary node, hex node, revision number, or a string
540 Value can be a binary node, hex node, revision number, or a string
538 that can be converted to an integer.
541 that can be converted to an integer.
539
542
540 Raises ``error.LookupError`` if a node could not be resolved.
543 Raises ``error.LookupError`` if a node could not be resolved.
541 """
544 """
542
545
543 def linkrev(rev):
546 def linkrev(rev):
544 """Obtain the changeset revision number a revision is linked to."""
547 """Obtain the changeset revision number a revision is linked to."""
545
548
546 def iscensored(rev):
549 def iscensored(rev):
547 """Return whether a revision's content has been censored."""
550 """Return whether a revision's content has been censored."""
548
551
549 def commonancestorsheads(node1, node2):
552 def commonancestorsheads(node1, node2):
550 """Obtain an iterable of nodes containing heads of common ancestors.
553 """Obtain an iterable of nodes containing heads of common ancestors.
551
554
552 See ``ancestor.commonancestorsheads()``.
555 See ``ancestor.commonancestorsheads()``.
553 """
556 """
554
557
555 def descendants(revs):
558 def descendants(revs):
556 """Obtain descendant revision numbers for a set of revision numbers.
559 """Obtain descendant revision numbers for a set of revision numbers.
557
560
558 If ``nullrev`` is in the set, this is equivalent to ``revs()``.
561 If ``nullrev`` is in the set, this is equivalent to ``revs()``.
559 """
562 """
560
563
561 def heads(start=None, stop=None):
564 def heads(start=None, stop=None):
562 """Obtain a list of nodes that are DAG heads, with control.
565 """Obtain a list of nodes that are DAG heads, with control.
563
566
564 The set of revisions examined can be limited by specifying
567 The set of revisions examined can be limited by specifying
565 ``start`` and ``stop``. ``start`` is a node. ``stop`` is an
568 ``start`` and ``stop``. ``start`` is a node. ``stop`` is an
566 iterable of nodes. DAG traversal starts at earlier revision
569 iterable of nodes. DAG traversal starts at earlier revision
567 ``start`` and iterates forward until any node in ``stop`` is
570 ``start`` and iterates forward until any node in ``stop`` is
568 encountered.
571 encountered.
569 """
572 """
570
573
571 def children(node):
574 def children(node):
572 """Obtain nodes that are children of a node.
575 """Obtain nodes that are children of a node.
573
576
574 Returns a list of nodes.
577 Returns a list of nodes.
575 """
578 """
576
579
577 class ifiledata(interfaceutil.Interface):
580 class ifiledata(interfaceutil.Interface):
578 """Storage interface for data storage of a specific file.
581 """Storage interface for data storage of a specific file.
579
582
580 This complements ``ifileindex`` and provides an interface for accessing
583 This complements ``ifileindex`` and provides an interface for accessing
581 data for a tracked file.
584 data for a tracked file.
582 """
585 """
583 def size(rev):
586 def size(rev):
584 """Obtain the fulltext size of file data.
587 """Obtain the fulltext size of file data.
585
588
586 Any metadata is excluded from size measurements.
589 Any metadata is excluded from size measurements.
587 """
590 """
588
591
589 def revision(node, raw=False):
592 def revision(node, raw=False):
590 """"Obtain fulltext data for a node.
593 """"Obtain fulltext data for a node.
591
594
592 By default, any storage transformations are applied before the data
595 By default, any storage transformations are applied before the data
593 is returned. If ``raw`` is True, non-raw storage transformations
596 is returned. If ``raw`` is True, non-raw storage transformations
594 are not applied.
597 are not applied.
595
598
596 The fulltext data may contain a header containing metadata. Most
599 The fulltext data may contain a header containing metadata. Most
597 consumers should use ``read()`` to obtain the actual file data.
600 consumers should use ``read()`` to obtain the actual file data.
598 """
601 """
599
602
600 def rawdata(node):
603 def rawdata(node):
601 """Obtain raw data for a node.
604 """Obtain raw data for a node.
602 """
605 """
603
606
604 def read(node):
607 def read(node):
605 """Resolve file fulltext data.
608 """Resolve file fulltext data.
606
609
607 This is similar to ``revision()`` except any metadata in the data
610 This is similar to ``revision()`` except any metadata in the data
608 headers is stripped.
611 headers is stripped.
609 """
612 """
610
613
611 def renamed(node):
614 def renamed(node):
612 """Obtain copy metadata for a node.
615 """Obtain copy metadata for a node.
613
616
614 Returns ``False`` if no copy metadata is stored or a 2-tuple of
617 Returns ``False`` if no copy metadata is stored or a 2-tuple of
615 (path, node) from which this revision was copied.
618 (path, node) from which this revision was copied.
616 """
619 """
617
620
618 def cmp(node, fulltext):
621 def cmp(node, fulltext):
619 """Compare fulltext to another revision.
622 """Compare fulltext to another revision.
620
623
621 Returns True if the fulltext is different from what is stored.
624 Returns True if the fulltext is different from what is stored.
622
625
623 This takes copy metadata into account.
626 This takes copy metadata into account.
624
627
625 TODO better document the copy metadata and censoring logic.
628 TODO better document the copy metadata and censoring logic.
626 """
629 """
627
630
628 def emitrevisions(nodes,
631 def emitrevisions(nodes,
629 nodesorder=None,
632 nodesorder=None,
630 revisiondata=False,
633 revisiondata=False,
631 assumehaveparentrevisions=False,
634 assumehaveparentrevisions=False,
632 deltamode=CG_DELTAMODE_STD):
635 deltamode=CG_DELTAMODE_STD):
633 """Produce ``irevisiondelta`` for revisions.
636 """Produce ``irevisiondelta`` for revisions.
634
637
635 Given an iterable of nodes, emits objects conforming to the
638 Given an iterable of nodes, emits objects conforming to the
636 ``irevisiondelta`` interface that describe revisions in storage.
639 ``irevisiondelta`` interface that describe revisions in storage.
637
640
638 This method is a generator.
641 This method is a generator.
639
642
640 The input nodes may be unordered. Implementations must ensure that a
643 The input nodes may be unordered. Implementations must ensure that a
641 node's parents are emitted before the node itself. Transitively, this
644 node's parents are emitted before the node itself. Transitively, this
642 means that a node may only be emitted once all its ancestors in
645 means that a node may only be emitted once all its ancestors in
643 ``nodes`` have also been emitted.
646 ``nodes`` have also been emitted.
644
647
645 By default, emits "index" data (the ``node``, ``p1node``, and
648 By default, emits "index" data (the ``node``, ``p1node``, and
646 ``p2node`` attributes). If ``revisiondata`` is set, revision data
649 ``p2node`` attributes). If ``revisiondata`` is set, revision data
647 will also be present on the emitted objects.
650 will also be present on the emitted objects.
648
651
649 With default argument values, implementations can choose to emit
652 With default argument values, implementations can choose to emit
650 either fulltext revision data or a delta. When emitting deltas,
653 either fulltext revision data or a delta. When emitting deltas,
651 implementations must consider whether the delta's base revision
654 implementations must consider whether the delta's base revision
652 fulltext is available to the receiver.
655 fulltext is available to the receiver.
653
656
654 The base revision fulltext is guaranteed to be available if any of
657 The base revision fulltext is guaranteed to be available if any of
655 the following are met:
658 the following are met:
656
659
657 * Its fulltext revision was emitted by this method call.
660 * Its fulltext revision was emitted by this method call.
658 * A delta for that revision was emitted by this method call.
661 * A delta for that revision was emitted by this method call.
659 * ``assumehaveparentrevisions`` is True and the base revision is a
662 * ``assumehaveparentrevisions`` is True and the base revision is a
660 parent of the node.
663 parent of the node.
661
664
662 ``nodesorder`` can be used to control the order that revisions are
665 ``nodesorder`` can be used to control the order that revisions are
663 emitted. By default, revisions can be reordered as long as they are
666 emitted. By default, revisions can be reordered as long as they are
664 in DAG topological order (see above). If the value is ``nodes``,
667 in DAG topological order (see above). If the value is ``nodes``,
665 the iteration order from ``nodes`` should be used. If the value is
668 the iteration order from ``nodes`` should be used. If the value is
666 ``storage``, then the native order from the backing storage layer
669 ``storage``, then the native order from the backing storage layer
667 is used. (Not all storage layers will have strong ordering and behavior
670 is used. (Not all storage layers will have strong ordering and behavior
668 of this mode is storage-dependent.) ``nodes`` ordering can force
671 of this mode is storage-dependent.) ``nodes`` ordering can force
669 revisions to be emitted before their ancestors, so consumers should
672 revisions to be emitted before their ancestors, so consumers should
670 use it with care.
673 use it with care.
671
674
672 The ``linknode`` attribute on the returned ``irevisiondelta`` may not
675 The ``linknode`` attribute on the returned ``irevisiondelta`` may not
673 be set and it is the caller's responsibility to resolve it, if needed.
676 be set and it is the caller's responsibility to resolve it, if needed.
674
677
675 If ``deltamode`` is CG_DELTAMODE_PREV and revision data is requested,
678 If ``deltamode`` is CG_DELTAMODE_PREV and revision data is requested,
676 all revision data should be emitted as deltas against the revision
679 all revision data should be emitted as deltas against the revision
677 emitted just prior. The initial revision should be a delta against its
680 emitted just prior. The initial revision should be a delta against its
678 1st parent.
681 1st parent.
679 """
682 """
680
683
681 class ifilemutation(interfaceutil.Interface):
684 class ifilemutation(interfaceutil.Interface):
682 """Storage interface for mutation events of a tracked file."""
685 """Storage interface for mutation events of a tracked file."""
683
686
684 def add(filedata, meta, transaction, linkrev, p1, p2):
687 def add(filedata, meta, transaction, linkrev, p1, p2):
685 """Add a new revision to the store.
688 """Add a new revision to the store.
686
689
687 Takes file data, dictionary of metadata, a transaction, linkrev,
690 Takes file data, dictionary of metadata, a transaction, linkrev,
688 and parent nodes.
691 and parent nodes.
689
692
690 Returns the node that was added.
693 Returns the node that was added.
691
694
692 May no-op if a revision matching the supplied data is already stored.
695 May no-op if a revision matching the supplied data is already stored.
693 """
696 """
694
697
695 def addrevision(revisiondata, transaction, linkrev, p1, p2, node=None,
698 def addrevision(revisiondata, transaction, linkrev, p1, p2, node=None,
696 flags=0, cachedelta=None):
699 flags=0, cachedelta=None):
697 """Add a new revision to the store.
700 """Add a new revision to the store.
698
701
699 This is similar to ``add()`` except it operates at a lower level.
702 This is similar to ``add()`` except it operates at a lower level.
700
703
701 The data passed in already contains a metadata header, if any.
704 The data passed in already contains a metadata header, if any.
702
705
703 ``node`` and ``flags`` can be used to define the expected node and
706 ``node`` and ``flags`` can be used to define the expected node and
704 the flags to use with storage. ``flags`` is a bitwise value composed
707 the flags to use with storage. ``flags`` is a bitwise value composed
705 of the various ``REVISION_FLAG_*`` constants.
708 of the various ``REVISION_FLAG_*`` constants.
706
709
707 ``add()`` is usually called when adding files from e.g. the working
710 ``add()`` is usually called when adding files from e.g. the working
708 directory. ``addrevision()`` is often called by ``add()`` and for
711 directory. ``addrevision()`` is often called by ``add()`` and for
709 scenarios where revision data has already been computed, such as when
712 scenarios where revision data has already been computed, such as when
710 applying raw data from a peer repo.
713 applying raw data from a peer repo.
711 """
714 """
712
715
713 def addgroup(deltas, linkmapper, transaction, addrevisioncb=None,
716 def addgroup(deltas, linkmapper, transaction, addrevisioncb=None,
714 maybemissingparents=False):
717 maybemissingparents=False):
715 """Process a series of deltas for storage.
718 """Process a series of deltas for storage.
716
719
717 ``deltas`` is an iterable of 7-tuples of
720 ``deltas`` is an iterable of 7-tuples of
718 (node, p1, p2, linknode, deltabase, delta, flags) defining revisions
721 (node, p1, p2, linknode, deltabase, delta, flags) defining revisions
719 to add.
722 to add.
720
723
721 The ``delta`` field contains ``mpatch`` data to apply to a base
724 The ``delta`` field contains ``mpatch`` data to apply to a base
722 revision, identified by ``deltabase``. The base node can be
725 revision, identified by ``deltabase``. The base node can be
723 ``nullid``, in which case the header from the delta can be ignored
726 ``nullid``, in which case the header from the delta can be ignored
724 and the delta used as the fulltext.
727 and the delta used as the fulltext.
725
728
726 ``addrevisioncb`` should be called for each node as it is committed.
729 ``addrevisioncb`` should be called for each node as it is committed.
727
730
728 ``maybemissingparents`` is a bool indicating whether the incoming
731 ``maybemissingparents`` is a bool indicating whether the incoming
729 data may reference parents/ancestor revisions that aren't present.
732 data may reference parents/ancestor revisions that aren't present.
730 This flag is set when receiving data into a "shallow" store that
733 This flag is set when receiving data into a "shallow" store that
731 doesn't hold all history.
734 doesn't hold all history.
732
735
733 Returns a list of nodes that were processed. A node will be in the list
736 Returns a list of nodes that were processed. A node will be in the list
734 even if it existed in the store previously.
737 even if it existed in the store previously.
735 """
738 """
736
739
737 def censorrevision(tr, node, tombstone=b''):
740 def censorrevision(tr, node, tombstone=b''):
738 """Remove the content of a single revision.
741 """Remove the content of a single revision.
739
742
740 The specified ``node`` will have its content purged from storage.
743 The specified ``node`` will have its content purged from storage.
741 Future attempts to access the revision data for this node will
744 Future attempts to access the revision data for this node will
742 result in failure.
745 result in failure.
743
746
744 A ``tombstone`` message can optionally be stored. This message may be
747 A ``tombstone`` message can optionally be stored. This message may be
745 displayed to users when they attempt to access the missing revision
748 displayed to users when they attempt to access the missing revision
746 data.
749 data.
747
750
748 Storage backends may have stored deltas against the previous content
751 Storage backends may have stored deltas against the previous content
749 in this revision. As part of censoring a revision, these storage
752 in this revision. As part of censoring a revision, these storage
750 backends are expected to rewrite any internally stored deltas such
753 backends are expected to rewrite any internally stored deltas such
751 that they no longer reference the deleted content.
754 that they no longer reference the deleted content.
752 """
755 """
753
756
754 def getstrippoint(minlink):
757 def getstrippoint(minlink):
755 """Find the minimum revision that must be stripped to strip a linkrev.
758 """Find the minimum revision that must be stripped to strip a linkrev.
756
759
757 Returns a 2-tuple containing the minimum revision number and a set
760 Returns a 2-tuple containing the minimum revision number and a set
758 of all revisions numbers that would be broken by this strip.
761 of all revisions numbers that would be broken by this strip.
759
762
760 TODO this is highly revlog centric and should be abstracted into
763 TODO this is highly revlog centric and should be abstracted into
761 a higher-level deletion API. ``repair.strip()`` relies on this.
764 a higher-level deletion API. ``repair.strip()`` relies on this.
762 """
765 """
763
766
764 def strip(minlink, transaction):
767 def strip(minlink, transaction):
765 """Remove storage of items starting at a linkrev.
768 """Remove storage of items starting at a linkrev.
766
769
767 This uses ``getstrippoint()`` to determine the first node to remove.
770 This uses ``getstrippoint()`` to determine the first node to remove.
768 Then it effectively truncates storage for all revisions after that.
771 Then it effectively truncates storage for all revisions after that.
769
772
770 TODO this is highly revlog centric and should be abstracted into a
773 TODO this is highly revlog centric and should be abstracted into a
771 higher-level deletion API.
774 higher-level deletion API.
772 """
775 """
773
776
774 class ifilestorage(ifileindex, ifiledata, ifilemutation):
777 class ifilestorage(ifileindex, ifiledata, ifilemutation):
775 """Complete storage interface for a single tracked file."""
778 """Complete storage interface for a single tracked file."""
776
779
777 def files():
780 def files():
778 """Obtain paths that are backing storage for this file.
781 """Obtain paths that are backing storage for this file.
779
782
780 TODO this is used heavily by verify code and there should probably
783 TODO this is used heavily by verify code and there should probably
781 be a better API for that.
784 be a better API for that.
782 """
785 """
783
786
784 def storageinfo(exclusivefiles=False, sharedfiles=False,
787 def storageinfo(exclusivefiles=False, sharedfiles=False,
785 revisionscount=False, trackedsize=False,
788 revisionscount=False, trackedsize=False,
786 storedsize=False):
789 storedsize=False):
787 """Obtain information about storage for this file's data.
790 """Obtain information about storage for this file's data.
788
791
789 Returns a dict describing storage for this tracked path. The keys
792 Returns a dict describing storage for this tracked path. The keys
790 in the dict map to arguments of the same. The arguments are bools
793 in the dict map to arguments of the same. The arguments are bools
791 indicating whether to calculate and obtain that data.
794 indicating whether to calculate and obtain that data.
792
795
793 exclusivefiles
796 exclusivefiles
794 Iterable of (vfs, path) describing files that are exclusively
797 Iterable of (vfs, path) describing files that are exclusively
795 used to back storage for this tracked path.
798 used to back storage for this tracked path.
796
799
797 sharedfiles
800 sharedfiles
798 Iterable of (vfs, path) describing files that are used to back
801 Iterable of (vfs, path) describing files that are used to back
799 storage for this tracked path. Those files may also provide storage
802 storage for this tracked path. Those files may also provide storage
800 for other stored entities.
803 for other stored entities.
801
804
802 revisionscount
805 revisionscount
803 Number of revisions available for retrieval.
806 Number of revisions available for retrieval.
804
807
805 trackedsize
808 trackedsize
806 Total size in bytes of all tracked revisions. This is a sum of the
809 Total size in bytes of all tracked revisions. This is a sum of the
807 length of the fulltext of all revisions.
810 length of the fulltext of all revisions.
808
811
809 storedsize
812 storedsize
810 Total size in bytes used to store data for all tracked revisions.
813 Total size in bytes used to store data for all tracked revisions.
811 This is commonly less than ``trackedsize`` due to internal usage
814 This is commonly less than ``trackedsize`` due to internal usage
812 of deltas rather than fulltext revisions.
815 of deltas rather than fulltext revisions.
813
816
814 Not all storage backends may support all queries are have a reasonable
817 Not all storage backends may support all queries are have a reasonable
815 value to use. In that case, the value should be set to ``None`` and
818 value to use. In that case, the value should be set to ``None`` and
816 callers are expected to handle this special value.
819 callers are expected to handle this special value.
817 """
820 """
818
821
819 def verifyintegrity(state):
822 def verifyintegrity(state):
820 """Verifies the integrity of file storage.
823 """Verifies the integrity of file storage.
821
824
822 ``state`` is a dict holding state of the verifier process. It can be
825 ``state`` is a dict holding state of the verifier process. It can be
823 used to communicate data between invocations of multiple storage
826 used to communicate data between invocations of multiple storage
824 primitives.
827 primitives.
825
828
826 If individual revisions cannot have their revision content resolved,
829 If individual revisions cannot have their revision content resolved,
827 the method is expected to set the ``skipread`` key to a set of nodes
830 the method is expected to set the ``skipread`` key to a set of nodes
828 that encountered problems.
831 that encountered problems.
829
832
830 The method yields objects conforming to the ``iverifyproblem``
833 The method yields objects conforming to the ``iverifyproblem``
831 interface.
834 interface.
832 """
835 """
833
836
834 class idirs(interfaceutil.Interface):
837 class idirs(interfaceutil.Interface):
835 """Interface representing a collection of directories from paths.
838 """Interface representing a collection of directories from paths.
836
839
837 This interface is essentially a derived data structure representing
840 This interface is essentially a derived data structure representing
838 directories from a collection of paths.
841 directories from a collection of paths.
839 """
842 """
840
843
841 def addpath(path):
844 def addpath(path):
842 """Add a path to the collection.
845 """Add a path to the collection.
843
846
844 All directories in the path will be added to the collection.
847 All directories in the path will be added to the collection.
845 """
848 """
846
849
847 def delpath(path):
850 def delpath(path):
848 """Remove a path from the collection.
851 """Remove a path from the collection.
849
852
850 If the removal was the last path in a particular directory, the
853 If the removal was the last path in a particular directory, the
851 directory is removed from the collection.
854 directory is removed from the collection.
852 """
855 """
853
856
854 def __iter__():
857 def __iter__():
855 """Iterate over the directories in this collection of paths."""
858 """Iterate over the directories in this collection of paths."""
856
859
857 def __contains__(path):
860 def __contains__(path):
858 """Whether a specific directory is in this collection."""
861 """Whether a specific directory is in this collection."""
859
862
860 class imanifestdict(interfaceutil.Interface):
863 class imanifestdict(interfaceutil.Interface):
861 """Interface representing a manifest data structure.
864 """Interface representing a manifest data structure.
862
865
863 A manifest is effectively a dict mapping paths to entries. Each entry
866 A manifest is effectively a dict mapping paths to entries. Each entry
864 consists of a binary node and extra flags affecting that entry.
867 consists of a binary node and extra flags affecting that entry.
865 """
868 """
866
869
867 def __getitem__(path):
870 def __getitem__(path):
868 """Returns the binary node value for a path in the manifest.
871 """Returns the binary node value for a path in the manifest.
869
872
870 Raises ``KeyError`` if the path does not exist in the manifest.
873 Raises ``KeyError`` if the path does not exist in the manifest.
871
874
872 Equivalent to ``self.find(path)[0]``.
875 Equivalent to ``self.find(path)[0]``.
873 """
876 """
874
877
875 def find(path):
878 def find(path):
876 """Returns the entry for a path in the manifest.
879 """Returns the entry for a path in the manifest.
877
880
878 Returns a 2-tuple of (node, flags).
881 Returns a 2-tuple of (node, flags).
879
882
880 Raises ``KeyError`` if the path does not exist in the manifest.
883 Raises ``KeyError`` if the path does not exist in the manifest.
881 """
884 """
882
885
883 def __len__():
886 def __len__():
884 """Return the number of entries in the manifest."""
887 """Return the number of entries in the manifest."""
885
888
886 def __nonzero__():
889 def __nonzero__():
887 """Returns True if the manifest has entries, False otherwise."""
890 """Returns True if the manifest has entries, False otherwise."""
888
891
889 __bool__ = __nonzero__
892 __bool__ = __nonzero__
890
893
891 def __setitem__(path, node):
894 def __setitem__(path, node):
892 """Define the node value for a path in the manifest.
895 """Define the node value for a path in the manifest.
893
896
894 If the path is already in the manifest, its flags will be copied to
897 If the path is already in the manifest, its flags will be copied to
895 the new entry.
898 the new entry.
896 """
899 """
897
900
898 def __contains__(path):
901 def __contains__(path):
899 """Whether a path exists in the manifest."""
902 """Whether a path exists in the manifest."""
900
903
901 def __delitem__(path):
904 def __delitem__(path):
902 """Remove a path from the manifest.
905 """Remove a path from the manifest.
903
906
904 Raises ``KeyError`` if the path is not in the manifest.
907 Raises ``KeyError`` if the path is not in the manifest.
905 """
908 """
906
909
907 def __iter__():
910 def __iter__():
908 """Iterate over paths in the manifest."""
911 """Iterate over paths in the manifest."""
909
912
910 def iterkeys():
913 def iterkeys():
911 """Iterate over paths in the manifest."""
914 """Iterate over paths in the manifest."""
912
915
913 def keys():
916 def keys():
914 """Obtain a list of paths in the manifest."""
917 """Obtain a list of paths in the manifest."""
915
918
916 def filesnotin(other, match=None):
919 def filesnotin(other, match=None):
917 """Obtain the set of paths in this manifest but not in another.
920 """Obtain the set of paths in this manifest but not in another.
918
921
919 ``match`` is an optional matcher function to be applied to both
922 ``match`` is an optional matcher function to be applied to both
920 manifests.
923 manifests.
921
924
922 Returns a set of paths.
925 Returns a set of paths.
923 """
926 """
924
927
925 def dirs():
928 def dirs():
926 """Returns an object implementing the ``idirs`` interface."""
929 """Returns an object implementing the ``idirs`` interface."""
927
930
928 def hasdir(dir):
931 def hasdir(dir):
929 """Returns a bool indicating if a directory is in this manifest."""
932 """Returns a bool indicating if a directory is in this manifest."""
930
933
931 def matches(match):
934 def matches(match):
932 """Generate a new manifest filtered through a matcher.
935 """Generate a new manifest filtered through a matcher.
933
936
934 Returns an object conforming to the ``imanifestdict`` interface.
937 Returns an object conforming to the ``imanifestdict`` interface.
935 """
938 """
936
939
937 def walk(match):
940 def walk(match):
938 """Generator of paths in manifest satisfying a matcher.
941 """Generator of paths in manifest satisfying a matcher.
939
942
940 This is equivalent to ``self.matches(match).iterkeys()`` except a new
943 This is equivalent to ``self.matches(match).iterkeys()`` except a new
941 manifest object is not created.
944 manifest object is not created.
942
945
943 If the matcher has explicit files listed and they don't exist in
946 If the matcher has explicit files listed and they don't exist in
944 the manifest, ``match.bad()`` is called for each missing file.
947 the manifest, ``match.bad()`` is called for each missing file.
945 """
948 """
946
949
947 def diff(other, match=None, clean=False):
950 def diff(other, match=None, clean=False):
948 """Find differences between this manifest and another.
951 """Find differences between this manifest and another.
949
952
950 This manifest is compared to ``other``.
953 This manifest is compared to ``other``.
951
954
952 If ``match`` is provided, the two manifests are filtered against this
955 If ``match`` is provided, the two manifests are filtered against this
953 matcher and only entries satisfying the matcher are compared.
956 matcher and only entries satisfying the matcher are compared.
954
957
955 If ``clean`` is True, unchanged files are included in the returned
958 If ``clean`` is True, unchanged files are included in the returned
956 object.
959 object.
957
960
958 Returns a dict with paths as keys and values of 2-tuples of 2-tuples of
961 Returns a dict with paths as keys and values of 2-tuples of 2-tuples of
959 the form ``((node1, flag1), (node2, flag2))`` where ``(node1, flag1)``
962 the form ``((node1, flag1), (node2, flag2))`` where ``(node1, flag1)``
960 represents the node and flags for this manifest and ``(node2, flag2)``
963 represents the node and flags for this manifest and ``(node2, flag2)``
961 are the same for the other manifest.
964 are the same for the other manifest.
962 """
965 """
963
966
964 def setflag(path, flag):
967 def setflag(path, flag):
965 """Set the flag value for a given path.
968 """Set the flag value for a given path.
966
969
967 Raises ``KeyError`` if the path is not already in the manifest.
970 Raises ``KeyError`` if the path is not already in the manifest.
968 """
971 """
969
972
970 def get(path, default=None):
973 def get(path, default=None):
971 """Obtain the node value for a path or a default value if missing."""
974 """Obtain the node value for a path or a default value if missing."""
972
975
973 def flags(path, default=''):
976 def flags(path, default=''):
974 """Return the flags value for a path or a default value if missing."""
977 """Return the flags value for a path or a default value if missing."""
975
978
976 def copy():
979 def copy():
977 """Return a copy of this manifest."""
980 """Return a copy of this manifest."""
978
981
979 def items():
982 def items():
980 """Returns an iterable of (path, node) for items in this manifest."""
983 """Returns an iterable of (path, node) for items in this manifest."""
981
984
982 def iteritems():
985 def iteritems():
983 """Identical to items()."""
986 """Identical to items()."""
984
987
985 def iterentries():
988 def iterentries():
986 """Returns an iterable of (path, node, flags) for this manifest.
989 """Returns an iterable of (path, node, flags) for this manifest.
987
990
988 Similar to ``iteritems()`` except items are a 3-tuple and include
991 Similar to ``iteritems()`` except items are a 3-tuple and include
989 flags.
992 flags.
990 """
993 """
991
994
992 def text():
995 def text():
993 """Obtain the raw data representation for this manifest.
996 """Obtain the raw data representation for this manifest.
994
997
995 Result is used to create a manifest revision.
998 Result is used to create a manifest revision.
996 """
999 """
997
1000
998 def fastdelta(base, changes):
1001 def fastdelta(base, changes):
999 """Obtain a delta between this manifest and another given changes.
1002 """Obtain a delta between this manifest and another given changes.
1000
1003
1001 ``base`` in the raw data representation for another manifest.
1004 ``base`` in the raw data representation for another manifest.
1002
1005
1003 ``changes`` is an iterable of ``(path, to_delete)``.
1006 ``changes`` is an iterable of ``(path, to_delete)``.
1004
1007
1005 Returns a 2-tuple containing ``bytearray(self.text())`` and the
1008 Returns a 2-tuple containing ``bytearray(self.text())`` and the
1006 delta between ``base`` and this manifest.
1009 delta between ``base`` and this manifest.
1007 """
1010 """
1008
1011
1009 class imanifestrevisionbase(interfaceutil.Interface):
1012 class imanifestrevisionbase(interfaceutil.Interface):
1010 """Base interface representing a single revision of a manifest.
1013 """Base interface representing a single revision of a manifest.
1011
1014
1012 Should not be used as a primary interface: should always be inherited
1015 Should not be used as a primary interface: should always be inherited
1013 as part of a larger interface.
1016 as part of a larger interface.
1014 """
1017 """
1015
1018
1016 def new():
1019 def new():
1017 """Obtain a new manifest instance.
1020 """Obtain a new manifest instance.
1018
1021
1019 Returns an object conforming to the ``imanifestrevisionwritable``
1022 Returns an object conforming to the ``imanifestrevisionwritable``
1020 interface. The instance will be associated with the same
1023 interface. The instance will be associated with the same
1021 ``imanifestlog`` collection as this instance.
1024 ``imanifestlog`` collection as this instance.
1022 """
1025 """
1023
1026
1024 def copy():
1027 def copy():
1025 """Obtain a copy of this manifest instance.
1028 """Obtain a copy of this manifest instance.
1026
1029
1027 Returns an object conforming to the ``imanifestrevisionwritable``
1030 Returns an object conforming to the ``imanifestrevisionwritable``
1028 interface. The instance will be associated with the same
1031 interface. The instance will be associated with the same
1029 ``imanifestlog`` collection as this instance.
1032 ``imanifestlog`` collection as this instance.
1030 """
1033 """
1031
1034
1032 def read():
1035 def read():
1033 """Obtain the parsed manifest data structure.
1036 """Obtain the parsed manifest data structure.
1034
1037
1035 The returned object conforms to the ``imanifestdict`` interface.
1038 The returned object conforms to the ``imanifestdict`` interface.
1036 """
1039 """
1037
1040
1038 class imanifestrevisionstored(imanifestrevisionbase):
1041 class imanifestrevisionstored(imanifestrevisionbase):
1039 """Interface representing a manifest revision committed to storage."""
1042 """Interface representing a manifest revision committed to storage."""
1040
1043
1041 def node():
1044 def node():
1042 """The binary node for this manifest."""
1045 """The binary node for this manifest."""
1043
1046
1044 parents = interfaceutil.Attribute(
1047 parents = interfaceutil.Attribute(
1045 """List of binary nodes that are parents for this manifest revision."""
1048 """List of binary nodes that are parents for this manifest revision."""
1046 )
1049 )
1047
1050
1048 def readdelta(shallow=False):
1051 def readdelta(shallow=False):
1049 """Obtain the manifest data structure representing changes from parent.
1052 """Obtain the manifest data structure representing changes from parent.
1050
1053
1051 This manifest is compared to its 1st parent. A new manifest representing
1054 This manifest is compared to its 1st parent. A new manifest representing
1052 those differences is constructed.
1055 those differences is constructed.
1053
1056
1054 The returned object conforms to the ``imanifestdict`` interface.
1057 The returned object conforms to the ``imanifestdict`` interface.
1055 """
1058 """
1056
1059
1057 def readfast(shallow=False):
1060 def readfast(shallow=False):
1058 """Calls either ``read()`` or ``readdelta()``.
1061 """Calls either ``read()`` or ``readdelta()``.
1059
1062
1060 The faster of the two options is called.
1063 The faster of the two options is called.
1061 """
1064 """
1062
1065
1063 def find(key):
1066 def find(key):
1064 """Calls self.read().find(key)``.
1067 """Calls self.read().find(key)``.
1065
1068
1066 Returns a 2-tuple of ``(node, flags)`` or raises ``KeyError``.
1069 Returns a 2-tuple of ``(node, flags)`` or raises ``KeyError``.
1067 """
1070 """
1068
1071
1069 class imanifestrevisionwritable(imanifestrevisionbase):
1072 class imanifestrevisionwritable(imanifestrevisionbase):
1070 """Interface representing a manifest revision that can be committed."""
1073 """Interface representing a manifest revision that can be committed."""
1071
1074
1072 def write(transaction, linkrev, p1node, p2node, added, removed, match=None):
1075 def write(transaction, linkrev, p1node, p2node, added, removed, match=None):
1073 """Add this revision to storage.
1076 """Add this revision to storage.
1074
1077
1075 Takes a transaction object, the changeset revision number it will
1078 Takes a transaction object, the changeset revision number it will
1076 be associated with, its parent nodes, and lists of added and
1079 be associated with, its parent nodes, and lists of added and
1077 removed paths.
1080 removed paths.
1078
1081
1079 If match is provided, storage can choose not to inspect or write out
1082 If match is provided, storage can choose not to inspect or write out
1080 items that do not match. Storage is still required to be able to provide
1083 items that do not match. Storage is still required to be able to provide
1081 the full manifest in the future for any directories written (these
1084 the full manifest in the future for any directories written (these
1082 manifests should not be "narrowed on disk").
1085 manifests should not be "narrowed on disk").
1083
1086
1084 Returns the binary node of the created revision.
1087 Returns the binary node of the created revision.
1085 """
1088 """
1086
1089
1087 class imanifeststorage(interfaceutil.Interface):
1090 class imanifeststorage(interfaceutil.Interface):
1088 """Storage interface for manifest data."""
1091 """Storage interface for manifest data."""
1089
1092
1090 tree = interfaceutil.Attribute(
1093 tree = interfaceutil.Attribute(
1091 """The path to the directory this manifest tracks.
1094 """The path to the directory this manifest tracks.
1092
1095
1093 The empty bytestring represents the root manifest.
1096 The empty bytestring represents the root manifest.
1094 """)
1097 """)
1095
1098
1096 index = interfaceutil.Attribute(
1099 index = interfaceutil.Attribute(
1097 """An ``ifilerevisionssequence`` instance.""")
1100 """An ``ifilerevisionssequence`` instance.""")
1098
1101
1099 indexfile = interfaceutil.Attribute(
1102 indexfile = interfaceutil.Attribute(
1100 """Path of revlog index file.
1103 """Path of revlog index file.
1101
1104
1102 TODO this is revlog specific and should not be exposed.
1105 TODO this is revlog specific and should not be exposed.
1103 """)
1106 """)
1104
1107
1105 opener = interfaceutil.Attribute(
1108 opener = interfaceutil.Attribute(
1106 """VFS opener to use to access underlying files used for storage.
1109 """VFS opener to use to access underlying files used for storage.
1107
1110
1108 TODO this is revlog specific and should not be exposed.
1111 TODO this is revlog specific and should not be exposed.
1109 """)
1112 """)
1110
1113
1111 version = interfaceutil.Attribute(
1114 version = interfaceutil.Attribute(
1112 """Revlog version number.
1115 """Revlog version number.
1113
1116
1114 TODO this is revlog specific and should not be exposed.
1117 TODO this is revlog specific and should not be exposed.
1115 """)
1118 """)
1116
1119
1117 _generaldelta = interfaceutil.Attribute(
1120 _generaldelta = interfaceutil.Attribute(
1118 """Whether generaldelta storage is being used.
1121 """Whether generaldelta storage is being used.
1119
1122
1120 TODO this is revlog specific and should not be exposed.
1123 TODO this is revlog specific and should not be exposed.
1121 """)
1124 """)
1122
1125
1123 fulltextcache = interfaceutil.Attribute(
1126 fulltextcache = interfaceutil.Attribute(
1124 """Dict with cache of fulltexts.
1127 """Dict with cache of fulltexts.
1125
1128
1126 TODO this doesn't feel appropriate for the storage interface.
1129 TODO this doesn't feel appropriate for the storage interface.
1127 """)
1130 """)
1128
1131
1129 def __len__():
1132 def __len__():
1130 """Obtain the number of revisions stored for this manifest."""
1133 """Obtain the number of revisions stored for this manifest."""
1131
1134
1132 def __iter__():
1135 def __iter__():
1133 """Iterate over revision numbers for this manifest."""
1136 """Iterate over revision numbers for this manifest."""
1134
1137
1135 def rev(node):
1138 def rev(node):
1136 """Obtain the revision number given a binary node.
1139 """Obtain the revision number given a binary node.
1137
1140
1138 Raises ``error.LookupError`` if the node is not known.
1141 Raises ``error.LookupError`` if the node is not known.
1139 """
1142 """
1140
1143
1141 def node(rev):
1144 def node(rev):
1142 """Obtain the node value given a revision number.
1145 """Obtain the node value given a revision number.
1143
1146
1144 Raises ``error.LookupError`` if the revision is not known.
1147 Raises ``error.LookupError`` if the revision is not known.
1145 """
1148 """
1146
1149
1147 def lookup(value):
1150 def lookup(value):
1148 """Attempt to resolve a value to a node.
1151 """Attempt to resolve a value to a node.
1149
1152
1150 Value can be a binary node, hex node, revision number, or a bytes
1153 Value can be a binary node, hex node, revision number, or a bytes
1151 that can be converted to an integer.
1154 that can be converted to an integer.
1152
1155
1153 Raises ``error.LookupError`` if a ndoe could not be resolved.
1156 Raises ``error.LookupError`` if a ndoe could not be resolved.
1154 """
1157 """
1155
1158
1156 def parents(node):
1159 def parents(node):
1157 """Returns a 2-tuple of parent nodes for a node.
1160 """Returns a 2-tuple of parent nodes for a node.
1158
1161
1159 Values will be ``nullid`` if the parent is empty.
1162 Values will be ``nullid`` if the parent is empty.
1160 """
1163 """
1161
1164
1162 def parentrevs(rev):
1165 def parentrevs(rev):
1163 """Like parents() but operates on revision numbers."""
1166 """Like parents() but operates on revision numbers."""
1164
1167
1165 def linkrev(rev):
1168 def linkrev(rev):
1166 """Obtain the changeset revision number a revision is linked to."""
1169 """Obtain the changeset revision number a revision is linked to."""
1167
1170
1168 def revision(node, _df=None, raw=False):
1171 def revision(node, _df=None, raw=False):
1169 """Obtain fulltext data for a node."""
1172 """Obtain fulltext data for a node."""
1170
1173
1171 def rawdata(node, _df=None):
1174 def rawdata(node, _df=None):
1172 """Obtain raw data for a node."""
1175 """Obtain raw data for a node."""
1173
1176
1174 def revdiff(rev1, rev2):
1177 def revdiff(rev1, rev2):
1175 """Obtain a delta between two revision numbers.
1178 """Obtain a delta between two revision numbers.
1176
1179
1177 The returned data is the result of ``bdiff.bdiff()`` on the raw
1180 The returned data is the result of ``bdiff.bdiff()`` on the raw
1178 revision data.
1181 revision data.
1179 """
1182 """
1180
1183
1181 def cmp(node, fulltext):
1184 def cmp(node, fulltext):
1182 """Compare fulltext to another revision.
1185 """Compare fulltext to another revision.
1183
1186
1184 Returns True if the fulltext is different from what is stored.
1187 Returns True if the fulltext is different from what is stored.
1185 """
1188 """
1186
1189
1187 def emitrevisions(nodes,
1190 def emitrevisions(nodes,
1188 nodesorder=None,
1191 nodesorder=None,
1189 revisiondata=False,
1192 revisiondata=False,
1190 assumehaveparentrevisions=False):
1193 assumehaveparentrevisions=False):
1191 """Produce ``irevisiondelta`` describing revisions.
1194 """Produce ``irevisiondelta`` describing revisions.
1192
1195
1193 See the documentation for ``ifiledata`` for more.
1196 See the documentation for ``ifiledata`` for more.
1194 """
1197 """
1195
1198
1196 def addgroup(deltas, linkmapper, transaction, addrevisioncb=None):
1199 def addgroup(deltas, linkmapper, transaction, addrevisioncb=None):
1197 """Process a series of deltas for storage.
1200 """Process a series of deltas for storage.
1198
1201
1199 See the documentation in ``ifilemutation`` for more.
1202 See the documentation in ``ifilemutation`` for more.
1200 """
1203 """
1201
1204
1202 def rawsize(rev):
1205 def rawsize(rev):
1203 """Obtain the size of tracked data.
1206 """Obtain the size of tracked data.
1204
1207
1205 Is equivalent to ``len(m.rawdata(node))``.
1208 Is equivalent to ``len(m.rawdata(node))``.
1206
1209
1207 TODO this method is only used by upgrade code and may be removed.
1210 TODO this method is only used by upgrade code and may be removed.
1208 """
1211 """
1209
1212
1210 def getstrippoint(minlink):
1213 def getstrippoint(minlink):
1211 """Find minimum revision that must be stripped to strip a linkrev.
1214 """Find minimum revision that must be stripped to strip a linkrev.
1212
1215
1213 See the documentation in ``ifilemutation`` for more.
1216 See the documentation in ``ifilemutation`` for more.
1214 """
1217 """
1215
1218
1216 def strip(minlink, transaction):
1219 def strip(minlink, transaction):
1217 """Remove storage of items starting at a linkrev.
1220 """Remove storage of items starting at a linkrev.
1218
1221
1219 See the documentation in ``ifilemutation`` for more.
1222 See the documentation in ``ifilemutation`` for more.
1220 """
1223 """
1221
1224
1222 def checksize():
1225 def checksize():
1223 """Obtain the expected sizes of backing files.
1226 """Obtain the expected sizes of backing files.
1224
1227
1225 TODO this is used by verify and it should not be part of the interface.
1228 TODO this is used by verify and it should not be part of the interface.
1226 """
1229 """
1227
1230
1228 def files():
1231 def files():
1229 """Obtain paths that are backing storage for this manifest.
1232 """Obtain paths that are backing storage for this manifest.
1230
1233
1231 TODO this is used by verify and there should probably be a better API
1234 TODO this is used by verify and there should probably be a better API
1232 for this functionality.
1235 for this functionality.
1233 """
1236 """
1234
1237
1235 def deltaparent(rev):
1238 def deltaparent(rev):
1236 """Obtain the revision that a revision is delta'd against.
1239 """Obtain the revision that a revision is delta'd against.
1237
1240
1238 TODO delta encoding is an implementation detail of storage and should
1241 TODO delta encoding is an implementation detail of storage and should
1239 not be exposed to the storage interface.
1242 not be exposed to the storage interface.
1240 """
1243 """
1241
1244
1242 def clone(tr, dest, **kwargs):
1245 def clone(tr, dest, **kwargs):
1243 """Clone this instance to another."""
1246 """Clone this instance to another."""
1244
1247
1245 def clearcaches(clear_persisted_data=False):
1248 def clearcaches(clear_persisted_data=False):
1246 """Clear any caches associated with this instance."""
1249 """Clear any caches associated with this instance."""
1247
1250
1248 def dirlog(d):
1251 def dirlog(d):
1249 """Obtain a manifest storage instance for a tree."""
1252 """Obtain a manifest storage instance for a tree."""
1250
1253
1251 def add(m, transaction, link, p1, p2, added, removed, readtree=None,
1254 def add(m, transaction, link, p1, p2, added, removed, readtree=None,
1252 match=None):
1255 match=None):
1253 """Add a revision to storage.
1256 """Add a revision to storage.
1254
1257
1255 ``m`` is an object conforming to ``imanifestdict``.
1258 ``m`` is an object conforming to ``imanifestdict``.
1256
1259
1257 ``link`` is the linkrev revision number.
1260 ``link`` is the linkrev revision number.
1258
1261
1259 ``p1`` and ``p2`` are the parent revision numbers.
1262 ``p1`` and ``p2`` are the parent revision numbers.
1260
1263
1261 ``added`` and ``removed`` are iterables of added and removed paths,
1264 ``added`` and ``removed`` are iterables of added and removed paths,
1262 respectively.
1265 respectively.
1263
1266
1264 ``readtree`` is a function that can be used to read the child tree(s)
1267 ``readtree`` is a function that can be used to read the child tree(s)
1265 when recursively writing the full tree structure when using
1268 when recursively writing the full tree structure when using
1266 treemanifets.
1269 treemanifets.
1267
1270
1268 ``match`` is a matcher that can be used to hint to storage that not all
1271 ``match`` is a matcher that can be used to hint to storage that not all
1269 paths must be inspected; this is an optimization and can be safely
1272 paths must be inspected; this is an optimization and can be safely
1270 ignored. Note that the storage must still be able to reproduce a full
1273 ignored. Note that the storage must still be able to reproduce a full
1271 manifest including files that did not match.
1274 manifest including files that did not match.
1272 """
1275 """
1273
1276
1274 def storageinfo(exclusivefiles=False, sharedfiles=False,
1277 def storageinfo(exclusivefiles=False, sharedfiles=False,
1275 revisionscount=False, trackedsize=False,
1278 revisionscount=False, trackedsize=False,
1276 storedsize=False):
1279 storedsize=False):
1277 """Obtain information about storage for this manifest's data.
1280 """Obtain information about storage for this manifest's data.
1278
1281
1279 See ``ifilestorage.storageinfo()`` for a description of this method.
1282 See ``ifilestorage.storageinfo()`` for a description of this method.
1280 This one behaves the same way, except for manifest data.
1283 This one behaves the same way, except for manifest data.
1281 """
1284 """
1282
1285
1283 class imanifestlog(interfaceutil.Interface):
1286 class imanifestlog(interfaceutil.Interface):
1284 """Interface representing a collection of manifest snapshots.
1287 """Interface representing a collection of manifest snapshots.
1285
1288
1286 Represents the root manifest in a repository.
1289 Represents the root manifest in a repository.
1287
1290
1288 Also serves as a means to access nested tree manifests and to cache
1291 Also serves as a means to access nested tree manifests and to cache
1289 tree manifests.
1292 tree manifests.
1290 """
1293 """
1291
1294
1292 def __getitem__(node):
1295 def __getitem__(node):
1293 """Obtain a manifest instance for a given binary node.
1296 """Obtain a manifest instance for a given binary node.
1294
1297
1295 Equivalent to calling ``self.get('', node)``.
1298 Equivalent to calling ``self.get('', node)``.
1296
1299
1297 The returned object conforms to the ``imanifestrevisionstored``
1300 The returned object conforms to the ``imanifestrevisionstored``
1298 interface.
1301 interface.
1299 """
1302 """
1300
1303
1301 def get(tree, node, verify=True):
1304 def get(tree, node, verify=True):
1302 """Retrieve the manifest instance for a given directory and binary node.
1305 """Retrieve the manifest instance for a given directory and binary node.
1303
1306
1304 ``node`` always refers to the node of the root manifest (which will be
1307 ``node`` always refers to the node of the root manifest (which will be
1305 the only manifest if flat manifests are being used).
1308 the only manifest if flat manifests are being used).
1306
1309
1307 If ``tree`` is the empty string, the root manifest is returned.
1310 If ``tree`` is the empty string, the root manifest is returned.
1308 Otherwise the manifest for the specified directory will be returned
1311 Otherwise the manifest for the specified directory will be returned
1309 (requires tree manifests).
1312 (requires tree manifests).
1310
1313
1311 If ``verify`` is True, ``LookupError`` is raised if the node is not
1314 If ``verify`` is True, ``LookupError`` is raised if the node is not
1312 known.
1315 known.
1313
1316
1314 The returned object conforms to the ``imanifestrevisionstored``
1317 The returned object conforms to the ``imanifestrevisionstored``
1315 interface.
1318 interface.
1316 """
1319 """
1317
1320
1318 def getstorage(tree):
1321 def getstorage(tree):
1319 """Retrieve an interface to storage for a particular tree.
1322 """Retrieve an interface to storage for a particular tree.
1320
1323
1321 If ``tree`` is the empty bytestring, storage for the root manifest will
1324 If ``tree`` is the empty bytestring, storage for the root manifest will
1322 be returned. Otherwise storage for a tree manifest is returned.
1325 be returned. Otherwise storage for a tree manifest is returned.
1323
1326
1324 TODO formalize interface for returned object.
1327 TODO formalize interface for returned object.
1325 """
1328 """
1326
1329
1327 def clearcaches():
1330 def clearcaches():
1328 """Clear caches associated with this collection."""
1331 """Clear caches associated with this collection."""
1329
1332
1330 def rev(node):
1333 def rev(node):
1331 """Obtain the revision number for a binary node.
1334 """Obtain the revision number for a binary node.
1332
1335
1333 Raises ``error.LookupError`` if the node is not known.
1336 Raises ``error.LookupError`` if the node is not known.
1334 """
1337 """
1335
1338
1336 class ilocalrepositoryfilestorage(interfaceutil.Interface):
1339 class ilocalrepositoryfilestorage(interfaceutil.Interface):
1337 """Local repository sub-interface providing access to tracked file storage.
1340 """Local repository sub-interface providing access to tracked file storage.
1338
1341
1339 This interface defines how a repository accesses storage for a single
1342 This interface defines how a repository accesses storage for a single
1340 tracked file path.
1343 tracked file path.
1341 """
1344 """
1342
1345
1343 def file(f):
1346 def file(f):
1344 """Obtain a filelog for a tracked path.
1347 """Obtain a filelog for a tracked path.
1345
1348
1346 The returned type conforms to the ``ifilestorage`` interface.
1349 The returned type conforms to the ``ifilestorage`` interface.
1347 """
1350 """
1348
1351
1349 class ilocalrepositorymain(interfaceutil.Interface):
1352 class ilocalrepositorymain(interfaceutil.Interface):
1350 """Main interface for local repositories.
1353 """Main interface for local repositories.
1351
1354
1352 This currently captures the reality of things - not how things should be.
1355 This currently captures the reality of things - not how things should be.
1353 """
1356 """
1354
1357
1355 supportedformats = interfaceutil.Attribute(
1358 supportedformats = interfaceutil.Attribute(
1356 """Set of requirements that apply to stream clone.
1359 """Set of requirements that apply to stream clone.
1357
1360
1358 This is actually a class attribute and is shared among all instances.
1361 This is actually a class attribute and is shared among all instances.
1359 """)
1362 """)
1360
1363
1361 supported = interfaceutil.Attribute(
1364 supported = interfaceutil.Attribute(
1362 """Set of requirements that this repo is capable of opening.""")
1365 """Set of requirements that this repo is capable of opening.""")
1363
1366
1364 requirements = interfaceutil.Attribute(
1367 requirements = interfaceutil.Attribute(
1365 """Set of requirements this repo uses.""")
1368 """Set of requirements this repo uses.""")
1366
1369
1367 features = interfaceutil.Attribute(
1370 features = interfaceutil.Attribute(
1368 """Set of "features" this repository supports.
1371 """Set of "features" this repository supports.
1369
1372
1370 A "feature" is a loosely-defined term. It can refer to a feature
1373 A "feature" is a loosely-defined term. It can refer to a feature
1371 in the classical sense or can describe an implementation detail
1374 in the classical sense or can describe an implementation detail
1372 of the repository. For example, a ``readonly`` feature may denote
1375 of the repository. For example, a ``readonly`` feature may denote
1373 the repository as read-only. Or a ``revlogfilestore`` feature may
1376 the repository as read-only. Or a ``revlogfilestore`` feature may
1374 denote that the repository is using revlogs for file storage.
1377 denote that the repository is using revlogs for file storage.
1375
1378
1376 The intent of features is to provide a machine-queryable mechanism
1379 The intent of features is to provide a machine-queryable mechanism
1377 for repo consumers to test for various repository characteristics.
1380 for repo consumers to test for various repository characteristics.
1378
1381
1379 Features are similar to ``requirements``. The main difference is that
1382 Features are similar to ``requirements``. The main difference is that
1380 requirements are stored on-disk and represent requirements to open the
1383 requirements are stored on-disk and represent requirements to open the
1381 repository. Features are more run-time capabilities of the repository
1384 repository. Features are more run-time capabilities of the repository
1382 and more granular capabilities (which may be derived from requirements).
1385 and more granular capabilities (which may be derived from requirements).
1383 """)
1386 """)
1384
1387
1385 filtername = interfaceutil.Attribute(
1388 filtername = interfaceutil.Attribute(
1386 """Name of the repoview that is active on this repo.""")
1389 """Name of the repoview that is active on this repo.""")
1387
1390
1388 wvfs = interfaceutil.Attribute(
1391 wvfs = interfaceutil.Attribute(
1389 """VFS used to access the working directory.""")
1392 """VFS used to access the working directory.""")
1390
1393
1391 vfs = interfaceutil.Attribute(
1394 vfs = interfaceutil.Attribute(
1392 """VFS rooted at the .hg directory.
1395 """VFS rooted at the .hg directory.
1393
1396
1394 Used to access repository data not in the store.
1397 Used to access repository data not in the store.
1395 """)
1398 """)
1396
1399
1397 svfs = interfaceutil.Attribute(
1400 svfs = interfaceutil.Attribute(
1398 """VFS rooted at the store.
1401 """VFS rooted at the store.
1399
1402
1400 Used to access repository data in the store. Typically .hg/store.
1403 Used to access repository data in the store. Typically .hg/store.
1401 But can point elsewhere if the store is shared.
1404 But can point elsewhere if the store is shared.
1402 """)
1405 """)
1403
1406
1404 root = interfaceutil.Attribute(
1407 root = interfaceutil.Attribute(
1405 """Path to the root of the working directory.""")
1408 """Path to the root of the working directory.""")
1406
1409
1407 path = interfaceutil.Attribute(
1410 path = interfaceutil.Attribute(
1408 """Path to the .hg directory.""")
1411 """Path to the .hg directory.""")
1409
1412
1410 origroot = interfaceutil.Attribute(
1413 origroot = interfaceutil.Attribute(
1411 """The filesystem path that was used to construct the repo.""")
1414 """The filesystem path that was used to construct the repo.""")
1412
1415
1413 auditor = interfaceutil.Attribute(
1416 auditor = interfaceutil.Attribute(
1414 """A pathauditor for the working directory.
1417 """A pathauditor for the working directory.
1415
1418
1416 This checks if a path refers to a nested repository.
1419 This checks if a path refers to a nested repository.
1417
1420
1418 Operates on the filesystem.
1421 Operates on the filesystem.
1419 """)
1422 """)
1420
1423
1421 nofsauditor = interfaceutil.Attribute(
1424 nofsauditor = interfaceutil.Attribute(
1422 """A pathauditor for the working directory.
1425 """A pathauditor for the working directory.
1423
1426
1424 This is like ``auditor`` except it doesn't do filesystem checks.
1427 This is like ``auditor`` except it doesn't do filesystem checks.
1425 """)
1428 """)
1426
1429
1427 baseui = interfaceutil.Attribute(
1430 baseui = interfaceutil.Attribute(
1428 """Original ui instance passed into constructor.""")
1431 """Original ui instance passed into constructor.""")
1429
1432
1430 ui = interfaceutil.Attribute(
1433 ui = interfaceutil.Attribute(
1431 """Main ui instance for this instance.""")
1434 """Main ui instance for this instance.""")
1432
1435
1433 sharedpath = interfaceutil.Attribute(
1436 sharedpath = interfaceutil.Attribute(
1434 """Path to the .hg directory of the repo this repo was shared from.""")
1437 """Path to the .hg directory of the repo this repo was shared from.""")
1435
1438
1436 store = interfaceutil.Attribute(
1439 store = interfaceutil.Attribute(
1437 """A store instance.""")
1440 """A store instance.""")
1438
1441
1439 spath = interfaceutil.Attribute(
1442 spath = interfaceutil.Attribute(
1440 """Path to the store.""")
1443 """Path to the store.""")
1441
1444
1442 sjoin = interfaceutil.Attribute(
1445 sjoin = interfaceutil.Attribute(
1443 """Alias to self.store.join.""")
1446 """Alias to self.store.join.""")
1444
1447
1445 cachevfs = interfaceutil.Attribute(
1448 cachevfs = interfaceutil.Attribute(
1446 """A VFS used to access the cache directory.
1449 """A VFS used to access the cache directory.
1447
1450
1448 Typically .hg/cache.
1451 Typically .hg/cache.
1449 """)
1452 """)
1450
1453
1451 wcachevfs = interfaceutil.Attribute(
1454 wcachevfs = interfaceutil.Attribute(
1452 """A VFS used to access the cache directory dedicated to working copy
1455 """A VFS used to access the cache directory dedicated to working copy
1453
1456
1454 Typically .hg/wcache.
1457 Typically .hg/wcache.
1455 """)
1458 """)
1456
1459
1457 filteredrevcache = interfaceutil.Attribute(
1460 filteredrevcache = interfaceutil.Attribute(
1458 """Holds sets of revisions to be filtered.""")
1461 """Holds sets of revisions to be filtered.""")
1459
1462
1460 names = interfaceutil.Attribute(
1463 names = interfaceutil.Attribute(
1461 """A ``namespaces`` instance.""")
1464 """A ``namespaces`` instance.""")
1462
1465
1463 def close():
1466 def close():
1464 """Close the handle on this repository."""
1467 """Close the handle on this repository."""
1465
1468
1466 def peer():
1469 def peer():
1467 """Obtain an object conforming to the ``peer`` interface."""
1470 """Obtain an object conforming to the ``peer`` interface."""
1468
1471
1469 def unfiltered():
1472 def unfiltered():
1470 """Obtain an unfiltered/raw view of this repo."""
1473 """Obtain an unfiltered/raw view of this repo."""
1471
1474
1472 def filtered(name, visibilityexceptions=None):
1475 def filtered(name, visibilityexceptions=None):
1473 """Obtain a named view of this repository."""
1476 """Obtain a named view of this repository."""
1474
1477
1475 obsstore = interfaceutil.Attribute(
1478 obsstore = interfaceutil.Attribute(
1476 """A store of obsolescence data.""")
1479 """A store of obsolescence data.""")
1477
1480
1478 changelog = interfaceutil.Attribute(
1481 changelog = interfaceutil.Attribute(
1479 """A handle on the changelog revlog.""")
1482 """A handle on the changelog revlog.""")
1480
1483
1481 manifestlog = interfaceutil.Attribute(
1484 manifestlog = interfaceutil.Attribute(
1482 """An instance conforming to the ``imanifestlog`` interface.
1485 """An instance conforming to the ``imanifestlog`` interface.
1483
1486
1484 Provides access to manifests for the repository.
1487 Provides access to manifests for the repository.
1485 """)
1488 """)
1486
1489
1487 dirstate = interfaceutil.Attribute(
1490 dirstate = interfaceutil.Attribute(
1488 """Working directory state.""")
1491 """Working directory state.""")
1489
1492
1490 narrowpats = interfaceutil.Attribute(
1493 narrowpats = interfaceutil.Attribute(
1491 """Matcher patterns for this repository's narrowspec.""")
1494 """Matcher patterns for this repository's narrowspec.""")
1492
1495
1493 def narrowmatch(match=None, includeexact=False):
1496 def narrowmatch(match=None, includeexact=False):
1494 """Obtain a matcher for the narrowspec."""
1497 """Obtain a matcher for the narrowspec."""
1495
1498
1496 def setnarrowpats(newincludes, newexcludes):
1499 def setnarrowpats(newincludes, newexcludes):
1497 """Define the narrowspec for this repository."""
1500 """Define the narrowspec for this repository."""
1498
1501
1499 def __getitem__(changeid):
1502 def __getitem__(changeid):
1500 """Try to resolve a changectx."""
1503 """Try to resolve a changectx."""
1501
1504
1502 def __contains__(changeid):
1505 def __contains__(changeid):
1503 """Whether a changeset exists."""
1506 """Whether a changeset exists."""
1504
1507
1505 def __nonzero__():
1508 def __nonzero__():
1506 """Always returns True."""
1509 """Always returns True."""
1507 return True
1510 return True
1508
1511
1509 __bool__ = __nonzero__
1512 __bool__ = __nonzero__
1510
1513
1511 def __len__():
1514 def __len__():
1512 """Returns the number of changesets in the repo."""
1515 """Returns the number of changesets in the repo."""
1513
1516
1514 def __iter__():
1517 def __iter__():
1515 """Iterate over revisions in the changelog."""
1518 """Iterate over revisions in the changelog."""
1516
1519
1517 def revs(expr, *args):
1520 def revs(expr, *args):
1518 """Evaluate a revset.
1521 """Evaluate a revset.
1519
1522
1520 Emits revisions.
1523 Emits revisions.
1521 """
1524 """
1522
1525
1523 def set(expr, *args):
1526 def set(expr, *args):
1524 """Evaluate a revset.
1527 """Evaluate a revset.
1525
1528
1526 Emits changectx instances.
1529 Emits changectx instances.
1527 """
1530 """
1528
1531
1529 def anyrevs(specs, user=False, localalias=None):
1532 def anyrevs(specs, user=False, localalias=None):
1530 """Find revisions matching one of the given revsets."""
1533 """Find revisions matching one of the given revsets."""
1531
1534
1532 def url():
1535 def url():
1533 """Returns a string representing the location of this repo."""
1536 """Returns a string representing the location of this repo."""
1534
1537
1535 def hook(name, throw=False, **args):
1538 def hook(name, throw=False, **args):
1536 """Call a hook."""
1539 """Call a hook."""
1537
1540
1538 def tags():
1541 def tags():
1539 """Return a mapping of tag to node."""
1542 """Return a mapping of tag to node."""
1540
1543
1541 def tagtype(tagname):
1544 def tagtype(tagname):
1542 """Return the type of a given tag."""
1545 """Return the type of a given tag."""
1543
1546
1544 def tagslist():
1547 def tagslist():
1545 """Return a list of tags ordered by revision."""
1548 """Return a list of tags ordered by revision."""
1546
1549
1547 def nodetags(node):
1550 def nodetags(node):
1548 """Return the tags associated with a node."""
1551 """Return the tags associated with a node."""
1549
1552
1550 def nodebookmarks(node):
1553 def nodebookmarks(node):
1551 """Return the list of bookmarks pointing to the specified node."""
1554 """Return the list of bookmarks pointing to the specified node."""
1552
1555
1553 def branchmap():
1556 def branchmap():
1554 """Return a mapping of branch to heads in that branch."""
1557 """Return a mapping of branch to heads in that branch."""
1555
1558
1556 def revbranchcache():
1559 def revbranchcache():
1557 pass
1560 pass
1558
1561
1559 def branchtip(branchtip, ignoremissing=False):
1562 def branchtip(branchtip, ignoremissing=False):
1560 """Return the tip node for a given branch."""
1563 """Return the tip node for a given branch."""
1561
1564
1562 def lookup(key):
1565 def lookup(key):
1563 """Resolve the node for a revision."""
1566 """Resolve the node for a revision."""
1564
1567
1565 def lookupbranch(key):
1568 def lookupbranch(key):
1566 """Look up the branch name of the given revision or branch name."""
1569 """Look up the branch name of the given revision or branch name."""
1567
1570
1568 def known(nodes):
1571 def known(nodes):
1569 """Determine whether a series of nodes is known.
1572 """Determine whether a series of nodes is known.
1570
1573
1571 Returns a list of bools.
1574 Returns a list of bools.
1572 """
1575 """
1573
1576
1574 def local():
1577 def local():
1575 """Whether the repository is local."""
1578 """Whether the repository is local."""
1576 return True
1579 return True
1577
1580
1578 def publishing():
1581 def publishing():
1579 """Whether the repository is a publishing repository."""
1582 """Whether the repository is a publishing repository."""
1580
1583
1581 def cancopy():
1584 def cancopy():
1582 pass
1585 pass
1583
1586
1584 def shared():
1587 def shared():
1585 """The type of shared repository or None."""
1588 """The type of shared repository or None."""
1586
1589
1587 def wjoin(f, *insidef):
1590 def wjoin(f, *insidef):
1588 """Calls self.vfs.reljoin(self.root, f, *insidef)"""
1591 """Calls self.vfs.reljoin(self.root, f, *insidef)"""
1589
1592
1590 def setparents(p1, p2):
1593 def setparents(p1, p2):
1591 """Set the parent nodes of the working directory."""
1594 """Set the parent nodes of the working directory."""
1592
1595
1593 def filectx(path, changeid=None, fileid=None):
1596 def filectx(path, changeid=None, fileid=None):
1594 """Obtain a filectx for the given file revision."""
1597 """Obtain a filectx for the given file revision."""
1595
1598
1596 def getcwd():
1599 def getcwd():
1597 """Obtain the current working directory from the dirstate."""
1600 """Obtain the current working directory from the dirstate."""
1598
1601
1599 def pathto(f, cwd=None):
1602 def pathto(f, cwd=None):
1600 """Obtain the relative path to a file."""
1603 """Obtain the relative path to a file."""
1601
1604
1602 def adddatafilter(name, fltr):
1605 def adddatafilter(name, fltr):
1603 pass
1606 pass
1604
1607
1605 def wread(filename):
1608 def wread(filename):
1606 """Read a file from wvfs, using data filters."""
1609 """Read a file from wvfs, using data filters."""
1607
1610
1608 def wwrite(filename, data, flags, backgroundclose=False, **kwargs):
1611 def wwrite(filename, data, flags, backgroundclose=False, **kwargs):
1609 """Write data to a file in the wvfs, using data filters."""
1612 """Write data to a file in the wvfs, using data filters."""
1610
1613
1611 def wwritedata(filename, data):
1614 def wwritedata(filename, data):
1612 """Resolve data for writing to the wvfs, using data filters."""
1615 """Resolve data for writing to the wvfs, using data filters."""
1613
1616
1614 def currenttransaction():
1617 def currenttransaction():
1615 """Obtain the current transaction instance or None."""
1618 """Obtain the current transaction instance or None."""
1616
1619
1617 def transaction(desc, report=None):
1620 def transaction(desc, report=None):
1618 """Open a new transaction to write to the repository."""
1621 """Open a new transaction to write to the repository."""
1619
1622
1620 def undofiles():
1623 def undofiles():
1621 """Returns a list of (vfs, path) for files to undo transactions."""
1624 """Returns a list of (vfs, path) for files to undo transactions."""
1622
1625
1623 def recover():
1626 def recover():
1624 """Roll back an interrupted transaction."""
1627 """Roll back an interrupted transaction."""
1625
1628
1626 def rollback(dryrun=False, force=False):
1629 def rollback(dryrun=False, force=False):
1627 """Undo the last transaction.
1630 """Undo the last transaction.
1628
1631
1629 DANGEROUS.
1632 DANGEROUS.
1630 """
1633 """
1631
1634
1632 def updatecaches(tr=None, full=False):
1635 def updatecaches(tr=None, full=False):
1633 """Warm repo caches."""
1636 """Warm repo caches."""
1634
1637
1635 def invalidatecaches():
1638 def invalidatecaches():
1636 """Invalidate cached data due to the repository mutating."""
1639 """Invalidate cached data due to the repository mutating."""
1637
1640
1638 def invalidatevolatilesets():
1641 def invalidatevolatilesets():
1639 pass
1642 pass
1640
1643
1641 def invalidatedirstate():
1644 def invalidatedirstate():
1642 """Invalidate the dirstate."""
1645 """Invalidate the dirstate."""
1643
1646
1644 def invalidate(clearfilecache=False):
1647 def invalidate(clearfilecache=False):
1645 pass
1648 pass
1646
1649
1647 def invalidateall():
1650 def invalidateall():
1648 pass
1651 pass
1649
1652
1650 def lock(wait=True):
1653 def lock(wait=True):
1651 """Lock the repository store and return a lock instance."""
1654 """Lock the repository store and return a lock instance."""
1652
1655
1653 def wlock(wait=True):
1656 def wlock(wait=True):
1654 """Lock the non-store parts of the repository."""
1657 """Lock the non-store parts of the repository."""
1655
1658
1656 def currentwlock():
1659 def currentwlock():
1657 """Return the wlock if it's held or None."""
1660 """Return the wlock if it's held or None."""
1658
1661
1659 def checkcommitpatterns(wctx, vdirs, match, status, fail):
1662 def checkcommitpatterns(wctx, vdirs, match, status, fail):
1660 pass
1663 pass
1661
1664
1662 def commit(text='', user=None, date=None, match=None, force=False,
1665 def commit(text='', user=None, date=None, match=None, force=False,
1663 editor=False, extra=None):
1666 editor=False, extra=None):
1664 """Add a new revision to the repository."""
1667 """Add a new revision to the repository."""
1665
1668
1666 def commitctx(ctx, error=False, origctx=None):
1669 def commitctx(ctx, error=False, origctx=None):
1667 """Commit a commitctx instance to the repository."""
1670 """Commit a commitctx instance to the repository."""
1668
1671
1669 def destroying():
1672 def destroying():
1670 """Inform the repository that nodes are about to be destroyed."""
1673 """Inform the repository that nodes are about to be destroyed."""
1671
1674
1672 def destroyed():
1675 def destroyed():
1673 """Inform the repository that nodes have been destroyed."""
1676 """Inform the repository that nodes have been destroyed."""
1674
1677
1675 def status(node1='.', node2=None, match=None, ignored=False,
1678 def status(node1='.', node2=None, match=None, ignored=False,
1676 clean=False, unknown=False, listsubrepos=False):
1679 clean=False, unknown=False, listsubrepos=False):
1677 """Convenience method to call repo[x].status()."""
1680 """Convenience method to call repo[x].status()."""
1678
1681
1679 def addpostdsstatus(ps):
1682 def addpostdsstatus(ps):
1680 pass
1683 pass
1681
1684
1682 def postdsstatus():
1685 def postdsstatus():
1683 pass
1686 pass
1684
1687
1685 def clearpostdsstatus():
1688 def clearpostdsstatus():
1686 pass
1689 pass
1687
1690
1688 def heads(start=None):
1691 def heads(start=None):
1689 """Obtain list of nodes that are DAG heads."""
1692 """Obtain list of nodes that are DAG heads."""
1690
1693
1691 def branchheads(branch=None, start=None, closed=False):
1694 def branchheads(branch=None, start=None, closed=False):
1692 pass
1695 pass
1693
1696
1694 def branches(nodes):
1697 def branches(nodes):
1695 pass
1698 pass
1696
1699
1697 def between(pairs):
1700 def between(pairs):
1698 pass
1701 pass
1699
1702
1700 def checkpush(pushop):
1703 def checkpush(pushop):
1701 pass
1704 pass
1702
1705
1703 prepushoutgoinghooks = interfaceutil.Attribute(
1706 prepushoutgoinghooks = interfaceutil.Attribute(
1704 """util.hooks instance.""")
1707 """util.hooks instance.""")
1705
1708
1706 def pushkey(namespace, key, old, new):
1709 def pushkey(namespace, key, old, new):
1707 pass
1710 pass
1708
1711
1709 def listkeys(namespace):
1712 def listkeys(namespace):
1710 pass
1713 pass
1711
1714
1712 def debugwireargs(one, two, three=None, four=None, five=None):
1715 def debugwireargs(one, two, three=None, four=None, five=None):
1713 pass
1716 pass
1714
1717
1715 def savecommitmessage(text):
1718 def savecommitmessage(text):
1716 pass
1719 pass
1717
1720
1718 class completelocalrepository(ilocalrepositorymain,
1721 class completelocalrepository(ilocalrepositorymain,
1719 ilocalrepositoryfilestorage):
1722 ilocalrepositoryfilestorage):
1720 """Complete interface for a local repository."""
1723 """Complete interface for a local repository."""
1721
1724
1722 class iwireprotocolcommandcacher(interfaceutil.Interface):
1725 class iwireprotocolcommandcacher(interfaceutil.Interface):
1723 """Represents a caching backend for wire protocol commands.
1726 """Represents a caching backend for wire protocol commands.
1724
1727
1725 Wire protocol version 2 supports transparent caching of many commands.
1728 Wire protocol version 2 supports transparent caching of many commands.
1726 To leverage this caching, servers can activate objects that cache
1729 To leverage this caching, servers can activate objects that cache
1727 command responses. Objects handle both cache writing and reading.
1730 command responses. Objects handle both cache writing and reading.
1728 This interface defines how that response caching mechanism works.
1731 This interface defines how that response caching mechanism works.
1729
1732
1730 Wire protocol version 2 commands emit a series of objects that are
1733 Wire protocol version 2 commands emit a series of objects that are
1731 serialized and sent to the client. The caching layer exists between
1734 serialized and sent to the client. The caching layer exists between
1732 the invocation of the command function and the sending of its output
1735 the invocation of the command function and the sending of its output
1733 objects to an output layer.
1736 objects to an output layer.
1734
1737
1735 Instances of this interface represent a binding to a cache that
1738 Instances of this interface represent a binding to a cache that
1736 can serve a response (in place of calling a command function) and/or
1739 can serve a response (in place of calling a command function) and/or
1737 write responses to a cache for subsequent use.
1740 write responses to a cache for subsequent use.
1738
1741
1739 When a command request arrives, the following happens with regards
1742 When a command request arrives, the following happens with regards
1740 to this interface:
1743 to this interface:
1741
1744
1742 1. The server determines whether the command request is cacheable.
1745 1. The server determines whether the command request is cacheable.
1743 2. If it is, an instance of this interface is spawned.
1746 2. If it is, an instance of this interface is spawned.
1744 3. The cacher is activated in a context manager (``__enter__`` is called).
1747 3. The cacher is activated in a context manager (``__enter__`` is called).
1745 4. A cache *key* for that request is derived. This will call the
1748 4. A cache *key* for that request is derived. This will call the
1746 instance's ``adjustcachekeystate()`` method so the derivation
1749 instance's ``adjustcachekeystate()`` method so the derivation
1747 can be influenced.
1750 can be influenced.
1748 5. The cacher is informed of the derived cache key via a call to
1751 5. The cacher is informed of the derived cache key via a call to
1749 ``setcachekey()``.
1752 ``setcachekey()``.
1750 6. The cacher's ``lookup()`` method is called to test for presence of
1753 6. The cacher's ``lookup()`` method is called to test for presence of
1751 the derived key in the cache.
1754 the derived key in the cache.
1752 7. If ``lookup()`` returns a hit, that cached result is used in place
1755 7. If ``lookup()`` returns a hit, that cached result is used in place
1753 of invoking the command function. ``__exit__`` is called and the instance
1756 of invoking the command function. ``__exit__`` is called and the instance
1754 is discarded.
1757 is discarded.
1755 8. The command function is invoked.
1758 8. The command function is invoked.
1756 9. ``onobject()`` is called for each object emitted by the command
1759 9. ``onobject()`` is called for each object emitted by the command
1757 function.
1760 function.
1758 10. After the final object is seen, ``onfinished()`` is called.
1761 10. After the final object is seen, ``onfinished()`` is called.
1759 11. ``__exit__`` is called to signal the end of use of the instance.
1762 11. ``__exit__`` is called to signal the end of use of the instance.
1760
1763
1761 Cache *key* derivation can be influenced by the instance.
1764 Cache *key* derivation can be influenced by the instance.
1762
1765
1763 Cache keys are initially derived by a deterministic representation of
1766 Cache keys are initially derived by a deterministic representation of
1764 the command request. This includes the command name, arguments, protocol
1767 the command request. This includes the command name, arguments, protocol
1765 version, etc. This initial key derivation is performed by CBOR-encoding a
1768 version, etc. This initial key derivation is performed by CBOR-encoding a
1766 data structure and feeding that output into a hasher.
1769 data structure and feeding that output into a hasher.
1767
1770
1768 Instances of this interface can influence this initial key derivation
1771 Instances of this interface can influence this initial key derivation
1769 via ``adjustcachekeystate()``.
1772 via ``adjustcachekeystate()``.
1770
1773
1771 The instance is informed of the derived cache key via a call to
1774 The instance is informed of the derived cache key via a call to
1772 ``setcachekey()``. The instance must store the key locally so it can
1775 ``setcachekey()``. The instance must store the key locally so it can
1773 be consulted on subsequent operations that may require it.
1776 be consulted on subsequent operations that may require it.
1774
1777
1775 When constructed, the instance has access to a callable that can be used
1778 When constructed, the instance has access to a callable that can be used
1776 for encoding response objects. This callable receives as its single
1779 for encoding response objects. This callable receives as its single
1777 argument an object emitted by a command function. It returns an iterable
1780 argument an object emitted by a command function. It returns an iterable
1778 of bytes chunks representing the encoded object. Unless the cacher is
1781 of bytes chunks representing the encoded object. Unless the cacher is
1779 caching native Python objects in memory or has a way of reconstructing
1782 caching native Python objects in memory or has a way of reconstructing
1780 the original Python objects, implementations typically call this function
1783 the original Python objects, implementations typically call this function
1781 to produce bytes from the output objects and then store those bytes in
1784 to produce bytes from the output objects and then store those bytes in
1782 the cache. When it comes time to re-emit those bytes, they are wrapped
1785 the cache. When it comes time to re-emit those bytes, they are wrapped
1783 in a ``wireprototypes.encodedresponse`` instance to tell the output
1786 in a ``wireprototypes.encodedresponse`` instance to tell the output
1784 layer that they are pre-encoded.
1787 layer that they are pre-encoded.
1785
1788
1786 When receiving the objects emitted by the command function, instances
1789 When receiving the objects emitted by the command function, instances
1787 can choose what to do with those objects. The simplest thing to do is
1790 can choose what to do with those objects. The simplest thing to do is
1788 re-emit the original objects. They will be forwarded to the output
1791 re-emit the original objects. They will be forwarded to the output
1789 layer and will be processed as if the cacher did not exist.
1792 layer and will be processed as if the cacher did not exist.
1790
1793
1791 Implementations could also choose to not emit objects - instead locally
1794 Implementations could also choose to not emit objects - instead locally
1792 buffering objects or their encoded representation. They could then emit
1795 buffering objects or their encoded representation. They could then emit
1793 a single "coalesced" object when ``onfinished()`` is called. In
1796 a single "coalesced" object when ``onfinished()`` is called. In
1794 this way, the implementation would function as a filtering layer of
1797 this way, the implementation would function as a filtering layer of
1795 sorts.
1798 sorts.
1796
1799
1797 When caching objects, typically the encoded form of the object will
1800 When caching objects, typically the encoded form of the object will
1798 be stored. Keep in mind that if the original object is forwarded to
1801 be stored. Keep in mind that if the original object is forwarded to
1799 the output layer, it will need to be encoded there as well. For large
1802 the output layer, it will need to be encoded there as well. For large
1800 output, this redundant encoding could add overhead. Implementations
1803 output, this redundant encoding could add overhead. Implementations
1801 could wrap the encoded object data in ``wireprototypes.encodedresponse``
1804 could wrap the encoded object data in ``wireprototypes.encodedresponse``
1802 instances to avoid this overhead.
1805 instances to avoid this overhead.
1803 """
1806 """
1804 def __enter__():
1807 def __enter__():
1805 """Marks the instance as active.
1808 """Marks the instance as active.
1806
1809
1807 Should return self.
1810 Should return self.
1808 """
1811 """
1809
1812
1810 def __exit__(exctype, excvalue, exctb):
1813 def __exit__(exctype, excvalue, exctb):
1811 """Called when cacher is no longer used.
1814 """Called when cacher is no longer used.
1812
1815
1813 This can be used by implementations to perform cleanup actions (e.g.
1816 This can be used by implementations to perform cleanup actions (e.g.
1814 disconnecting network sockets, aborting a partially cached response.
1817 disconnecting network sockets, aborting a partially cached response.
1815 """
1818 """
1816
1819
1817 def adjustcachekeystate(state):
1820 def adjustcachekeystate(state):
1818 """Influences cache key derivation by adjusting state to derive key.
1821 """Influences cache key derivation by adjusting state to derive key.
1819
1822
1820 A dict defining the state used to derive the cache key is passed.
1823 A dict defining the state used to derive the cache key is passed.
1821
1824
1822 Implementations can modify this dict to record additional state that
1825 Implementations can modify this dict to record additional state that
1823 is wanted to influence key derivation.
1826 is wanted to influence key derivation.
1824
1827
1825 Implementations are *highly* encouraged to not modify or delete
1828 Implementations are *highly* encouraged to not modify or delete
1826 existing keys.
1829 existing keys.
1827 """
1830 """
1828
1831
1829 def setcachekey(key):
1832 def setcachekey(key):
1830 """Record the derived cache key for this request.
1833 """Record the derived cache key for this request.
1831
1834
1832 Instances may mutate the key for internal usage, as desired. e.g.
1835 Instances may mutate the key for internal usage, as desired. e.g.
1833 instances may wish to prepend the repo name, introduce path
1836 instances may wish to prepend the repo name, introduce path
1834 components for filesystem or URL addressing, etc. Behavior is up to
1837 components for filesystem or URL addressing, etc. Behavior is up to
1835 the cache.
1838 the cache.
1836
1839
1837 Returns a bool indicating if the request is cacheable by this
1840 Returns a bool indicating if the request is cacheable by this
1838 instance.
1841 instance.
1839 """
1842 """
1840
1843
1841 def lookup():
1844 def lookup():
1842 """Attempt to resolve an entry in the cache.
1845 """Attempt to resolve an entry in the cache.
1843
1846
1844 The instance is instructed to look for the cache key that it was
1847 The instance is instructed to look for the cache key that it was
1845 informed about via the call to ``setcachekey()``.
1848 informed about via the call to ``setcachekey()``.
1846
1849
1847 If there's no cache hit or the cacher doesn't wish to use the cached
1850 If there's no cache hit or the cacher doesn't wish to use the cached
1848 entry, ``None`` should be returned.
1851 entry, ``None`` should be returned.
1849
1852
1850 Else, a dict defining the cached result should be returned. The
1853 Else, a dict defining the cached result should be returned. The
1851 dict may have the following keys:
1854 dict may have the following keys:
1852
1855
1853 objs
1856 objs
1854 An iterable of objects that should be sent to the client. That
1857 An iterable of objects that should be sent to the client. That
1855 iterable of objects is expected to be what the command function
1858 iterable of objects is expected to be what the command function
1856 would return if invoked or an equivalent representation thereof.
1859 would return if invoked or an equivalent representation thereof.
1857 """
1860 """
1858
1861
1859 def onobject(obj):
1862 def onobject(obj):
1860 """Called when a new object is emitted from the command function.
1863 """Called when a new object is emitted from the command function.
1861
1864
1862 Receives as its argument the object that was emitted from the
1865 Receives as its argument the object that was emitted from the
1863 command function.
1866 command function.
1864
1867
1865 This method returns an iterator of objects to forward to the output
1868 This method returns an iterator of objects to forward to the output
1866 layer. The easiest implementation is a generator that just
1869 layer. The easiest implementation is a generator that just
1867 ``yield obj``.
1870 ``yield obj``.
1868 """
1871 """
1869
1872
1870 def onfinished():
1873 def onfinished():
1871 """Called after all objects have been emitted from the command function.
1874 """Called after all objects have been emitted from the command function.
1872
1875
1873 Implementations should return an iterator of objects to forward to
1876 Implementations should return an iterator of objects to forward to
1874 the output layer.
1877 the output layer.
1875
1878
1876 This method can be a generator.
1879 This method can be a generator.
1877 """
1880 """
@@ -1,55 +1,62 b''
1 # revlogdeltas.py - constant used for revlog logic
1 # revlogdeltas.py - constant used for revlog logic
2 #
2 #
3 # Copyright 2005-2007 Matt Mackall <mpm@selenic.com>
3 # Copyright 2005-2007 Matt Mackall <mpm@selenic.com>
4 # Copyright 2018 Octobus <contact@octobus.net>
4 # Copyright 2018 Octobus <contact@octobus.net>
5 #
5 #
6 # This software may be used and distributed according to the terms of the
6 # This software may be used and distributed according to the terms of the
7 # GNU General Public License version 2 or any later version.
7 # GNU General Public License version 2 or any later version.
8 """Helper class to compute deltas stored inside revlogs"""
8 """Helper class to compute deltas stored inside revlogs"""
9
9
10 from __future__ import absolute_import
10 from __future__ import absolute_import
11
11
12 from ..interfaces import (
12 from ..interfaces import (
13 repository,
13 repository,
14 )
14 )
15
15
16 # revlog header flags
16 # revlog header flags
17 REVLOGV0 = 0
17 REVLOGV0 = 0
18 REVLOGV1 = 1
18 REVLOGV1 = 1
19 # Dummy value until file format is finalized.
19 # Dummy value until file format is finalized.
20 # Reminder: change the bounds check in revlog.__init__ when this is changed.
20 # Reminder: change the bounds check in revlog.__init__ when this is changed.
21 REVLOGV2 = 0xDEAD
21 REVLOGV2 = 0xDEAD
22 # Shared across v1 and v2.
22 # Shared across v1 and v2.
23 FLAG_INLINE_DATA = (1 << 16)
23 FLAG_INLINE_DATA = (1 << 16)
24 # Only used by v1, implied by v2.
24 # Only used by v1, implied by v2.
25 FLAG_GENERALDELTA = (1 << 17)
25 FLAG_GENERALDELTA = (1 << 17)
26 REVLOG_DEFAULT_FLAGS = FLAG_INLINE_DATA
26 REVLOG_DEFAULT_FLAGS = FLAG_INLINE_DATA
27 REVLOG_DEFAULT_FORMAT = REVLOGV1
27 REVLOG_DEFAULT_FORMAT = REVLOGV1
28 REVLOG_DEFAULT_VERSION = REVLOG_DEFAULT_FORMAT | REVLOG_DEFAULT_FLAGS
28 REVLOG_DEFAULT_VERSION = REVLOG_DEFAULT_FORMAT | REVLOG_DEFAULT_FLAGS
29 REVLOGV1_FLAGS = FLAG_INLINE_DATA | FLAG_GENERALDELTA
29 REVLOGV1_FLAGS = FLAG_INLINE_DATA | FLAG_GENERALDELTA
30 REVLOGV2_FLAGS = FLAG_INLINE_DATA
30 REVLOGV2_FLAGS = FLAG_INLINE_DATA
31
31
32 # revlog index flags
32 # revlog index flags
33
33
34 # For historical reasons, revlog's internal flags were exposed via the
34 # For historical reasons, revlog's internal flags were exposed via the
35 # wire protocol and are even exposed in parts of the storage APIs.
35 # wire protocol and are even exposed in parts of the storage APIs.
36
36
37 # revision has censor metadata, must be verified
37 # revision has censor metadata, must be verified
38 REVIDX_ISCENSORED = repository.REVISION_FLAG_CENSORED
38 REVIDX_ISCENSORED = repository.REVISION_FLAG_CENSORED
39 # revision hash does not match data (narrowhg)
39 # revision hash does not match data (narrowhg)
40 REVIDX_ELLIPSIS = repository.REVISION_FLAG_ELLIPSIS
40 REVIDX_ELLIPSIS = repository.REVISION_FLAG_ELLIPSIS
41 # revision data is stored externally
41 # revision data is stored externally
42 REVIDX_EXTSTORED = repository.REVISION_FLAG_EXTSTORED
42 REVIDX_EXTSTORED = repository.REVISION_FLAG_EXTSTORED
43 # revision data contains extra metadata not part of the official digest
44 REVIDX_SIDEDATA = repository.REVISION_FLAG_SIDEDATA
43 REVIDX_DEFAULT_FLAGS = 0
45 REVIDX_DEFAULT_FLAGS = 0
44 # stable order in which flags need to be processed and their processors applied
46 # stable order in which flags need to be processed and their processors applied
45 REVIDX_FLAGS_ORDER = [
47 REVIDX_FLAGS_ORDER = [
46 REVIDX_ISCENSORED,
48 REVIDX_ISCENSORED,
47 REVIDX_ELLIPSIS,
49 REVIDX_ELLIPSIS,
48 REVIDX_EXTSTORED,
50 REVIDX_EXTSTORED,
51 REVIDX_SIDEDATA,
49 ]
52 ]
50
53
51 # bitmark for flags that could cause rawdata content change
54 # bitmark for flags that could cause rawdata content change
52 REVIDX_RAWTEXT_CHANGING_FLAGS = REVIDX_ISCENSORED | REVIDX_EXTSTORED
55 REVIDX_RAWTEXT_CHANGING_FLAGS = (
56 REVIDX_ISCENSORED
57 | REVIDX_EXTSTORED
58 | REVIDX_SIDEDATA
59 )
53
60
54 SPARSE_REVLOG_MAX_CHAIN_LENGTH = 1000
61 SPARSE_REVLOG_MAX_CHAIN_LENGTH = 1000
55
62
General Comments 0
You need to be logged in to leave comments. Login now