##// END OF EJS Templates
repository: document that file() return value conforms to interface...
Gregory Szorc -
r38528:5cfb01d5 default
parent child Browse files
Show More
@@ -1,994 +1,997 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 .utils import (
14 from .utils import (
15 interfaceutil,
15 interfaceutil,
16 )
16 )
17
17
18 class ipeerconnection(interfaceutil.Interface):
18 class ipeerconnection(interfaceutil.Interface):
19 """Represents a "connection" to a repository.
19 """Represents a "connection" to a repository.
20
20
21 This is the base interface for representing a connection to a repository.
21 This is the base interface for representing a connection to a repository.
22 It holds basic properties and methods applicable to all peer types.
22 It holds basic properties and methods applicable to all peer types.
23
23
24 This is not a complete interface definition and should not be used
24 This is not a complete interface definition and should not be used
25 outside of this module.
25 outside of this module.
26 """
26 """
27 ui = interfaceutil.Attribute("""ui.ui instance""")
27 ui = interfaceutil.Attribute("""ui.ui instance""")
28
28
29 def url():
29 def url():
30 """Returns a URL string representing this peer.
30 """Returns a URL string representing this peer.
31
31
32 Currently, implementations expose the raw URL used to construct the
32 Currently, implementations expose the raw URL used to construct the
33 instance. It may contain credentials as part of the URL. The
33 instance. It may contain credentials as part of the URL. The
34 expectations of the value aren't well-defined and this could lead to
34 expectations of the value aren't well-defined and this could lead to
35 data leakage.
35 data leakage.
36
36
37 TODO audit/clean consumers and more clearly define the contents of this
37 TODO audit/clean consumers and more clearly define the contents of this
38 value.
38 value.
39 """
39 """
40
40
41 def local():
41 def local():
42 """Returns a local repository instance.
42 """Returns a local repository instance.
43
43
44 If the peer represents a local repository, returns an object that
44 If the peer represents a local repository, returns an object that
45 can be used to interface with it. Otherwise returns ``None``.
45 can be used to interface with it. Otherwise returns ``None``.
46 """
46 """
47
47
48 def peer():
48 def peer():
49 """Returns an object conforming to this interface.
49 """Returns an object conforming to this interface.
50
50
51 Most implementations will ``return self``.
51 Most implementations will ``return self``.
52 """
52 """
53
53
54 def canpush():
54 def canpush():
55 """Returns a boolean indicating if this peer can be pushed to."""
55 """Returns a boolean indicating if this peer can be pushed to."""
56
56
57 def close():
57 def close():
58 """Close the connection to this peer.
58 """Close the connection to this peer.
59
59
60 This is called when the peer will no longer be used. Resources
60 This is called when the peer will no longer be used. Resources
61 associated with the peer should be cleaned up.
61 associated with the peer should be cleaned up.
62 """
62 """
63
63
64 class ipeercapabilities(interfaceutil.Interface):
64 class ipeercapabilities(interfaceutil.Interface):
65 """Peer sub-interface related to capabilities."""
65 """Peer sub-interface related to capabilities."""
66
66
67 def capable(name):
67 def capable(name):
68 """Determine support for a named capability.
68 """Determine support for a named capability.
69
69
70 Returns ``False`` if capability not supported.
70 Returns ``False`` if capability not supported.
71
71
72 Returns ``True`` if boolean capability is supported. Returns a string
72 Returns ``True`` if boolean capability is supported. Returns a string
73 if capability support is non-boolean.
73 if capability support is non-boolean.
74
74
75 Capability strings may or may not map to wire protocol capabilities.
75 Capability strings may or may not map to wire protocol capabilities.
76 """
76 """
77
77
78 def requirecap(name, purpose):
78 def requirecap(name, purpose):
79 """Require a capability to be present.
79 """Require a capability to be present.
80
80
81 Raises a ``CapabilityError`` if the capability isn't present.
81 Raises a ``CapabilityError`` if the capability isn't present.
82 """
82 """
83
83
84 class ipeercommands(interfaceutil.Interface):
84 class ipeercommands(interfaceutil.Interface):
85 """Client-side interface for communicating over the wire protocol.
85 """Client-side interface for communicating over the wire protocol.
86
86
87 This interface is used as a gateway to the Mercurial wire protocol.
87 This interface is used as a gateway to the Mercurial wire protocol.
88 methods commonly call wire protocol commands of the same name.
88 methods commonly call wire protocol commands of the same name.
89 """
89 """
90
90
91 def branchmap():
91 def branchmap():
92 """Obtain heads in named branches.
92 """Obtain heads in named branches.
93
93
94 Returns a dict mapping branch name to an iterable of nodes that are
94 Returns a dict mapping branch name to an iterable of nodes that are
95 heads on that branch.
95 heads on that branch.
96 """
96 """
97
97
98 def capabilities():
98 def capabilities():
99 """Obtain capabilities of the peer.
99 """Obtain capabilities of the peer.
100
100
101 Returns a set of string capabilities.
101 Returns a set of string capabilities.
102 """
102 """
103
103
104 def clonebundles():
104 def clonebundles():
105 """Obtains the clone bundles manifest for the repo.
105 """Obtains the clone bundles manifest for the repo.
106
106
107 Returns the manifest as unparsed bytes.
107 Returns the manifest as unparsed bytes.
108 """
108 """
109
109
110 def debugwireargs(one, two, three=None, four=None, five=None):
110 def debugwireargs(one, two, three=None, four=None, five=None):
111 """Used to facilitate debugging of arguments passed over the wire."""
111 """Used to facilitate debugging of arguments passed over the wire."""
112
112
113 def getbundle(source, **kwargs):
113 def getbundle(source, **kwargs):
114 """Obtain remote repository data as a bundle.
114 """Obtain remote repository data as a bundle.
115
115
116 This command is how the bulk of repository data is transferred from
116 This command is how the bulk of repository data is transferred from
117 the peer to the local repository
117 the peer to the local repository
118
118
119 Returns a generator of bundle data.
119 Returns a generator of bundle data.
120 """
120 """
121
121
122 def heads():
122 def heads():
123 """Determine all known head revisions in the peer.
123 """Determine all known head revisions in the peer.
124
124
125 Returns an iterable of binary nodes.
125 Returns an iterable of binary nodes.
126 """
126 """
127
127
128 def known(nodes):
128 def known(nodes):
129 """Determine whether multiple nodes are known.
129 """Determine whether multiple nodes are known.
130
130
131 Accepts an iterable of nodes whose presence to check for.
131 Accepts an iterable of nodes whose presence to check for.
132
132
133 Returns an iterable of booleans indicating of the corresponding node
133 Returns an iterable of booleans indicating of the corresponding node
134 at that index is known to the peer.
134 at that index is known to the peer.
135 """
135 """
136
136
137 def listkeys(namespace):
137 def listkeys(namespace):
138 """Obtain all keys in a pushkey namespace.
138 """Obtain all keys in a pushkey namespace.
139
139
140 Returns an iterable of key names.
140 Returns an iterable of key names.
141 """
141 """
142
142
143 def lookup(key):
143 def lookup(key):
144 """Resolve a value to a known revision.
144 """Resolve a value to a known revision.
145
145
146 Returns a binary node of the resolved revision on success.
146 Returns a binary node of the resolved revision on success.
147 """
147 """
148
148
149 def pushkey(namespace, key, old, new):
149 def pushkey(namespace, key, old, new):
150 """Set a value using the ``pushkey`` protocol.
150 """Set a value using the ``pushkey`` protocol.
151
151
152 Arguments correspond to the pushkey namespace and key to operate on and
152 Arguments correspond to the pushkey namespace and key to operate on and
153 the old and new values for that key.
153 the old and new values for that key.
154
154
155 Returns a string with the peer result. The value inside varies by the
155 Returns a string with the peer result. The value inside varies by the
156 namespace.
156 namespace.
157 """
157 """
158
158
159 def stream_out():
159 def stream_out():
160 """Obtain streaming clone data.
160 """Obtain streaming clone data.
161
161
162 Successful result should be a generator of data chunks.
162 Successful result should be a generator of data chunks.
163 """
163 """
164
164
165 def unbundle(bundle, heads, url):
165 def unbundle(bundle, heads, url):
166 """Transfer repository data to the peer.
166 """Transfer repository data to the peer.
167
167
168 This is how the bulk of data during a push is transferred.
168 This is how the bulk of data during a push is transferred.
169
169
170 Returns the integer number of heads added to the peer.
170 Returns the integer number of heads added to the peer.
171 """
171 """
172
172
173 class ipeerlegacycommands(interfaceutil.Interface):
173 class ipeerlegacycommands(interfaceutil.Interface):
174 """Interface for implementing support for legacy wire protocol commands.
174 """Interface for implementing support for legacy wire protocol commands.
175
175
176 Wire protocol commands transition to legacy status when they are no longer
176 Wire protocol commands transition to legacy status when they are no longer
177 used by modern clients. To facilitate identifying which commands are
177 used by modern clients. To facilitate identifying which commands are
178 legacy, the interfaces are split.
178 legacy, the interfaces are split.
179 """
179 """
180
180
181 def between(pairs):
181 def between(pairs):
182 """Obtain nodes between pairs of nodes.
182 """Obtain nodes between pairs of nodes.
183
183
184 ``pairs`` is an iterable of node pairs.
184 ``pairs`` is an iterable of node pairs.
185
185
186 Returns an iterable of iterables of nodes corresponding to each
186 Returns an iterable of iterables of nodes corresponding to each
187 requested pair.
187 requested pair.
188 """
188 """
189
189
190 def branches(nodes):
190 def branches(nodes):
191 """Obtain ancestor changesets of specific nodes back to a branch point.
191 """Obtain ancestor changesets of specific nodes back to a branch point.
192
192
193 For each requested node, the peer finds the first ancestor node that is
193 For each requested node, the peer finds the first ancestor node that is
194 a DAG root or is a merge.
194 a DAG root or is a merge.
195
195
196 Returns an iterable of iterables with the resolved values for each node.
196 Returns an iterable of iterables with the resolved values for each node.
197 """
197 """
198
198
199 def changegroup(nodes, source):
199 def changegroup(nodes, source):
200 """Obtain a changegroup with data for descendants of specified nodes."""
200 """Obtain a changegroup with data for descendants of specified nodes."""
201
201
202 def changegroupsubset(bases, heads, source):
202 def changegroupsubset(bases, heads, source):
203 pass
203 pass
204
204
205 class ipeercommandexecutor(interfaceutil.Interface):
205 class ipeercommandexecutor(interfaceutil.Interface):
206 """Represents a mechanism to execute remote commands.
206 """Represents a mechanism to execute remote commands.
207
207
208 This is the primary interface for requesting that wire protocol commands
208 This is the primary interface for requesting that wire protocol commands
209 be executed. Instances of this interface are active in a context manager
209 be executed. Instances of this interface are active in a context manager
210 and have a well-defined lifetime. When the context manager exits, all
210 and have a well-defined lifetime. When the context manager exits, all
211 outstanding requests are waited on.
211 outstanding requests are waited on.
212 """
212 """
213
213
214 def callcommand(name, args):
214 def callcommand(name, args):
215 """Request that a named command be executed.
215 """Request that a named command be executed.
216
216
217 Receives the command name and a dictionary of command arguments.
217 Receives the command name and a dictionary of command arguments.
218
218
219 Returns a ``concurrent.futures.Future`` that will resolve to the
219 Returns a ``concurrent.futures.Future`` that will resolve to the
220 result of that command request. That exact value is left up to
220 result of that command request. That exact value is left up to
221 the implementation and possibly varies by command.
221 the implementation and possibly varies by command.
222
222
223 Not all commands can coexist with other commands in an executor
223 Not all commands can coexist with other commands in an executor
224 instance: it depends on the underlying wire protocol transport being
224 instance: it depends on the underlying wire protocol transport being
225 used and the command itself.
225 used and the command itself.
226
226
227 Implementations MAY call ``sendcommands()`` automatically if the
227 Implementations MAY call ``sendcommands()`` automatically if the
228 requested command can not coexist with other commands in this executor.
228 requested command can not coexist with other commands in this executor.
229
229
230 Implementations MAY call ``sendcommands()`` automatically when the
230 Implementations MAY call ``sendcommands()`` automatically when the
231 future's ``result()`` is called. So, consumers using multiple
231 future's ``result()`` is called. So, consumers using multiple
232 commands with an executor MUST ensure that ``result()`` is not called
232 commands with an executor MUST ensure that ``result()`` is not called
233 until all command requests have been issued.
233 until all command requests have been issued.
234 """
234 """
235
235
236 def sendcommands():
236 def sendcommands():
237 """Trigger submission of queued command requests.
237 """Trigger submission of queued command requests.
238
238
239 Not all transports submit commands as soon as they are requested to
239 Not all transports submit commands as soon as they are requested to
240 run. When called, this method forces queued command requests to be
240 run. When called, this method forces queued command requests to be
241 issued. It will no-op if all commands have already been sent.
241 issued. It will no-op if all commands have already been sent.
242
242
243 When called, no more new commands may be issued with this executor.
243 When called, no more new commands may be issued with this executor.
244 """
244 """
245
245
246 def close():
246 def close():
247 """Signal that this command request is finished.
247 """Signal that this command request is finished.
248
248
249 When called, no more new commands may be issued. All outstanding
249 When called, no more new commands may be issued. All outstanding
250 commands that have previously been issued are waited on before
250 commands that have previously been issued are waited on before
251 returning. This not only includes waiting for the futures to resolve,
251 returning. This not only includes waiting for the futures to resolve,
252 but also waiting for all response data to arrive. In other words,
252 but also waiting for all response data to arrive. In other words,
253 calling this waits for all on-wire state for issued command requests
253 calling this waits for all on-wire state for issued command requests
254 to finish.
254 to finish.
255
255
256 When used as a context manager, this method is called when exiting the
256 When used as a context manager, this method is called when exiting the
257 context manager.
257 context manager.
258
258
259 This method may call ``sendcommands()`` if there are buffered commands.
259 This method may call ``sendcommands()`` if there are buffered commands.
260 """
260 """
261
261
262 class ipeerrequests(interfaceutil.Interface):
262 class ipeerrequests(interfaceutil.Interface):
263 """Interface for executing commands on a peer."""
263 """Interface for executing commands on a peer."""
264
264
265 def commandexecutor():
265 def commandexecutor():
266 """A context manager that resolves to an ipeercommandexecutor.
266 """A context manager that resolves to an ipeercommandexecutor.
267
267
268 The object this resolves to can be used to issue command requests
268 The object this resolves to can be used to issue command requests
269 to the peer.
269 to the peer.
270
270
271 Callers should call its ``callcommand`` method to issue command
271 Callers should call its ``callcommand`` method to issue command
272 requests.
272 requests.
273
273
274 A new executor should be obtained for each distinct set of commands
274 A new executor should be obtained for each distinct set of commands
275 (possibly just a single command) that the consumer wants to execute
275 (possibly just a single command) that the consumer wants to execute
276 as part of a single operation or round trip. This is because some
276 as part of a single operation or round trip. This is because some
277 peers are half-duplex and/or don't support persistent connections.
277 peers are half-duplex and/or don't support persistent connections.
278 e.g. in the case of HTTP peers, commands sent to an executor represent
278 e.g. in the case of HTTP peers, commands sent to an executor represent
279 a single HTTP request. While some peers may support multiple command
279 a single HTTP request. While some peers may support multiple command
280 sends over the wire per executor, consumers need to code to the least
280 sends over the wire per executor, consumers need to code to the least
281 capable peer. So it should be assumed that command executors buffer
281 capable peer. So it should be assumed that command executors buffer
282 called commands until they are told to send them and that each
282 called commands until they are told to send them and that each
283 command executor could result in a new connection or wire-level request
283 command executor could result in a new connection or wire-level request
284 being issued.
284 being issued.
285 """
285 """
286
286
287 class ipeerbase(ipeerconnection, ipeercapabilities, ipeerrequests):
287 class ipeerbase(ipeerconnection, ipeercapabilities, ipeerrequests):
288 """Unified interface for peer repositories.
288 """Unified interface for peer repositories.
289
289
290 All peer instances must conform to this interface.
290 All peer instances must conform to this interface.
291 """
291 """
292
292
293 @interfaceutil.implementer(ipeerbase)
293 @interfaceutil.implementer(ipeerbase)
294 class peer(object):
294 class peer(object):
295 """Base class for peer repositories."""
295 """Base class for peer repositories."""
296
296
297 def capable(self, name):
297 def capable(self, name):
298 caps = self.capabilities()
298 caps = self.capabilities()
299 if name in caps:
299 if name in caps:
300 return True
300 return True
301
301
302 name = '%s=' % name
302 name = '%s=' % name
303 for cap in caps:
303 for cap in caps:
304 if cap.startswith(name):
304 if cap.startswith(name):
305 return cap[len(name):]
305 return cap[len(name):]
306
306
307 return False
307 return False
308
308
309 def requirecap(self, name, purpose):
309 def requirecap(self, name, purpose):
310 if self.capable(name):
310 if self.capable(name):
311 return
311 return
312
312
313 raise error.CapabilityError(
313 raise error.CapabilityError(
314 _('cannot %s; remote repository does not support the %r '
314 _('cannot %s; remote repository does not support the %r '
315 'capability') % (purpose, name))
315 'capability') % (purpose, name))
316
316
317 class ifilerevisionssequence(interfaceutil.Interface):
317 class ifilerevisionssequence(interfaceutil.Interface):
318 """Contains index data for all revisions of a file.
318 """Contains index data for all revisions of a file.
319
319
320 Types implementing this behave like lists of tuples. The index
320 Types implementing this behave like lists of tuples. The index
321 in the list corresponds to the revision number. The values contain
321 in the list corresponds to the revision number. The values contain
322 index metadata.
322 index metadata.
323
323
324 The *null* revision (revision number -1) is always the last item
324 The *null* revision (revision number -1) is always the last item
325 in the index.
325 in the index.
326 """
326 """
327
327
328 def __len__():
328 def __len__():
329 """The total number of revisions."""
329 """The total number of revisions."""
330
330
331 def __getitem__(rev):
331 def __getitem__(rev):
332 """Returns the object having a specific revision number.
332 """Returns the object having a specific revision number.
333
333
334 Returns an 8-tuple with the following fields:
334 Returns an 8-tuple with the following fields:
335
335
336 offset+flags
336 offset+flags
337 Contains the offset and flags for the revision. 64-bit unsigned
337 Contains the offset and flags for the revision. 64-bit unsigned
338 integer where first 6 bytes are the offset and the next 2 bytes
338 integer where first 6 bytes are the offset and the next 2 bytes
339 are flags. The offset can be 0 if it is not used by the store.
339 are flags. The offset can be 0 if it is not used by the store.
340 compressed size
340 compressed size
341 Size of the revision data in the store. It can be 0 if it isn't
341 Size of the revision data in the store. It can be 0 if it isn't
342 needed by the store.
342 needed by the store.
343 uncompressed size
343 uncompressed size
344 Fulltext size. It can be 0 if it isn't needed by the store.
344 Fulltext size. It can be 0 if it isn't needed by the store.
345 base revision
345 base revision
346 Revision number of revision the delta for storage is encoded
346 Revision number of revision the delta for storage is encoded
347 against. -1 indicates not encoded against a base revision.
347 against. -1 indicates not encoded against a base revision.
348 link revision
348 link revision
349 Revision number of changelog revision this entry is related to.
349 Revision number of changelog revision this entry is related to.
350 p1 revision
350 p1 revision
351 Revision number of 1st parent. -1 if no 1st parent.
351 Revision number of 1st parent. -1 if no 1st parent.
352 p2 revision
352 p2 revision
353 Revision number of 2nd parent. -1 if no 1st parent.
353 Revision number of 2nd parent. -1 if no 1st parent.
354 node
354 node
355 Binary node value for this revision number.
355 Binary node value for this revision number.
356
356
357 Negative values should index off the end of the sequence. ``-1``
357 Negative values should index off the end of the sequence. ``-1``
358 should return the null revision. ``-2`` should return the most
358 should return the null revision. ``-2`` should return the most
359 recent revision.
359 recent revision.
360 """
360 """
361
361
362 def __contains__(rev):
362 def __contains__(rev):
363 """Whether a revision number exists."""
363 """Whether a revision number exists."""
364
364
365 def insert(self, i, entry):
365 def insert(self, i, entry):
366 """Add an item to the index at specific revision."""
366 """Add an item to the index at specific revision."""
367
367
368 class ifileindex(interfaceutil.Interface):
368 class ifileindex(interfaceutil.Interface):
369 """Storage interface for index data of a single file.
369 """Storage interface for index data of a single file.
370
370
371 File storage data is divided into index metadata and data storage.
371 File storage data is divided into index metadata and data storage.
372 This interface defines the index portion of the interface.
372 This interface defines the index portion of the interface.
373
373
374 The index logically consists of:
374 The index logically consists of:
375
375
376 * A mapping between revision numbers and nodes.
376 * A mapping between revision numbers and nodes.
377 * DAG data (storing and querying the relationship between nodes).
377 * DAG data (storing and querying the relationship between nodes).
378 * Metadata to facilitate storage.
378 * Metadata to facilitate storage.
379 """
379 """
380 index = interfaceutil.Attribute(
380 index = interfaceutil.Attribute(
381 """An ``ifilerevisionssequence`` instance.""")
381 """An ``ifilerevisionssequence`` instance.""")
382
382
383 def __len__():
383 def __len__():
384 """Obtain the number of revisions stored for this file."""
384 """Obtain the number of revisions stored for this file."""
385
385
386 def __iter__():
386 def __iter__():
387 """Iterate over revision numbers for this file."""
387 """Iterate over revision numbers for this file."""
388
388
389 def revs(start=0, stop=None):
389 def revs(start=0, stop=None):
390 """Iterate over revision numbers for this file, with control."""
390 """Iterate over revision numbers for this file, with control."""
391
391
392 def parents(node):
392 def parents(node):
393 """Returns a 2-tuple of parent nodes for a revision.
393 """Returns a 2-tuple of parent nodes for a revision.
394
394
395 Values will be ``nullid`` if the parent is empty.
395 Values will be ``nullid`` if the parent is empty.
396 """
396 """
397
397
398 def parentrevs(rev):
398 def parentrevs(rev):
399 """Like parents() but operates on revision numbers."""
399 """Like parents() but operates on revision numbers."""
400
400
401 def rev(node):
401 def rev(node):
402 """Obtain the revision number given a node.
402 """Obtain the revision number given a node.
403
403
404 Raises ``error.LookupError`` if the node is not known.
404 Raises ``error.LookupError`` if the node is not known.
405 """
405 """
406
406
407 def node(rev):
407 def node(rev):
408 """Obtain the node value given a revision number.
408 """Obtain the node value given a revision number.
409
409
410 Raises ``IndexError`` if the node is not known.
410 Raises ``IndexError`` if the node is not known.
411 """
411 """
412
412
413 def lookup(node):
413 def lookup(node):
414 """Attempt to resolve a value to a node.
414 """Attempt to resolve a value to a node.
415
415
416 Value can be a binary node, hex node, revision number, or a string
416 Value can be a binary node, hex node, revision number, or a string
417 that can be converted to an integer.
417 that can be converted to an integer.
418
418
419 Raises ``error.LookupError`` if a node could not be resolved.
419 Raises ``error.LookupError`` if a node could not be resolved.
420 """
420 """
421
421
422 def linkrev(rev):
422 def linkrev(rev):
423 """Obtain the changeset revision number a revision is linked to."""
423 """Obtain the changeset revision number a revision is linked to."""
424
424
425 def flags(rev):
425 def flags(rev):
426 """Obtain flags used to affect storage of a revision."""
426 """Obtain flags used to affect storage of a revision."""
427
427
428 def iscensored(rev):
428 def iscensored(rev):
429 """Return whether a revision's content has been censored."""
429 """Return whether a revision's content has been censored."""
430
430
431 def commonancestorsheads(node1, node2):
431 def commonancestorsheads(node1, node2):
432 """Obtain an iterable of nodes containing heads of common ancestors.
432 """Obtain an iterable of nodes containing heads of common ancestors.
433
433
434 See ``ancestor.commonancestorsheads()``.
434 See ``ancestor.commonancestorsheads()``.
435 """
435 """
436
436
437 def descendants(revs):
437 def descendants(revs):
438 """Obtain descendant revision numbers for a set of revision numbers.
438 """Obtain descendant revision numbers for a set of revision numbers.
439
439
440 If ``nullrev`` is in the set, this is equivalent to ``revs()``.
440 If ``nullrev`` is in the set, this is equivalent to ``revs()``.
441 """
441 """
442
442
443 def headrevs():
443 def headrevs():
444 """Obtain a list of revision numbers that are DAG heads.
444 """Obtain a list of revision numbers that are DAG heads.
445
445
446 The list is sorted oldest to newest.
446 The list is sorted oldest to newest.
447
447
448 TODO determine if sorting is required.
448 TODO determine if sorting is required.
449 """
449 """
450
450
451 def heads(start=None, stop=None):
451 def heads(start=None, stop=None):
452 """Obtain a list of nodes that are DAG heads, with control.
452 """Obtain a list of nodes that are DAG heads, with control.
453
453
454 The set of revisions examined can be limited by specifying
454 The set of revisions examined can be limited by specifying
455 ``start`` and ``stop``. ``start`` is a node. ``stop`` is an
455 ``start`` and ``stop``. ``start`` is a node. ``stop`` is an
456 iterable of nodes. DAG traversal starts at earlier revision
456 iterable of nodes. DAG traversal starts at earlier revision
457 ``start`` and iterates forward until any node in ``stop`` is
457 ``start`` and iterates forward until any node in ``stop`` is
458 encountered.
458 encountered.
459 """
459 """
460
460
461 def children(node):
461 def children(node):
462 """Obtain nodes that are children of a node.
462 """Obtain nodes that are children of a node.
463
463
464 Returns a list of nodes.
464 Returns a list of nodes.
465 """
465 """
466
466
467 def deltaparent(rev):
467 def deltaparent(rev):
468 """"Return the revision that is a suitable parent to delta against."""
468 """"Return the revision that is a suitable parent to delta against."""
469
469
470 def candelta(baserev, rev):
470 def candelta(baserev, rev):
471 """"Whether a delta can be generated between two revisions."""
471 """"Whether a delta can be generated between two revisions."""
472
472
473 class ifiledata(interfaceutil.Interface):
473 class ifiledata(interfaceutil.Interface):
474 """Storage interface for data storage of a specific file.
474 """Storage interface for data storage of a specific file.
475
475
476 This complements ``ifileindex`` and provides an interface for accessing
476 This complements ``ifileindex`` and provides an interface for accessing
477 data for a tracked file.
477 data for a tracked file.
478 """
478 """
479 def rawsize(rev):
479 def rawsize(rev):
480 """The size of the fulltext data for a revision as stored."""
480 """The size of the fulltext data for a revision as stored."""
481
481
482 def size(rev):
482 def size(rev):
483 """Obtain the fulltext size of file data.
483 """Obtain the fulltext size of file data.
484
484
485 Any metadata is excluded from size measurements. Use ``rawsize()`` if
485 Any metadata is excluded from size measurements. Use ``rawsize()`` if
486 metadata size is important.
486 metadata size is important.
487 """
487 """
488
488
489 def checkhash(fulltext, node, p1=None, p2=None, rev=None):
489 def checkhash(fulltext, node, p1=None, p2=None, rev=None):
490 """Validate the stored hash of a given fulltext and node.
490 """Validate the stored hash of a given fulltext and node.
491
491
492 Raises ``error.RevlogError`` is hash validation fails.
492 Raises ``error.RevlogError`` is hash validation fails.
493 """
493 """
494
494
495 def revision(node, raw=False):
495 def revision(node, raw=False):
496 """"Obtain fulltext data for a node.
496 """"Obtain fulltext data for a node.
497
497
498 By default, any storage transformations are applied before the data
498 By default, any storage transformations are applied before the data
499 is returned. If ``raw`` is True, non-raw storage transformations
499 is returned. If ``raw`` is True, non-raw storage transformations
500 are not applied.
500 are not applied.
501
501
502 The fulltext data may contain a header containing metadata. Most
502 The fulltext data may contain a header containing metadata. Most
503 consumers should use ``read()`` to obtain the actual file data.
503 consumers should use ``read()`` to obtain the actual file data.
504 """
504 """
505
505
506 def read(node):
506 def read(node):
507 """Resolve file fulltext data.
507 """Resolve file fulltext data.
508
508
509 This is similar to ``revision()`` except any metadata in the data
509 This is similar to ``revision()`` except any metadata in the data
510 headers is stripped.
510 headers is stripped.
511 """
511 """
512
512
513 def renamed(node):
513 def renamed(node):
514 """Obtain copy metadata for a node.
514 """Obtain copy metadata for a node.
515
515
516 Returns ``False`` if no copy metadata is stored or a 2-tuple of
516 Returns ``False`` if no copy metadata is stored or a 2-tuple of
517 (path, node) from which this revision was copied.
517 (path, node) from which this revision was copied.
518 """
518 """
519
519
520 def cmp(node, fulltext):
520 def cmp(node, fulltext):
521 """Compare fulltext to another revision.
521 """Compare fulltext to another revision.
522
522
523 Returns True if the fulltext is different from what is stored.
523 Returns True if the fulltext is different from what is stored.
524
524
525 This takes copy metadata into account.
525 This takes copy metadata into account.
526
526
527 TODO better document the copy metadata and censoring logic.
527 TODO better document the copy metadata and censoring logic.
528 """
528 """
529
529
530 def revdiff(rev1, rev2):
530 def revdiff(rev1, rev2):
531 """Obtain a delta between two revision numbers.
531 """Obtain a delta between two revision numbers.
532
532
533 Operates on raw data in the store (``revision(node, raw=True)``).
533 Operates on raw data in the store (``revision(node, raw=True)``).
534
534
535 The returned data is the result of ``bdiff.bdiff`` on the raw
535 The returned data is the result of ``bdiff.bdiff`` on the raw
536 revision data.
536 revision data.
537 """
537 """
538
538
539 class ifilemutation(interfaceutil.Interface):
539 class ifilemutation(interfaceutil.Interface):
540 """Storage interface for mutation events of a tracked file."""
540 """Storage interface for mutation events of a tracked file."""
541
541
542 def add(filedata, meta, transaction, linkrev, p1, p2):
542 def add(filedata, meta, transaction, linkrev, p1, p2):
543 """Add a new revision to the store.
543 """Add a new revision to the store.
544
544
545 Takes file data, dictionary of metadata, a transaction, linkrev,
545 Takes file data, dictionary of metadata, a transaction, linkrev,
546 and parent nodes.
546 and parent nodes.
547
547
548 Returns the node that was added.
548 Returns the node that was added.
549
549
550 May no-op if a revision matching the supplied data is already stored.
550 May no-op if a revision matching the supplied data is already stored.
551 """
551 """
552
552
553 def addrevision(revisiondata, transaction, linkrev, p1, p2, node=None,
553 def addrevision(revisiondata, transaction, linkrev, p1, p2, node=None,
554 flags=0, cachedelta=None):
554 flags=0, cachedelta=None):
555 """Add a new revision to the store.
555 """Add a new revision to the store.
556
556
557 This is similar to ``add()`` except it operates at a lower level.
557 This is similar to ``add()`` except it operates at a lower level.
558
558
559 The data passed in already contains a metadata header, if any.
559 The data passed in already contains a metadata header, if any.
560
560
561 ``node`` and ``flags`` can be used to define the expected node and
561 ``node`` and ``flags`` can be used to define the expected node and
562 the flags to use with storage.
562 the flags to use with storage.
563
563
564 ``add()`` is usually called when adding files from e.g. the working
564 ``add()`` is usually called when adding files from e.g. the working
565 directory. ``addrevision()`` is often called by ``add()`` and for
565 directory. ``addrevision()`` is often called by ``add()`` and for
566 scenarios where revision data has already been computed, such as when
566 scenarios where revision data has already been computed, such as when
567 applying raw data from a peer repo.
567 applying raw data from a peer repo.
568 """
568 """
569
569
570 def addgroup(deltas, linkmapper, transaction, addrevisioncb=None):
570 def addgroup(deltas, linkmapper, transaction, addrevisioncb=None):
571 """Process a series of deltas for storage.
571 """Process a series of deltas for storage.
572
572
573 ``deltas`` is an iterable of 7-tuples of
573 ``deltas`` is an iterable of 7-tuples of
574 (node, p1, p2, linknode, deltabase, delta, flags) defining revisions
574 (node, p1, p2, linknode, deltabase, delta, flags) defining revisions
575 to add.
575 to add.
576
576
577 The ``delta`` field contains ``mpatch`` data to apply to a base
577 The ``delta`` field contains ``mpatch`` data to apply to a base
578 revision, identified by ``deltabase``. The base node can be
578 revision, identified by ``deltabase``. The base node can be
579 ``nullid``, in which case the header from the delta can be ignored
579 ``nullid``, in which case the header from the delta can be ignored
580 and the delta used as the fulltext.
580 and the delta used as the fulltext.
581
581
582 ``addrevisioncb`` should be called for each node as it is committed.
582 ``addrevisioncb`` should be called for each node as it is committed.
583
583
584 Returns a list of nodes that were processed. A node will be in the list
584 Returns a list of nodes that were processed. A node will be in the list
585 even if it existed in the store previously.
585 even if it existed in the store previously.
586 """
586 """
587
587
588 def getstrippoint(minlink):
588 def getstrippoint(minlink):
589 """Find the minimum revision that must be stripped to strip a linkrev.
589 """Find the minimum revision that must be stripped to strip a linkrev.
590
590
591 Returns a 2-tuple containing the minimum revision number and a set
591 Returns a 2-tuple containing the minimum revision number and a set
592 of all revisions numbers that would be broken by this strip.
592 of all revisions numbers that would be broken by this strip.
593
593
594 TODO this is highly revlog centric and should be abstracted into
594 TODO this is highly revlog centric and should be abstracted into
595 a higher-level deletion API. ``repair.strip()`` relies on this.
595 a higher-level deletion API. ``repair.strip()`` relies on this.
596 """
596 """
597
597
598 def strip(minlink, transaction):
598 def strip(minlink, transaction):
599 """Remove storage of items starting at a linkrev.
599 """Remove storage of items starting at a linkrev.
600
600
601 This uses ``getstrippoint()`` to determine the first node to remove.
601 This uses ``getstrippoint()`` to determine the first node to remove.
602 Then it effectively truncates storage for all revisions after that.
602 Then it effectively truncates storage for all revisions after that.
603
603
604 TODO this is highly revlog centric and should be abstracted into a
604 TODO this is highly revlog centric and should be abstracted into a
605 higher-level deletion API.
605 higher-level deletion API.
606 """
606 """
607
607
608 class ifilestorage(ifileindex, ifiledata, ifilemutation):
608 class ifilestorage(ifileindex, ifiledata, ifilemutation):
609 """Complete storage interface for a single tracked file."""
609 """Complete storage interface for a single tracked file."""
610
610
611 version = interfaceutil.Attribute(
611 version = interfaceutil.Attribute(
612 """Version number of storage.
612 """Version number of storage.
613
613
614 TODO this feels revlog centric and could likely be removed.
614 TODO this feels revlog centric and could likely be removed.
615 """)
615 """)
616
616
617 storedeltachains = interfaceutil.Attribute(
617 storedeltachains = interfaceutil.Attribute(
618 """Whether the store stores deltas.
618 """Whether the store stores deltas.
619
619
620 TODO deltachains are revlog centric. This can probably removed
620 TODO deltachains are revlog centric. This can probably removed
621 once there are better abstractions for obtaining/writing
621 once there are better abstractions for obtaining/writing
622 data.
622 data.
623 """)
623 """)
624
624
625 _generaldelta = interfaceutil.Attribute(
625 _generaldelta = interfaceutil.Attribute(
626 """Whether deltas can be against any parent revision.
626 """Whether deltas can be against any parent revision.
627
627
628 TODO this is used by changegroup code and it could probably be
628 TODO this is used by changegroup code and it could probably be
629 folded into another API.
629 folded into another API.
630 """)
630 """)
631
631
632 def files():
632 def files():
633 """Obtain paths that are backing storage for this file.
633 """Obtain paths that are backing storage for this file.
634
634
635 TODO this is used heavily by verify code and there should probably
635 TODO this is used heavily by verify code and there should probably
636 be a better API for that.
636 be a better API for that.
637 """
637 """
638
638
639 def checksize():
639 def checksize():
640 """Obtain the expected sizes of backing files.
640 """Obtain the expected sizes of backing files.
641
641
642 TODO this is used by verify and it should not be part of the interface.
642 TODO this is used by verify and it should not be part of the interface.
643 """
643 """
644
644
645 class completelocalrepository(interfaceutil.Interface):
645 class completelocalrepository(interfaceutil.Interface):
646 """Monolithic interface for local repositories.
646 """Monolithic interface for local repositories.
647
647
648 This currently captures the reality of things - not how things should be.
648 This currently captures the reality of things - not how things should be.
649 """
649 """
650
650
651 supportedformats = interfaceutil.Attribute(
651 supportedformats = interfaceutil.Attribute(
652 """Set of requirements that apply to stream clone.
652 """Set of requirements that apply to stream clone.
653
653
654 This is actually a class attribute and is shared among all instances.
654 This is actually a class attribute and is shared among all instances.
655 """)
655 """)
656
656
657 openerreqs = interfaceutil.Attribute(
657 openerreqs = interfaceutil.Attribute(
658 """Set of requirements that are passed to the opener.
658 """Set of requirements that are passed to the opener.
659
659
660 This is actually a class attribute and is shared among all instances.
660 This is actually a class attribute and is shared among all instances.
661 """)
661 """)
662
662
663 supported = interfaceutil.Attribute(
663 supported = interfaceutil.Attribute(
664 """Set of requirements that this repo is capable of opening.""")
664 """Set of requirements that this repo is capable of opening.""")
665
665
666 requirements = interfaceutil.Attribute(
666 requirements = interfaceutil.Attribute(
667 """Set of requirements this repo uses.""")
667 """Set of requirements this repo uses.""")
668
668
669 filtername = interfaceutil.Attribute(
669 filtername = interfaceutil.Attribute(
670 """Name of the repoview that is active on this repo.""")
670 """Name of the repoview that is active on this repo.""")
671
671
672 wvfs = interfaceutil.Attribute(
672 wvfs = interfaceutil.Attribute(
673 """VFS used to access the working directory.""")
673 """VFS used to access the working directory.""")
674
674
675 vfs = interfaceutil.Attribute(
675 vfs = interfaceutil.Attribute(
676 """VFS rooted at the .hg directory.
676 """VFS rooted at the .hg directory.
677
677
678 Used to access repository data not in the store.
678 Used to access repository data not in the store.
679 """)
679 """)
680
680
681 svfs = interfaceutil.Attribute(
681 svfs = interfaceutil.Attribute(
682 """VFS rooted at the store.
682 """VFS rooted at the store.
683
683
684 Used to access repository data in the store. Typically .hg/store.
684 Used to access repository data in the store. Typically .hg/store.
685 But can point elsewhere if the store is shared.
685 But can point elsewhere if the store is shared.
686 """)
686 """)
687
687
688 root = interfaceutil.Attribute(
688 root = interfaceutil.Attribute(
689 """Path to the root of the working directory.""")
689 """Path to the root of the working directory.""")
690
690
691 path = interfaceutil.Attribute(
691 path = interfaceutil.Attribute(
692 """Path to the .hg directory.""")
692 """Path to the .hg directory.""")
693
693
694 origroot = interfaceutil.Attribute(
694 origroot = interfaceutil.Attribute(
695 """The filesystem path that was used to construct the repo.""")
695 """The filesystem path that was used to construct the repo.""")
696
696
697 auditor = interfaceutil.Attribute(
697 auditor = interfaceutil.Attribute(
698 """A pathauditor for the working directory.
698 """A pathauditor for the working directory.
699
699
700 This checks if a path refers to a nested repository.
700 This checks if a path refers to a nested repository.
701
701
702 Operates on the filesystem.
702 Operates on the filesystem.
703 """)
703 """)
704
704
705 nofsauditor = interfaceutil.Attribute(
705 nofsauditor = interfaceutil.Attribute(
706 """A pathauditor for the working directory.
706 """A pathauditor for the working directory.
707
707
708 This is like ``auditor`` except it doesn't do filesystem checks.
708 This is like ``auditor`` except it doesn't do filesystem checks.
709 """)
709 """)
710
710
711 baseui = interfaceutil.Attribute(
711 baseui = interfaceutil.Attribute(
712 """Original ui instance passed into constructor.""")
712 """Original ui instance passed into constructor.""")
713
713
714 ui = interfaceutil.Attribute(
714 ui = interfaceutil.Attribute(
715 """Main ui instance for this instance.""")
715 """Main ui instance for this instance.""")
716
716
717 sharedpath = interfaceutil.Attribute(
717 sharedpath = interfaceutil.Attribute(
718 """Path to the .hg directory of the repo this repo was shared from.""")
718 """Path to the .hg directory of the repo this repo was shared from.""")
719
719
720 store = interfaceutil.Attribute(
720 store = interfaceutil.Attribute(
721 """A store instance.""")
721 """A store instance.""")
722
722
723 spath = interfaceutil.Attribute(
723 spath = interfaceutil.Attribute(
724 """Path to the store.""")
724 """Path to the store.""")
725
725
726 sjoin = interfaceutil.Attribute(
726 sjoin = interfaceutil.Attribute(
727 """Alias to self.store.join.""")
727 """Alias to self.store.join.""")
728
728
729 cachevfs = interfaceutil.Attribute(
729 cachevfs = interfaceutil.Attribute(
730 """A VFS used to access the cache directory.
730 """A VFS used to access the cache directory.
731
731
732 Typically .hg/cache.
732 Typically .hg/cache.
733 """)
733 """)
734
734
735 filteredrevcache = interfaceutil.Attribute(
735 filteredrevcache = interfaceutil.Attribute(
736 """Holds sets of revisions to be filtered.""")
736 """Holds sets of revisions to be filtered.""")
737
737
738 names = interfaceutil.Attribute(
738 names = interfaceutil.Attribute(
739 """A ``namespaces`` instance.""")
739 """A ``namespaces`` instance.""")
740
740
741 def close():
741 def close():
742 """Close the handle on this repository."""
742 """Close the handle on this repository."""
743
743
744 def peer():
744 def peer():
745 """Obtain an object conforming to the ``peer`` interface."""
745 """Obtain an object conforming to the ``peer`` interface."""
746
746
747 def unfiltered():
747 def unfiltered():
748 """Obtain an unfiltered/raw view of this repo."""
748 """Obtain an unfiltered/raw view of this repo."""
749
749
750 def filtered(name, visibilityexceptions=None):
750 def filtered(name, visibilityexceptions=None):
751 """Obtain a named view of this repository."""
751 """Obtain a named view of this repository."""
752
752
753 obsstore = interfaceutil.Attribute(
753 obsstore = interfaceutil.Attribute(
754 """A store of obsolescence data.""")
754 """A store of obsolescence data.""")
755
755
756 changelog = interfaceutil.Attribute(
756 changelog = interfaceutil.Attribute(
757 """A handle on the changelog revlog.""")
757 """A handle on the changelog revlog.""")
758
758
759 manifestlog = interfaceutil.Attribute(
759 manifestlog = interfaceutil.Attribute(
760 """A handle on the root manifest revlog.""")
760 """A handle on the root manifest revlog.""")
761
761
762 dirstate = interfaceutil.Attribute(
762 dirstate = interfaceutil.Attribute(
763 """Working directory state.""")
763 """Working directory state.""")
764
764
765 narrowpats = interfaceutil.Attribute(
765 narrowpats = interfaceutil.Attribute(
766 """Matcher patterns for this repository's narrowspec.""")
766 """Matcher patterns for this repository's narrowspec.""")
767
767
768 def narrowmatch():
768 def narrowmatch():
769 """Obtain a matcher for the narrowspec."""
769 """Obtain a matcher for the narrowspec."""
770
770
771 def setnarrowpats(newincludes, newexcludes):
771 def setnarrowpats(newincludes, newexcludes):
772 """Define the narrowspec for this repository."""
772 """Define the narrowspec for this repository."""
773
773
774 def __getitem__(changeid):
774 def __getitem__(changeid):
775 """Try to resolve a changectx."""
775 """Try to resolve a changectx."""
776
776
777 def __contains__(changeid):
777 def __contains__(changeid):
778 """Whether a changeset exists."""
778 """Whether a changeset exists."""
779
779
780 def __nonzero__():
780 def __nonzero__():
781 """Always returns True."""
781 """Always returns True."""
782 return True
782 return True
783
783
784 __bool__ = __nonzero__
784 __bool__ = __nonzero__
785
785
786 def __len__():
786 def __len__():
787 """Returns the number of changesets in the repo."""
787 """Returns the number of changesets in the repo."""
788
788
789 def __iter__():
789 def __iter__():
790 """Iterate over revisions in the changelog."""
790 """Iterate over revisions in the changelog."""
791
791
792 def revs(expr, *args):
792 def revs(expr, *args):
793 """Evaluate a revset.
793 """Evaluate a revset.
794
794
795 Emits revisions.
795 Emits revisions.
796 """
796 """
797
797
798 def set(expr, *args):
798 def set(expr, *args):
799 """Evaluate a revset.
799 """Evaluate a revset.
800
800
801 Emits changectx instances.
801 Emits changectx instances.
802 """
802 """
803
803
804 def anyrevs(specs, user=False, localalias=None):
804 def anyrevs(specs, user=False, localalias=None):
805 """Find revisions matching one of the given revsets."""
805 """Find revisions matching one of the given revsets."""
806
806
807 def url():
807 def url():
808 """Returns a string representing the location of this repo."""
808 """Returns a string representing the location of this repo."""
809
809
810 def hook(name, throw=False, **args):
810 def hook(name, throw=False, **args):
811 """Call a hook."""
811 """Call a hook."""
812
812
813 def tags():
813 def tags():
814 """Return a mapping of tag to node."""
814 """Return a mapping of tag to node."""
815
815
816 def tagtype(tagname):
816 def tagtype(tagname):
817 """Return the type of a given tag."""
817 """Return the type of a given tag."""
818
818
819 def tagslist():
819 def tagslist():
820 """Return a list of tags ordered by revision."""
820 """Return a list of tags ordered by revision."""
821
821
822 def nodetags(node):
822 def nodetags(node):
823 """Return the tags associated with a node."""
823 """Return the tags associated with a node."""
824
824
825 def nodebookmarks(node):
825 def nodebookmarks(node):
826 """Return the list of bookmarks pointing to the specified node."""
826 """Return the list of bookmarks pointing to the specified node."""
827
827
828 def branchmap():
828 def branchmap():
829 """Return a mapping of branch to heads in that branch."""
829 """Return a mapping of branch to heads in that branch."""
830
830
831 def revbranchcache():
831 def revbranchcache():
832 pass
832 pass
833
833
834 def branchtip(branchtip, ignoremissing=False):
834 def branchtip(branchtip, ignoremissing=False):
835 """Return the tip node for a given branch."""
835 """Return the tip node for a given branch."""
836
836
837 def lookup(key):
837 def lookup(key):
838 """Resolve the node for a revision."""
838 """Resolve the node for a revision."""
839
839
840 def lookupbranch(key):
840 def lookupbranch(key):
841 """Look up the branch name of the given revision or branch name."""
841 """Look up the branch name of the given revision or branch name."""
842
842
843 def known(nodes):
843 def known(nodes):
844 """Determine whether a series of nodes is known.
844 """Determine whether a series of nodes is known.
845
845
846 Returns a list of bools.
846 Returns a list of bools.
847 """
847 """
848
848
849 def local():
849 def local():
850 """Whether the repository is local."""
850 """Whether the repository is local."""
851 return True
851 return True
852
852
853 def publishing():
853 def publishing():
854 """Whether the repository is a publishing repository."""
854 """Whether the repository is a publishing repository."""
855
855
856 def cancopy():
856 def cancopy():
857 pass
857 pass
858
858
859 def shared():
859 def shared():
860 """The type of shared repository or None."""
860 """The type of shared repository or None."""
861
861
862 def wjoin(f, *insidef):
862 def wjoin(f, *insidef):
863 """Calls self.vfs.reljoin(self.root, f, *insidef)"""
863 """Calls self.vfs.reljoin(self.root, f, *insidef)"""
864
864
865 def file(f):
865 def file(f):
866 """Obtain a filelog for a tracked path."""
866 """Obtain a filelog for a tracked path.
867
868 The returned type conforms to the ``ifilestorage`` interface.
869 """
867
870
868 def setparents(p1, p2):
871 def setparents(p1, p2):
869 """Set the parent nodes of the working directory."""
872 """Set the parent nodes of the working directory."""
870
873
871 def filectx(path, changeid=None, fileid=None):
874 def filectx(path, changeid=None, fileid=None):
872 """Obtain a filectx for the given file revision."""
875 """Obtain a filectx for the given file revision."""
873
876
874 def getcwd():
877 def getcwd():
875 """Obtain the current working directory from the dirstate."""
878 """Obtain the current working directory from the dirstate."""
876
879
877 def pathto(f, cwd=None):
880 def pathto(f, cwd=None):
878 """Obtain the relative path to a file."""
881 """Obtain the relative path to a file."""
879
882
880 def adddatafilter(name, fltr):
883 def adddatafilter(name, fltr):
881 pass
884 pass
882
885
883 def wread(filename):
886 def wread(filename):
884 """Read a file from wvfs, using data filters."""
887 """Read a file from wvfs, using data filters."""
885
888
886 def wwrite(filename, data, flags, backgroundclose=False, **kwargs):
889 def wwrite(filename, data, flags, backgroundclose=False, **kwargs):
887 """Write data to a file in the wvfs, using data filters."""
890 """Write data to a file in the wvfs, using data filters."""
888
891
889 def wwritedata(filename, data):
892 def wwritedata(filename, data):
890 """Resolve data for writing to the wvfs, using data filters."""
893 """Resolve data for writing to the wvfs, using data filters."""
891
894
892 def currenttransaction():
895 def currenttransaction():
893 """Obtain the current transaction instance or None."""
896 """Obtain the current transaction instance or None."""
894
897
895 def transaction(desc, report=None):
898 def transaction(desc, report=None):
896 """Open a new transaction to write to the repository."""
899 """Open a new transaction to write to the repository."""
897
900
898 def undofiles():
901 def undofiles():
899 """Returns a list of (vfs, path) for files to undo transactions."""
902 """Returns a list of (vfs, path) for files to undo transactions."""
900
903
901 def recover():
904 def recover():
902 """Roll back an interrupted transaction."""
905 """Roll back an interrupted transaction."""
903
906
904 def rollback(dryrun=False, force=False):
907 def rollback(dryrun=False, force=False):
905 """Undo the last transaction.
908 """Undo the last transaction.
906
909
907 DANGEROUS.
910 DANGEROUS.
908 """
911 """
909
912
910 def updatecaches(tr=None, full=False):
913 def updatecaches(tr=None, full=False):
911 """Warm repo caches."""
914 """Warm repo caches."""
912
915
913 def invalidatecaches():
916 def invalidatecaches():
914 """Invalidate cached data due to the repository mutating."""
917 """Invalidate cached data due to the repository mutating."""
915
918
916 def invalidatevolatilesets():
919 def invalidatevolatilesets():
917 pass
920 pass
918
921
919 def invalidatedirstate():
922 def invalidatedirstate():
920 """Invalidate the dirstate."""
923 """Invalidate the dirstate."""
921
924
922 def invalidate(clearfilecache=False):
925 def invalidate(clearfilecache=False):
923 pass
926 pass
924
927
925 def invalidateall():
928 def invalidateall():
926 pass
929 pass
927
930
928 def lock(wait=True):
931 def lock(wait=True):
929 """Lock the repository store and return a lock instance."""
932 """Lock the repository store and return a lock instance."""
930
933
931 def wlock(wait=True):
934 def wlock(wait=True):
932 """Lock the non-store parts of the repository."""
935 """Lock the non-store parts of the repository."""
933
936
934 def currentwlock():
937 def currentwlock():
935 """Return the wlock if it's held or None."""
938 """Return the wlock if it's held or None."""
936
939
937 def checkcommitpatterns(wctx, vdirs, match, status, fail):
940 def checkcommitpatterns(wctx, vdirs, match, status, fail):
938 pass
941 pass
939
942
940 def commit(text='', user=None, date=None, match=None, force=False,
943 def commit(text='', user=None, date=None, match=None, force=False,
941 editor=False, extra=None):
944 editor=False, extra=None):
942 """Add a new revision to the repository."""
945 """Add a new revision to the repository."""
943
946
944 def commitctx(ctx, error=False):
947 def commitctx(ctx, error=False):
945 """Commit a commitctx instance to the repository."""
948 """Commit a commitctx instance to the repository."""
946
949
947 def destroying():
950 def destroying():
948 """Inform the repository that nodes are about to be destroyed."""
951 """Inform the repository that nodes are about to be destroyed."""
949
952
950 def destroyed():
953 def destroyed():
951 """Inform the repository that nodes have been destroyed."""
954 """Inform the repository that nodes have been destroyed."""
952
955
953 def status(node1='.', node2=None, match=None, ignored=False,
956 def status(node1='.', node2=None, match=None, ignored=False,
954 clean=False, unknown=False, listsubrepos=False):
957 clean=False, unknown=False, listsubrepos=False):
955 """Convenience method to call repo[x].status()."""
958 """Convenience method to call repo[x].status()."""
956
959
957 def addpostdsstatus(ps):
960 def addpostdsstatus(ps):
958 pass
961 pass
959
962
960 def postdsstatus():
963 def postdsstatus():
961 pass
964 pass
962
965
963 def clearpostdsstatus():
966 def clearpostdsstatus():
964 pass
967 pass
965
968
966 def heads(start=None):
969 def heads(start=None):
967 """Obtain list of nodes that are DAG heads."""
970 """Obtain list of nodes that are DAG heads."""
968
971
969 def branchheads(branch=None, start=None, closed=False):
972 def branchheads(branch=None, start=None, closed=False):
970 pass
973 pass
971
974
972 def branches(nodes):
975 def branches(nodes):
973 pass
976 pass
974
977
975 def between(pairs):
978 def between(pairs):
976 pass
979 pass
977
980
978 def checkpush(pushop):
981 def checkpush(pushop):
979 pass
982 pass
980
983
981 prepushoutgoinghooks = interfaceutil.Attribute(
984 prepushoutgoinghooks = interfaceutil.Attribute(
982 """util.hooks instance.""")
985 """util.hooks instance.""")
983
986
984 def pushkey(namespace, key, old, new):
987 def pushkey(namespace, key, old, new):
985 pass
988 pass
986
989
987 def listkeys(namespace):
990 def listkeys(namespace):
988 pass
991 pass
989
992
990 def debugwireargs(one, two, three=None, four=None, five=None):
993 def debugwireargs(one, two, three=None, four=None, five=None):
991 pass
994 pass
992
995
993 def savecommitmessage(text):
996 def savecommitmessage(text):
994 pass
997 pass
General Comments 0
You need to be logged in to leave comments. Login now