##// END OF EJS Templates
internals: document compression negotiation...
Gregory Szorc -
r30760:753b9d43 default
parent child Browse files
Show More
@@ -1,773 +1,907
1 The Mercurial wire protocol is a request-response based protocol
1 The Mercurial wire protocol is a request-response based protocol
2 with multiple wire representations.
2 with multiple wire representations.
3
3
4 Each request is modeled as a command name, a dictionary of arguments, and
4 Each request is modeled as a command name, a dictionary of arguments, and
5 optional raw input. Command arguments and their types are intrinsic
5 optional raw input. Command arguments and their types are intrinsic
6 properties of commands. So is the response type of the command. This means
6 properties of commands. So is the response type of the command. This means
7 clients can't always send arbitrary arguments to servers and servers can't
7 clients can't always send arbitrary arguments to servers and servers can't
8 return multiple response types.
8 return multiple response types.
9
9
10 The protocol is synchronous and does not support multiplexing (concurrent
10 The protocol is synchronous and does not support multiplexing (concurrent
11 commands).
11 commands).
12
12
13 Transport Protocols
13 Transport Protocols
14 ===================
14 ===================
15
15
16 HTTP Transport
16 HTTP Transport
17 --------------
17 --------------
18
18
19 Commands are issued as HTTP/1.0 or HTTP/1.1 requests. Commands are
19 Commands are issued as HTTP/1.0 or HTTP/1.1 requests. Commands are
20 sent to the base URL of the repository with the command name sent in
20 sent to the base URL of the repository with the command name sent in
21 the ``cmd`` query string parameter. e.g.
21 the ``cmd`` query string parameter. e.g.
22 ``https://example.com/repo?cmd=capabilities``. The HTTP method is ``GET``
22 ``https://example.com/repo?cmd=capabilities``. The HTTP method is ``GET``
23 or ``POST`` depending on the command and whether there is a request
23 or ``POST`` depending on the command and whether there is a request
24 body.
24 body.
25
25
26 Command arguments can be sent multiple ways.
26 Command arguments can be sent multiple ways.
27
27
28 The simplest is part of the URL query string using ``x-www-form-urlencoded``
28 The simplest is part of the URL query string using ``x-www-form-urlencoded``
29 encoding (see Python's ``urllib.urlencode()``. However, many servers impose
29 encoding (see Python's ``urllib.urlencode()``. However, many servers impose
30 length limitations on the URL. So this mechanism is typically only used if
30 length limitations on the URL. So this mechanism is typically only used if
31 the server doesn't support other mechanisms.
31 the server doesn't support other mechanisms.
32
32
33 If the server supports the ``httpheader`` capability, command arguments can
33 If the server supports the ``httpheader`` capability, command arguments can
34 be sent in HTTP request headers named ``X-HgArg-<N>`` where ``<N>`` is an
34 be sent in HTTP request headers named ``X-HgArg-<N>`` where ``<N>`` is an
35 integer starting at 1. A ``x-www-form-urlencoded`` representation of the
35 integer starting at 1. A ``x-www-form-urlencoded`` representation of the
36 arguments is obtained. This full string is then split into chunks and sent
36 arguments is obtained. This full string is then split into chunks and sent
37 in numbered ``X-HgArg-<N>`` headers. The maximum length of each HTTP header
37 in numbered ``X-HgArg-<N>`` headers. The maximum length of each HTTP header
38 is defined by the server in the ``httpheader`` capability value, which defaults
38 is defined by the server in the ``httpheader`` capability value, which defaults
39 to ``1024``. The server reassembles the encoded arguments string by
39 to ``1024``. The server reassembles the encoded arguments string by
40 concatenating the ``X-HgArg-<N>`` headers then URL decodes them into a
40 concatenating the ``X-HgArg-<N>`` headers then URL decodes them into a
41 dictionary.
41 dictionary.
42
42
43 The list of ``X-HgArg-<N>`` headers should be added to the ``Vary`` request
43 The list of ``X-HgArg-<N>`` headers should be added to the ``Vary`` request
44 header to instruct caches to take these headers into consideration when caching
44 header to instruct caches to take these headers into consideration when caching
45 requests.
45 requests.
46
46
47 If the server supports the ``httppostargs`` capability, the client
47 If the server supports the ``httppostargs`` capability, the client
48 may send command arguments in the HTTP request body as part of an
48 may send command arguments in the HTTP request body as part of an
49 HTTP POST request. The command arguments will be URL encoded just like
49 HTTP POST request. The command arguments will be URL encoded just like
50 they would for sending them via HTTP headers. However, no splitting is
50 they would for sending them via HTTP headers. However, no splitting is
51 performed: the raw arguments are included in the HTTP request body.
51 performed: the raw arguments are included in the HTTP request body.
52
52
53 The client sends a ``X-HgArgs-Post`` header with the string length of the
53 The client sends a ``X-HgArgs-Post`` header with the string length of the
54 encoded arguments data. Additional data may be included in the HTTP
54 encoded arguments data. Additional data may be included in the HTTP
55 request body immediately following the argument data. The offset of the
55 request body immediately following the argument data. The offset of the
56 non-argument data is defined by the ``X-HgArgs-Post`` header. The
56 non-argument data is defined by the ``X-HgArgs-Post`` header. The
57 ``X-HgArgs-Post`` header is not required if there is no argument data.
57 ``X-HgArgs-Post`` header is not required if there is no argument data.
58
58
59 Additional command data can be sent as part of the HTTP request body. The
59 Additional command data can be sent as part of the HTTP request body. The
60 default ``Content-Type`` when sending data is ``application/mercurial-0.1``.
60 default ``Content-Type`` when sending data is ``application/mercurial-0.1``.
61 A ``Content-Length`` header is currently always sent.
61 A ``Content-Length`` header is currently always sent.
62
62
63 Example HTTP requests::
63 Example HTTP requests::
64
64
65 GET /repo?cmd=capabilities
65 GET /repo?cmd=capabilities
66 X-HgArg-1: foo=bar&baz=hello%20world
66 X-HgArg-1: foo=bar&baz=hello%20world
67
67
68 The request media type should be chosen based on server support. If the
69 ``httpmediatype`` server capability is present, the client should send
70 the newest mutually supported media type. If this capability is absent,
71 the client must assume the server only supports the
72 ``application/mercurial-0.1`` media type.
73
68 The ``Content-Type`` HTTP response header identifies the response as coming
74 The ``Content-Type`` HTTP response header identifies the response as coming
69 from Mercurial and can also be used to signal an error has occurred.
75 from Mercurial and can also be used to signal an error has occurred.
70
76
71 The ``application/mercurial-0.1`` media type indicates a generic Mercurial
77 The ``application/mercurial-*`` media types indicate a generic Mercurial
72 response. It matches the media type sent by the client.
78 data type.
79
80 The ``application/mercurial-0.1`` media type is raw Mercurial data. It is the
81 predecessor of the format below.
82
83 The ``application/mercurial-0.2`` media type is compression framed Mercurial
84 data. The first byte of the payload indicates the length of the compression
85 format identifier that follows. Next are N bytes indicating the compression
86 format. e.g. ``zlib``. The remaining bytes are compressed according to that
87 compression format. The decompressed data behaves the same as with
88 ``application/mercurial-0.1``.
73
89
74 The ``application/hg-error`` media type indicates a generic error occurred.
90 The ``application/hg-error`` media type indicates a generic error occurred.
75 The content of the HTTP response body typically holds text describing the
91 The content of the HTTP response body typically holds text describing the
76 error.
92 error.
77
93
78 The ``application/hg-changegroup`` media type indicates a changegroup response
94 The ``application/hg-changegroup`` media type indicates a changegroup response
79 type.
95 type.
80
96
81 Clients also accept the ``text/plain`` media type. All other media
97 Clients also accept the ``text/plain`` media type. All other media
82 types should cause the client to error.
98 types should cause the client to error.
83
99
100 Behavior of media types is further described in the ``Content Negotiation``
101 section below.
102
84 Clients should issue a ``User-Agent`` request header that identifies the client.
103 Clients should issue a ``User-Agent`` request header that identifies the client.
85 The server should not use the ``User-Agent`` for feature detection.
104 The server should not use the ``User-Agent`` for feature detection.
86
105
87 A command returning a ``string`` response issues the
106 A command returning a ``string`` response issues a
88 ``application/mercurial-0.1`` media type and the HTTP response body contains
107 ``application/mercurial-0.*`` media type and the HTTP response body contains
89 the raw string value. A ``Content-Length`` header is typically issued.
108 the raw string value (after compression decoding, if used). A
109 ``Content-Length`` header is typically issued, but not required.
90
110
91 A command returning a ``stream`` response issues the
111 A command returning a ``stream`` response issues a
92 ``application/mercurial-0.1`` media type and the HTTP response is typically
112 ``application/mercurial-0.*`` media type and the HTTP response is typically
93 using *chunked transfer* (``Transfer-Encoding: chunked``).
113 using *chunked transfer* (``Transfer-Encoding: chunked``).
94
114
95 SSH Transport
115 SSH Transport
96 =============
116 =============
97
117
98 The SSH transport is a custom text-based protocol suitable for use over any
118 The SSH transport is a custom text-based protocol suitable for use over any
99 bi-directional stream transport. It is most commonly used with SSH.
119 bi-directional stream transport. It is most commonly used with SSH.
100
120
101 A SSH transport server can be started with ``hg serve --stdio``. The stdin,
121 A SSH transport server can be started with ``hg serve --stdio``. The stdin,
102 stderr, and stdout file descriptors of the started process are used to exchange
122 stderr, and stdout file descriptors of the started process are used to exchange
103 data. When Mercurial connects to a remote server over SSH, it actually starts
123 data. When Mercurial connects to a remote server over SSH, it actually starts
104 a ``hg serve --stdio`` process on the remote server.
124 a ``hg serve --stdio`` process on the remote server.
105
125
106 Commands are issued by sending the command name followed by a trailing newline
126 Commands are issued by sending the command name followed by a trailing newline
107 ``\n`` to the server. e.g. ``capabilities\n``.
127 ``\n`` to the server. e.g. ``capabilities\n``.
108
128
109 Command arguments are sent in the following format::
129 Command arguments are sent in the following format::
110
130
111 <argument> <length>\n<value>
131 <argument> <length>\n<value>
112
132
113 That is, the argument string name followed by a space followed by the
133 That is, the argument string name followed by a space followed by the
114 integer length of the value (expressed as a string) followed by a newline
134 integer length of the value (expressed as a string) followed by a newline
115 (``\n``) followed by the raw argument value.
135 (``\n``) followed by the raw argument value.
116
136
117 Dictionary arguments are encoded differently::
137 Dictionary arguments are encoded differently::
118
138
119 <argument> <# elements>\n
139 <argument> <# elements>\n
120 <key1> <length1>\n<value1>
140 <key1> <length1>\n<value1>
121 <key2> <length2>\n<value2>
141 <key2> <length2>\n<value2>
122 ...
142 ...
123
143
124 Non-argument data is sent immediately after the final argument value. It is
144 Non-argument data is sent immediately after the final argument value. It is
125 encoded in chunks::
145 encoded in chunks::
126
146
127 <length>\n<data>
147 <length>\n<data>
128
148
129 Each command declares a list of supported arguments and their types. If a
149 Each command declares a list of supported arguments and their types. If a
130 client sends an unknown argument to the server, the server should abort
150 client sends an unknown argument to the server, the server should abort
131 immediately. The special argument ``*`` in a command's definition indicates
151 immediately. The special argument ``*`` in a command's definition indicates
132 that all argument names are allowed.
152 that all argument names are allowed.
133
153
134 The definition of supported arguments and types is initially made when a
154 The definition of supported arguments and types is initially made when a
135 new command is implemented. The client and server must initially independently
155 new command is implemented. The client and server must initially independently
136 agree on the arguments and their types. This initial set of arguments can be
156 agree on the arguments and their types. This initial set of arguments can be
137 supplemented through the presence of *capabilities* advertised by the server.
157 supplemented through the presence of *capabilities* advertised by the server.
138
158
139 Each command has a defined expected response type.
159 Each command has a defined expected response type.
140
160
141 A ``string`` response type is a length framed value. The response consists of
161 A ``string`` response type is a length framed value. The response consists of
142 the string encoded integer length of a value followed by a newline (``\n``)
162 the string encoded integer length of a value followed by a newline (``\n``)
143 followed by the value. Empty values are allowed (and are represented as
163 followed by the value. Empty values are allowed (and are represented as
144 ``0\n``).
164 ``0\n``).
145
165
146 A ``stream`` response type consists of raw bytes of data. There is no framing.
166 A ``stream`` response type consists of raw bytes of data. There is no framing.
147
167
148 A generic error response type is also supported. It consists of a an error
168 A generic error response type is also supported. It consists of a an error
149 message written to ``stderr`` followed by ``\n-\n``. In addition, ``\n`` is
169 message written to ``stderr`` followed by ``\n-\n``. In addition, ``\n`` is
150 written to ``stdout``.
170 written to ``stdout``.
151
171
152 If the server receives an unknown command, it will send an empty ``string``
172 If the server receives an unknown command, it will send an empty ``string``
153 response.
173 response.
154
174
155 The server terminates if it receives an empty command (a ``\n`` character).
175 The server terminates if it receives an empty command (a ``\n`` character).
156
176
157 Capabilities
177 Capabilities
158 ============
178 ============
159
179
160 Servers advertise supported wire protocol features. This allows clients to
180 Servers advertise supported wire protocol features. This allows clients to
161 probe for server features before blindly calling a command or passing a
181 probe for server features before blindly calling a command or passing a
162 specific argument.
182 specific argument.
163
183
164 The server's features are exposed via a *capabilities* string. This is a
184 The server's features are exposed via a *capabilities* string. This is a
165 space-delimited string of tokens/features. Some features are single words
185 space-delimited string of tokens/features. Some features are single words
166 like ``lookup`` or ``batch``. Others are complicated key-value pairs
186 like ``lookup`` or ``batch``. Others are complicated key-value pairs
167 advertising sub-features. e.g. ``httpheader=2048``. When complex, non-word
187 advertising sub-features. e.g. ``httpheader=2048``. When complex, non-word
168 values are used, each feature name can define its own encoding of sub-values.
188 values are used, each feature name can define its own encoding of sub-values.
169 Comma-delimited and ``x-www-form-urlencoded`` values are common.
189 Comma-delimited and ``x-www-form-urlencoded`` values are common.
170
190
171 The following document capabilities defined by the canonical Mercurial server
191 The following document capabilities defined by the canonical Mercurial server
172 implementation.
192 implementation.
173
193
174 batch
194 batch
175 -----
195 -----
176
196
177 Whether the server supports the ``batch`` command.
197 Whether the server supports the ``batch`` command.
178
198
179 This capability/command was introduced in Mercurial 1.9 (released July 2011).
199 This capability/command was introduced in Mercurial 1.9 (released July 2011).
180
200
181 branchmap
201 branchmap
182 ---------
202 ---------
183
203
184 Whether the server supports the ``branchmap`` command.
204 Whether the server supports the ``branchmap`` command.
185
205
186 This capability/command was introduced in Mercurial 1.3 (released July 2009).
206 This capability/command was introduced in Mercurial 1.3 (released July 2009).
187
207
188 bundle2-exp
208 bundle2-exp
189 -----------
209 -----------
190
210
191 Precursor to ``bundle2`` capability that was used before bundle2 was a
211 Precursor to ``bundle2`` capability that was used before bundle2 was a
192 stable feature.
212 stable feature.
193
213
194 This capability was introduced in Mercurial 3.0 behind an experimental
214 This capability was introduced in Mercurial 3.0 behind an experimental
195 flag. This capability should not be observed in the wild.
215 flag. This capability should not be observed in the wild.
196
216
197 bundle2
217 bundle2
198 -------
218 -------
199
219
200 Indicates whether the server supports the ``bundle2`` data exchange format.
220 Indicates whether the server supports the ``bundle2`` data exchange format.
201
221
202 The value of the capability is a URL quoted, newline (``\n``) delimited
222 The value of the capability is a URL quoted, newline (``\n``) delimited
203 list of keys or key-value pairs.
223 list of keys or key-value pairs.
204
224
205 A key is simply a URL encoded string.
225 A key is simply a URL encoded string.
206
226
207 A key-value pair is a URL encoded key separated from a URL encoded value by
227 A key-value pair is a URL encoded key separated from a URL encoded value by
208 an ``=``. If the value is a list, elements are delimited by a ``,`` after
228 an ``=``. If the value is a list, elements are delimited by a ``,`` after
209 URL encoding.
229 URL encoding.
210
230
211 For example, say we have the values::
231 For example, say we have the values::
212
232
213 {'HG20': [], 'changegroup': ['01', '02'], 'digests': ['sha1', 'sha512']}
233 {'HG20': [], 'changegroup': ['01', '02'], 'digests': ['sha1', 'sha512']}
214
234
215 We would first construct a string::
235 We would first construct a string::
216
236
217 HG20\nchangegroup=01,02\ndigests=sha1,sha512
237 HG20\nchangegroup=01,02\ndigests=sha1,sha512
218
238
219 We would then URL quote this string::
239 We would then URL quote this string::
220
240
221 HG20%0Achangegroup%3D01%2C02%0Adigests%3Dsha1%2Csha512
241 HG20%0Achangegroup%3D01%2C02%0Adigests%3Dsha1%2Csha512
222
242
223 This capability was introduced in Mercurial 3.4 (released May 2015).
243 This capability was introduced in Mercurial 3.4 (released May 2015).
224
244
225 changegroupsubset
245 changegroupsubset
226 -----------------
246 -----------------
227
247
228 Whether the server supports the ``changegroupsubset`` command.
248 Whether the server supports the ``changegroupsubset`` command.
229
249
230 This capability was introduced in Mercurial 0.9.2 (released December
250 This capability was introduced in Mercurial 0.9.2 (released December
231 2006).
251 2006).
232
252
233 This capability was introduced at the same time as the ``lookup``
253 This capability was introduced at the same time as the ``lookup``
234 capability/command.
254 capability/command.
235
255
256 compression
257 -----------
258
259 Declares support for negotiating compression formats.
260
261 Presence of this capability indicates the server supports dynamic selection
262 of compression formats based on the client request.
263
264 Servers advertising this capability are required to support the
265 ``application/mercurial-0.2`` media type in response to commands returning
266 streams. Servers may support this media type on any command.
267
268 The value of the capability is a comma-delimited list of strings declaring
269 supported compression formats. The order of the compression formats is in
270 server-preferred order, most preferred first.
271
272 This capability was introduced in Mercurial 4.1 (released February 2017).
273
236 getbundle
274 getbundle
237 ---------
275 ---------
238
276
239 Whether the server supports the ``getbundle`` command.
277 Whether the server supports the ``getbundle`` command.
240
278
241 This capability was introduced in Mercurial 1.9 (released July 2011).
279 This capability was introduced in Mercurial 1.9 (released July 2011).
242
280
243 httpheader
281 httpheader
244 ----------
282 ----------
245
283
246 Whether the server supports receiving command arguments via HTTP request
284 Whether the server supports receiving command arguments via HTTP request
247 headers.
285 headers.
248
286
249 The value of the capability is an integer describing the max header
287 The value of the capability is an integer describing the max header
250 length that clients should send. Clients should ignore any content after a
288 length that clients should send. Clients should ignore any content after a
251 comma in the value, as this is reserved for future use.
289 comma in the value, as this is reserved for future use.
252
290
253 This capability was introduced in Mercurial 1.9 (released July 2011).
291 This capability was introduced in Mercurial 1.9 (released July 2011).
254
292
293 httpmediatype
294 -------------
295
296 Indicates which HTTP media types (``Content-Type`` header) the server is
297 capable of receiving and sending.
298
299 The value of the capability is a comma-delimited list of strings identifying
300 support for media type and transmission direction. The following strings may
301 be present:
302
303 0.1rx
304 Indicates server support for receiving ``application/mercurial-0.1`` media
305 types.
306
307 0.1tx
308 Indicates server support for sending ``application/mercurial-0.1`` media
309 types.
310
311 0.2rx
312 Indicates server support for receiving ``application/mercurial-0.2`` media
313 types.
314
315 0.2tx
316 Indicates server support for sending ``application/mercurial-0.2`` media
317 types.
318
319 minrx=X
320 Minimum media type version the server is capable of receiving. Value is a
321 string like ``0.2``.
322
323 This capability can be used by servers to limit connections from legacy
324 clients not using the latest supported media type. However, only clients
325 with knowledge of this capability will know to consult this value. This
326 capability is present so the client may issue a more user-friendly error
327 when the server has locked out a legacy client.
328
329 mintx=X
330 Minimum media type version the server is capable of sending. Value is a
331 string like ``0.1``.
332
333 Servers advertising support for the ``application/mercurial-0.2`` media type
334 should also advertise the ``compression`` capability.
335
336 This capability was introduced in Mercurial 4.1 (released February 2017).
337
255 httppostargs
338 httppostargs
256 ------------
339 ------------
257
340
258 **Experimental**
341 **Experimental**
259
342
260 Indicates that the server supports and prefers clients send command arguments
343 Indicates that the server supports and prefers clients send command arguments
261 via a HTTP POST request as part of the request body.
344 via a HTTP POST request as part of the request body.
262
345
263 This capability was introduced in Mercurial 3.8 (released May 2016).
346 This capability was introduced in Mercurial 3.8 (released May 2016).
264
347
265 known
348 known
266 -----
349 -----
267
350
268 Whether the server supports the ``known`` command.
351 Whether the server supports the ``known`` command.
269
352
270 This capability/command was introduced in Mercurial 1.9 (released July 2011).
353 This capability/command was introduced in Mercurial 1.9 (released July 2011).
271
354
272 lookup
355 lookup
273 ------
356 ------
274
357
275 Whether the server supports the ``lookup`` command.
358 Whether the server supports the ``lookup`` command.
276
359
277 This capability was introduced in Mercurial 0.9.2 (released December
360 This capability was introduced in Mercurial 0.9.2 (released December
278 2006).
361 2006).
279
362
280 This capability was introduced at the same time as the ``changegroupsubset``
363 This capability was introduced at the same time as the ``changegroupsubset``
281 capability/command.
364 capability/command.
282
365
283 pushkey
366 pushkey
284 -------
367 -------
285
368
286 Whether the server supports the ``pushkey`` and ``listkeys`` commands.
369 Whether the server supports the ``pushkey`` and ``listkeys`` commands.
287
370
288 This capability was introduced in Mercurial 1.6 (released July 2010).
371 This capability was introduced in Mercurial 1.6 (released July 2010).
289
372
290 standardbundle
373 standardbundle
291 --------------
374 --------------
292
375
293 **Unsupported**
376 **Unsupported**
294
377
295 This capability was introduced during the Mercurial 0.9.2 development cycle in
378 This capability was introduced during the Mercurial 0.9.2 development cycle in
296 2006. It was never present in a release, as it was replaced by the ``unbundle``
379 2006. It was never present in a release, as it was replaced by the ``unbundle``
297 capability. This capability should not be encountered in the wild.
380 capability. This capability should not be encountered in the wild.
298
381
299 stream-preferred
382 stream-preferred
300 ----------------
383 ----------------
301
384
302 If present the server prefers that clients clone using the streaming clone
385 If present the server prefers that clients clone using the streaming clone
303 protocol (``hg clone --uncompressed``) rather than the standard
386 protocol (``hg clone --uncompressed``) rather than the standard
304 changegroup/bundle based protocol.
387 changegroup/bundle based protocol.
305
388
306 This capability was introduced in Mercurial 2.2 (released May 2012).
389 This capability was introduced in Mercurial 2.2 (released May 2012).
307
390
308 streamreqs
391 streamreqs
309 ----------
392 ----------
310
393
311 Indicates whether the server supports *streaming clones* and the *requirements*
394 Indicates whether the server supports *streaming clones* and the *requirements*
312 that clients must support to receive it.
395 that clients must support to receive it.
313
396
314 If present, the server supports the ``stream_out`` command, which transmits
397 If present, the server supports the ``stream_out`` command, which transmits
315 raw revlogs from the repository instead of changegroups. This provides a faster
398 raw revlogs from the repository instead of changegroups. This provides a faster
316 cloning mechanism at the expense of more bandwidth used.
399 cloning mechanism at the expense of more bandwidth used.
317
400
318 The value of this capability is a comma-delimited list of repo format
401 The value of this capability is a comma-delimited list of repo format
319 *requirements*. These are requirements that impact the reading of data in
402 *requirements*. These are requirements that impact the reading of data in
320 the ``.hg/store`` directory. An example value is
403 the ``.hg/store`` directory. An example value is
321 ``streamreqs=generaldelta,revlogv1`` indicating the server repo requires
404 ``streamreqs=generaldelta,revlogv1`` indicating the server repo requires
322 the ``revlogv1`` and ``generaldelta`` requirements.
405 the ``revlogv1`` and ``generaldelta`` requirements.
323
406
324 If the only format requirement is ``revlogv1``, the server may expose the
407 If the only format requirement is ``revlogv1``, the server may expose the
325 ``stream`` capability instead of the ``streamreqs`` capability.
408 ``stream`` capability instead of the ``streamreqs`` capability.
326
409
327 This capability was introduced in Mercurial 1.7 (released November 2010).
410 This capability was introduced in Mercurial 1.7 (released November 2010).
328
411
329 stream
412 stream
330 ------
413 ------
331
414
332 Whether the server supports *streaming clones* from ``revlogv1`` repos.
415 Whether the server supports *streaming clones* from ``revlogv1`` repos.
333
416
334 If present, the server supports the ``stream_out`` command, which transmits
417 If present, the server supports the ``stream_out`` command, which transmits
335 raw revlogs from the repository instead of changegroups. This provides a faster
418 raw revlogs from the repository instead of changegroups. This provides a faster
336 cloning mechanism at the expense of more bandwidth used.
419 cloning mechanism at the expense of more bandwidth used.
337
420
338 This capability was introduced in Mercurial 0.9.1 (released July 2006).
421 This capability was introduced in Mercurial 0.9.1 (released July 2006).
339
422
340 When initially introduced, the value of the capability was the numeric
423 When initially introduced, the value of the capability was the numeric
341 revlog revision. e.g. ``stream=1``. This indicates the changegroup is using
424 revlog revision. e.g. ``stream=1``. This indicates the changegroup is using
342 ``revlogv1``. This simple integer value wasn't powerful enough, so the
425 ``revlogv1``. This simple integer value wasn't powerful enough, so the
343 ``streamreqs`` capability was invented to handle cases where the repo
426 ``streamreqs`` capability was invented to handle cases where the repo
344 requirements have more than just ``revlogv1``. Newer servers omit the
427 requirements have more than just ``revlogv1``. Newer servers omit the
345 ``=1`` since it was the only value supported and the value of ``1`` can
428 ``=1`` since it was the only value supported and the value of ``1`` can
346 be implied by clients.
429 be implied by clients.
347
430
348 unbundlehash
431 unbundlehash
349 ------------
432 ------------
350
433
351 Whether the ``unbundle`` commands supports receiving a hash of all the
434 Whether the ``unbundle`` commands supports receiving a hash of all the
352 heads instead of a list.
435 heads instead of a list.
353
436
354 For more, see the documentation for the ``unbundle`` command.
437 For more, see the documentation for the ``unbundle`` command.
355
438
356 This capability was introduced in Mercurial 1.9 (released July 2011).
439 This capability was introduced in Mercurial 1.9 (released July 2011).
357
440
358 unbundle
441 unbundle
359 --------
442 --------
360
443
361 Whether the server supports pushing via the ``unbundle`` command.
444 Whether the server supports pushing via the ``unbundle`` command.
362
445
363 This capability/command has been present since Mercurial 0.9.1 (released
446 This capability/command has been present since Mercurial 0.9.1 (released
364 July 2006).
447 July 2006).
365
448
366 Mercurial 0.9.2 (released December 2006) added values to the capability
449 Mercurial 0.9.2 (released December 2006) added values to the capability
367 indicating which bundle types the server supports receiving. This value is a
450 indicating which bundle types the server supports receiving. This value is a
368 comma-delimited list. e.g. ``HG10GZ,HG10BZ,HG10UN``. The order of values
451 comma-delimited list. e.g. ``HG10GZ,HG10BZ,HG10UN``. The order of values
369 reflects the priority/preference of that type, where the first value is the
452 reflects the priority/preference of that type, where the first value is the
370 most preferred type.
453 most preferred type.
371
454
372 Handshake Protocol
455 Handshake Protocol
373 ==================
456 ==================
374
457
375 While not explicitly required, it is common for clients to perform a
458 While not explicitly required, it is common for clients to perform a
376 *handshake* when connecting to a server. The handshake accomplishes 2 things:
459 *handshake* when connecting to a server. The handshake accomplishes 2 things:
377
460
378 * Obtaining capabilities and other server features
461 * Obtaining capabilities and other server features
379 * Flushing extra server output (e.g. SSH servers may print extra text
462 * Flushing extra server output (e.g. SSH servers may print extra text
380 when connecting that may confuse the wire protocol)
463 when connecting that may confuse the wire protocol)
381
464
382 This isn't a traditional *handshake* as far as network protocols go because
465 This isn't a traditional *handshake* as far as network protocols go because
383 there is no persistent state as a result of the handshake: the handshake is
466 there is no persistent state as a result of the handshake: the handshake is
384 simply the issuing of commands and commands are stateless.
467 simply the issuing of commands and commands are stateless.
385
468
386 The canonical clients perform a capabilities lookup at connection establishment
469 The canonical clients perform a capabilities lookup at connection establishment
387 time. This is because clients must assume a server only supports the features
470 time. This is because clients must assume a server only supports the features
388 of the original Mercurial server implementation until proven otherwise (from
471 of the original Mercurial server implementation until proven otherwise (from
389 advertised capabilities). Nearly every server running today supports features
472 advertised capabilities). Nearly every server running today supports features
390 that weren't present in the original Mercurial server implementation. Rather
473 that weren't present in the original Mercurial server implementation. Rather
391 than wait for a client to perform functionality that needs to consult
474 than wait for a client to perform functionality that needs to consult
392 capabilities, it issues the lookup at connection start to avoid any delay later.
475 capabilities, it issues the lookup at connection start to avoid any delay later.
393
476
394 For HTTP servers, the client sends a ``capabilities`` command request as
477 For HTTP servers, the client sends a ``capabilities`` command request as
395 soon as the connection is established. The server responds with a capabilities
478 soon as the connection is established. The server responds with a capabilities
396 string, which the client parses.
479 string, which the client parses.
397
480
398 For SSH servers, the client sends the ``hello`` command (no arguments)
481 For SSH servers, the client sends the ``hello`` command (no arguments)
399 and a ``between`` command with the ``pairs`` argument having the value
482 and a ``between`` command with the ``pairs`` argument having the value
400 ``0000000000000000000000000000000000000000-0000000000000000000000000000000000000000``.
483 ``0000000000000000000000000000000000000000-0000000000000000000000000000000000000000``.
401
484
402 The ``between`` command has been supported since the original Mercurial
485 The ``between`` command has been supported since the original Mercurial
403 server. Requesting the empty range will return a ``\n`` string response,
486 server. Requesting the empty range will return a ``\n`` string response,
404 which will be encoded as ``1\n\n`` (value length of ``1`` followed by a newline
487 which will be encoded as ``1\n\n`` (value length of ``1`` followed by a newline
405 followed by the value, which happens to be a newline).
488 followed by the value, which happens to be a newline).
406
489
407 The ``hello`` command was later introduced. Servers supporting it will issue
490 The ``hello`` command was later introduced. Servers supporting it will issue
408 a response to that command before sending the ``1\n\n`` response to the
491 a response to that command before sending the ``1\n\n`` response to the
409 ``between`` command. Servers not supporting ``hello`` will send an empty
492 ``between`` command. Servers not supporting ``hello`` will send an empty
410 response (``0\n``).
493 response (``0\n``).
411
494
412 In addition to the expected output from the ``hello`` and ``between`` commands,
495 In addition to the expected output from the ``hello`` and ``between`` commands,
413 servers may also send other output, such as *message of the day (MOTD)*
496 servers may also send other output, such as *message of the day (MOTD)*
414 announcements. Clients assume servers will send this output before the
497 announcements. Clients assume servers will send this output before the
415 Mercurial server replies to the client-issued commands. So any server output
498 Mercurial server replies to the client-issued commands. So any server output
416 not conforming to the expected command responses is assumed to be not related
499 not conforming to the expected command responses is assumed to be not related
417 to Mercurial and can be ignored.
500 to Mercurial and can be ignored.
418
501
502 Content Negotiation
503 ===================
504
505 The wire protocol has some mechanisms to help peers determine what content
506 types and encoding the other side will accept. Historically, these mechanisms
507 have been built into commands themselves because most commands only send a
508 well-defined response type and only certain commands needed to support
509 functionality like compression.
510
511 Currently, only the HTTP transport supports content negotiation at the protocol
512 layer.
513
514 HTTP requests advertise supported response formats via the ``X-HgProto-<N>``
515 request header, where ``<N>`` is an integer starting at 1 allowing the logical
516 value to span multiple headers. This value consists of a list of
517 space-delimited parameters. Each parameter denotes a feature or capability.
518
519 The following parameters are defined:
520
521 0.1
522 Indicates the client supports receiving ``application/mercurial-0.1``
523 responses.
524
525 0.2
526 Indicates the client supports receiving ``application/mercurial-0.2``
527 responses.
528
529 comp
530 Indicates compression formats the client can decode. Value is a list of
531 comma delimited strings identifying compression formats ordered from
532 most preferential to least preferential. e.g. ``comp=zstd,zlib,none``.
533
534 This parameter does not have an effect if only the ``0.1`` parameter
535 is defined, as support for ``application/mercurial-0.2`` or greater is
536 required to use arbitrary compression formats.
537
538 If this parameter is not advertised, the server interprets this as
539 equivalent to ``zlib,none``.
540
541 Clients may choose to only send this header if the ``httpmediatype``
542 server capability is present, as currently all server-side features
543 consulting this header require the client to opt in to new protocol features
544 advertised via the ``httpmediatype`` capability.
545
546 A server that doesn't receive an ``X-HgProto-<N>`` header should infer a
547 value of ``0.1``. This is compatible with legacy clients.
548
549 A server receiving a request indicating support for multiple media type
550 versions may respond with any of the supported media types. Not all servers
551 may support all media types on all commands.
552
419 Commands
553 Commands
420 ========
554 ========
421
555
422 This section contains a list of all wire protocol commands implemented by
556 This section contains a list of all wire protocol commands implemented by
423 the canonical Mercurial server.
557 the canonical Mercurial server.
424
558
425 batch
559 batch
426 -----
560 -----
427
561
428 Issue multiple commands while sending a single command request. The purpose
562 Issue multiple commands while sending a single command request. The purpose
429 of this command is to allow a client to issue multiple commands while avoiding
563 of this command is to allow a client to issue multiple commands while avoiding
430 multiple round trips to the server therefore enabling commands to complete
564 multiple round trips to the server therefore enabling commands to complete
431 quicker.
565 quicker.
432
566
433 The command accepts a ``cmds`` argument that contains a list of commands to
567 The command accepts a ``cmds`` argument that contains a list of commands to
434 execute.
568 execute.
435
569
436 The value of ``cmds`` is a ``;`` delimited list of strings. Each string has the
570 The value of ``cmds`` is a ``;`` delimited list of strings. Each string has the
437 form ``<command> <arguments>``. That is, the command name followed by a space
571 form ``<command> <arguments>``. That is, the command name followed by a space
438 followed by an argument string.
572 followed by an argument string.
439
573
440 The argument string is a ``,`` delimited list of ``<key>=<value>`` values
574 The argument string is a ``,`` delimited list of ``<key>=<value>`` values
441 corresponding to command arguments. Both the argument name and value are
575 corresponding to command arguments. Both the argument name and value are
442 escaped using a special substitution map::
576 escaped using a special substitution map::
443
577
444 : -> :c
578 : -> :c
445 , -> :o
579 , -> :o
446 ; -> :s
580 ; -> :s
447 = -> :e
581 = -> :e
448
582
449 The response type for this command is ``string``. The value contains a
583 The response type for this command is ``string``. The value contains a
450 ``;`` delimited list of responses for each requested command. Each value
584 ``;`` delimited list of responses for each requested command. Each value
451 in this list is escaped using the same substitution map used for arguments.
585 in this list is escaped using the same substitution map used for arguments.
452
586
453 If an error occurs, the generic error response may be sent.
587 If an error occurs, the generic error response may be sent.
454
588
455 between
589 between
456 -------
590 -------
457
591
458 (Legacy command used for discovery in old clients)
592 (Legacy command used for discovery in old clients)
459
593
460 Obtain nodes between pairs of nodes.
594 Obtain nodes between pairs of nodes.
461
595
462 The ``pairs`` arguments contains a space-delimited list of ``-`` delimited
596 The ``pairs`` arguments contains a space-delimited list of ``-`` delimited
463 hex node pairs. e.g.::
597 hex node pairs. e.g.::
464
598
465 a072279d3f7fd3a4aa7ffa1a5af8efc573e1c896-6dc58916e7c070f678682bfe404d2e2d68291a18
599 a072279d3f7fd3a4aa7ffa1a5af8efc573e1c896-6dc58916e7c070f678682bfe404d2e2d68291a18
466
600
467 Return type is a ``string``. Value consists of lines corresponding to each
601 Return type is a ``string``. Value consists of lines corresponding to each
468 requested range. Each line contains a space-delimited list of hex nodes.
602 requested range. Each line contains a space-delimited list of hex nodes.
469 A newline ``\n`` terminates each line, including the last one.
603 A newline ``\n`` terminates each line, including the last one.
470
604
471 branchmap
605 branchmap
472 ---------
606 ---------
473
607
474 Obtain heads in named branches.
608 Obtain heads in named branches.
475
609
476 Accepts no arguments. Return type is a ``string``.
610 Accepts no arguments. Return type is a ``string``.
477
611
478 Return value contains lines with URL encoded branch names followed by a space
612 Return value contains lines with URL encoded branch names followed by a space
479 followed by a space-delimited list of hex nodes of heads on that branch.
613 followed by a space-delimited list of hex nodes of heads on that branch.
480 e.g.::
614 e.g.::
481
615
482 default a072279d3f7fd3a4aa7ffa1a5af8efc573e1c896 6dc58916e7c070f678682bfe404d2e2d68291a18
616 default a072279d3f7fd3a4aa7ffa1a5af8efc573e1c896 6dc58916e7c070f678682bfe404d2e2d68291a18
483 stable baae3bf31522f41dd5e6d7377d0edd8d1cf3fccc
617 stable baae3bf31522f41dd5e6d7377d0edd8d1cf3fccc
484
618
485 There is no trailing newline.
619 There is no trailing newline.
486
620
487 branches
621 branches
488 --------
622 --------
489
623
490 Obtain ancestor changesets of specific nodes back to a branch point.
624 Obtain ancestor changesets of specific nodes back to a branch point.
491
625
492 Despite the name, this command has nothing to do with Mercurial named branches.
626 Despite the name, this command has nothing to do with Mercurial named branches.
493 Instead, it is related to DAG branches.
627 Instead, it is related to DAG branches.
494
628
495 The command accepts a ``nodes`` argument, which is a string of space-delimited
629 The command accepts a ``nodes`` argument, which is a string of space-delimited
496 hex nodes.
630 hex nodes.
497
631
498 For each node requested, the server will find the first ancestor node that is
632 For each node requested, the server will find the first ancestor node that is
499 a DAG root or is a merge.
633 a DAG root or is a merge.
500
634
501 Return type is a ``string``. Return value contains lines with result data for
635 Return type is a ``string``. Return value contains lines with result data for
502 each requested node. Each line contains space-delimited nodes followed by a
636 each requested node. Each line contains space-delimited nodes followed by a
503 newline (``\n``). The 4 nodes reported on each line correspond to the requested
637 newline (``\n``). The 4 nodes reported on each line correspond to the requested
504 node, the ancestor node found, and its 2 parent nodes (which may be the null
638 node, the ancestor node found, and its 2 parent nodes (which may be the null
505 node).
639 node).
506
640
507 capabilities
641 capabilities
508 ------------
642 ------------
509
643
510 Obtain the capabilities string for the repo.
644 Obtain the capabilities string for the repo.
511
645
512 Unlike the ``hello`` command, the capabilities string is not prefixed.
646 Unlike the ``hello`` command, the capabilities string is not prefixed.
513 There is no trailing newline.
647 There is no trailing newline.
514
648
515 This command does not accept any arguments. Return type is a ``string``.
649 This command does not accept any arguments. Return type is a ``string``.
516
650
517 changegroup
651 changegroup
518 -----------
652 -----------
519
653
520 (Legacy command: use ``getbundle`` instead)
654 (Legacy command: use ``getbundle`` instead)
521
655
522 Obtain a changegroup version 1 with data for changesets that are
656 Obtain a changegroup version 1 with data for changesets that are
523 descendants of client-specified changesets.
657 descendants of client-specified changesets.
524
658
525 The ``roots`` arguments contains a list of space-delimited hex nodes.
659 The ``roots`` arguments contains a list of space-delimited hex nodes.
526
660
527 The server responds with a changegroup version 1 containing all
661 The server responds with a changegroup version 1 containing all
528 changesets between the requested root/base nodes and the repo's head nodes
662 changesets between the requested root/base nodes and the repo's head nodes
529 at the time of the request.
663 at the time of the request.
530
664
531 The return type is a ``stream``.
665 The return type is a ``stream``.
532
666
533 changegroupsubset
667 changegroupsubset
534 -----------------
668 -----------------
535
669
536 (Legacy command: use ``getbundle`` instead)
670 (Legacy command: use ``getbundle`` instead)
537
671
538 Obtain a changegroup version 1 with data for changesetsets between
672 Obtain a changegroup version 1 with data for changesetsets between
539 client specified base and head nodes.
673 client specified base and head nodes.
540
674
541 The ``bases`` argument contains a list of space-delimited hex nodes.
675 The ``bases`` argument contains a list of space-delimited hex nodes.
542 The ``heads`` argument contains a list of space-delimited hex nodes.
676 The ``heads`` argument contains a list of space-delimited hex nodes.
543
677
544 The server responds with a changegroup version 1 containing all
678 The server responds with a changegroup version 1 containing all
545 changesets between the requested base and head nodes at the time of the
679 changesets between the requested base and head nodes at the time of the
546 request.
680 request.
547
681
548 The return type is a ``stream``.
682 The return type is a ``stream``.
549
683
550 clonebundles
684 clonebundles
551 ------------
685 ------------
552
686
553 Obtains a manifest of bundle URLs available to seed clones.
687 Obtains a manifest of bundle URLs available to seed clones.
554
688
555 Each returned line contains a URL followed by metadata. See the
689 Each returned line contains a URL followed by metadata. See the
556 documentation in the ``clonebundles`` extension for more.
690 documentation in the ``clonebundles`` extension for more.
557
691
558 The return type is a ``string``.
692 The return type is a ``string``.
559
693
560 getbundle
694 getbundle
561 ---------
695 ---------
562
696
563 Obtain a bundle containing repository data.
697 Obtain a bundle containing repository data.
564
698
565 This command accepts the following arguments:
699 This command accepts the following arguments:
566
700
567 heads
701 heads
568 List of space-delimited hex nodes of heads to retrieve.
702 List of space-delimited hex nodes of heads to retrieve.
569 common
703 common
570 List of space-delimited hex nodes that the client has in common with the
704 List of space-delimited hex nodes that the client has in common with the
571 server.
705 server.
572 obsmarkers
706 obsmarkers
573 Boolean indicating whether to include obsolescence markers as part
707 Boolean indicating whether to include obsolescence markers as part
574 of the response. Only works with bundle2.
708 of the response. Only works with bundle2.
575 bundlecaps
709 bundlecaps
576 Comma-delimited set of strings defining client bundle capabilities.
710 Comma-delimited set of strings defining client bundle capabilities.
577 listkeys
711 listkeys
578 Comma-delimited list of strings of ``pushkey`` namespaces. For each
712 Comma-delimited list of strings of ``pushkey`` namespaces. For each
579 namespace listed, a bundle2 part will be included with the content of
713 namespace listed, a bundle2 part will be included with the content of
580 that namespace.
714 that namespace.
581 cg
715 cg
582 Boolean indicating whether changegroup data is requested.
716 Boolean indicating whether changegroup data is requested.
583 cbattempted
717 cbattempted
584 Boolean indicating whether the client attempted to use the *clone bundles*
718 Boolean indicating whether the client attempted to use the *clone bundles*
585 feature before performing this request.
719 feature before performing this request.
586
720
587 The return type on success is a ``stream`` where the value is bundle.
721 The return type on success is a ``stream`` where the value is bundle.
588 On the HTTP transport, the response is zlib compressed.
722 On the HTTP transport, the response is zlib compressed.
589
723
590 If an error occurs, a generic error response can be sent.
724 If an error occurs, a generic error response can be sent.
591
725
592 Unless the client sends a false value for the ``cg`` argument, the returned
726 Unless the client sends a false value for the ``cg`` argument, the returned
593 bundle contains a changegroup with the nodes between the specified ``common``
727 bundle contains a changegroup with the nodes between the specified ``common``
594 and ``heads`` nodes. Depending on the command arguments, the type and content
728 and ``heads`` nodes. Depending on the command arguments, the type and content
595 of the returned bundle can vary significantly.
729 of the returned bundle can vary significantly.
596
730
597 The default behavior is for the server to send a raw changegroup version
731 The default behavior is for the server to send a raw changegroup version
598 ``01`` response.
732 ``01`` response.
599
733
600 If the ``bundlecaps`` provided by the client contain a value beginning
734 If the ``bundlecaps`` provided by the client contain a value beginning
601 with ``HG2``, a bundle2 will be returned. The bundle2 data may contain
735 with ``HG2``, a bundle2 will be returned. The bundle2 data may contain
602 additional repository data, such as ``pushkey`` namespace values.
736 additional repository data, such as ``pushkey`` namespace values.
603
737
604 heads
738 heads
605 -----
739 -----
606
740
607 Returns a list of space-delimited hex nodes of repository heads followed
741 Returns a list of space-delimited hex nodes of repository heads followed
608 by a newline. e.g.
742 by a newline. e.g.
609 ``a9eeb3adc7ddb5006c088e9eda61791c777cbf7c 31f91a3da534dc849f0d6bfc00a395a97cf218a1\n``
743 ``a9eeb3adc7ddb5006c088e9eda61791c777cbf7c 31f91a3da534dc849f0d6bfc00a395a97cf218a1\n``
610
744
611 This command does not accept any arguments. The return type is a ``string``.
745 This command does not accept any arguments. The return type is a ``string``.
612
746
613 hello
747 hello
614 -----
748 -----
615
749
616 Returns lines describing interesting things about the server in an RFC-822
750 Returns lines describing interesting things about the server in an RFC-822
617 like format.
751 like format.
618
752
619 Currently, the only line defines the server capabilities. It has the form::
753 Currently, the only line defines the server capabilities. It has the form::
620
754
621 capabilities: <value>
755 capabilities: <value>
622
756
623 See above for more about the capabilities string.
757 See above for more about the capabilities string.
624
758
625 SSH clients typically issue this command as soon as a connection is
759 SSH clients typically issue this command as soon as a connection is
626 established.
760 established.
627
761
628 This command does not accept any arguments. The return type is a ``string``.
762 This command does not accept any arguments. The return type is a ``string``.
629
763
630 listkeys
764 listkeys
631 --------
765 --------
632
766
633 List values in a specified ``pushkey`` namespace.
767 List values in a specified ``pushkey`` namespace.
634
768
635 The ``namespace`` argument defines the pushkey namespace to operate on.
769 The ``namespace`` argument defines the pushkey namespace to operate on.
636
770
637 The return type is a ``string``. The value is an encoded dictionary of keys.
771 The return type is a ``string``. The value is an encoded dictionary of keys.
638
772
639 Key-value pairs are delimited by newlines (``\n``). Within each line, keys and
773 Key-value pairs are delimited by newlines (``\n``). Within each line, keys and
640 values are separated by a tab (``\t``). Keys and values are both strings.
774 values are separated by a tab (``\t``). Keys and values are both strings.
641
775
642 lookup
776 lookup
643 ------
777 ------
644
778
645 Try to resolve a value to a known repository revision.
779 Try to resolve a value to a known repository revision.
646
780
647 The ``key`` argument is converted from bytes to an
781 The ``key`` argument is converted from bytes to an
648 ``encoding.localstr`` instance then passed into
782 ``encoding.localstr`` instance then passed into
649 ``localrepository.__getitem__`` in an attempt to resolve it.
783 ``localrepository.__getitem__`` in an attempt to resolve it.
650
784
651 The return type is a ``string``.
785 The return type is a ``string``.
652
786
653 Upon successful resolution, returns ``1 <hex node>\n``. On failure,
787 Upon successful resolution, returns ``1 <hex node>\n``. On failure,
654 returns ``0 <error string>\n``. e.g.::
788 returns ``0 <error string>\n``. e.g.::
655
789
656 1 273ce12ad8f155317b2c078ec75a4eba507f1fba\n
790 1 273ce12ad8f155317b2c078ec75a4eba507f1fba\n
657
791
658 0 unknown revision 'foo'\n
792 0 unknown revision 'foo'\n
659
793
660 known
794 known
661 -----
795 -----
662
796
663 Determine whether multiple nodes are known.
797 Determine whether multiple nodes are known.
664
798
665 The ``nodes`` argument is a list of space-delimited hex nodes to check
799 The ``nodes`` argument is a list of space-delimited hex nodes to check
666 for existence.
800 for existence.
667
801
668 The return type is ``string``.
802 The return type is ``string``.
669
803
670 Returns a string consisting of ``0``s and ``1``s indicating whether nodes
804 Returns a string consisting of ``0``s and ``1``s indicating whether nodes
671 are known. If the Nth node specified in the ``nodes`` argument is known,
805 are known. If the Nth node specified in the ``nodes`` argument is known,
672 a ``1`` will be returned at byte offset N. If the node isn't known, ``0``
806 a ``1`` will be returned at byte offset N. If the node isn't known, ``0``
673 will be present at byte offset N.
807 will be present at byte offset N.
674
808
675 There is no trailing newline.
809 There is no trailing newline.
676
810
677 pushkey
811 pushkey
678 -------
812 -------
679
813
680 Set a value using the ``pushkey`` protocol.
814 Set a value using the ``pushkey`` protocol.
681
815
682 Accepts arguments ``namespace``, ``key``, ``old``, and ``new``, which
816 Accepts arguments ``namespace``, ``key``, ``old``, and ``new``, which
683 correspond to the pushkey namespace to operate on, the key within that
817 correspond to the pushkey namespace to operate on, the key within that
684 namespace to change, the old value (which may be empty), and the new value.
818 namespace to change, the old value (which may be empty), and the new value.
685 All arguments are string types.
819 All arguments are string types.
686
820
687 The return type is a ``string``. The value depends on the transport protocol.
821 The return type is a ``string``. The value depends on the transport protocol.
688
822
689 The SSH transport sends a string encoded integer followed by a newline
823 The SSH transport sends a string encoded integer followed by a newline
690 (``\n``) which indicates operation result. The server may send additional
824 (``\n``) which indicates operation result. The server may send additional
691 output on the ``stderr`` stream that should be displayed to the user.
825 output on the ``stderr`` stream that should be displayed to the user.
692
826
693 The HTTP transport sends a string encoded integer followed by a newline
827 The HTTP transport sends a string encoded integer followed by a newline
694 followed by additional server output that should be displayed to the user.
828 followed by additional server output that should be displayed to the user.
695 This may include output from hooks, etc.
829 This may include output from hooks, etc.
696
830
697 The integer result varies by namespace. ``0`` means an error has occurred
831 The integer result varies by namespace. ``0`` means an error has occurred
698 and there should be additional output to display to the user.
832 and there should be additional output to display to the user.
699
833
700 stream_out
834 stream_out
701 ----------
835 ----------
702
836
703 Obtain *streaming clone* data.
837 Obtain *streaming clone* data.
704
838
705 The return type is either a ``string`` or a ``stream``, depending on
839 The return type is either a ``string`` or a ``stream``, depending on
706 whether the request was fulfilled properly.
840 whether the request was fulfilled properly.
707
841
708 A return value of ``1\n`` indicates the server is not configured to serve
842 A return value of ``1\n`` indicates the server is not configured to serve
709 this data. If this is seen by the client, they may not have verified the
843 this data. If this is seen by the client, they may not have verified the
710 ``stream`` capability is set before making the request.
844 ``stream`` capability is set before making the request.
711
845
712 A return value of ``2\n`` indicates the server was unable to lock the
846 A return value of ``2\n`` indicates the server was unable to lock the
713 repository to generate data.
847 repository to generate data.
714
848
715 All other responses are a ``stream`` of bytes. The first line of this data
849 All other responses are a ``stream`` of bytes. The first line of this data
716 contains 2 space-delimited integers corresponding to the path count and
850 contains 2 space-delimited integers corresponding to the path count and
717 payload size, respectively::
851 payload size, respectively::
718
852
719 <path count> <payload size>\n
853 <path count> <payload size>\n
720
854
721 The ``<payload size>`` is the total size of path data: it does not include
855 The ``<payload size>`` is the total size of path data: it does not include
722 the size of the per-path header lines.
856 the size of the per-path header lines.
723
857
724 Following that header are ``<path count>`` entries. Each entry consists of a
858 Following that header are ``<path count>`` entries. Each entry consists of a
725 line with metadata followed by raw revlog data. The line consists of::
859 line with metadata followed by raw revlog data. The line consists of::
726
860
727 <store path>\0<size>\n
861 <store path>\0<size>\n
728
862
729 The ``<store path>`` is the encoded store path of the data that follows.
863 The ``<store path>`` is the encoded store path of the data that follows.
730 ``<size>`` is the amount of data for this store path/revlog that follows the
864 ``<size>`` is the amount of data for this store path/revlog that follows the
731 newline.
865 newline.
732
866
733 There is no trailer to indicate end of data. Instead, the client should stop
867 There is no trailer to indicate end of data. Instead, the client should stop
734 reading after ``<path count>`` entries are consumed.
868 reading after ``<path count>`` entries are consumed.
735
869
736 unbundle
870 unbundle
737 --------
871 --------
738
872
739 Send a bundle containing data (usually changegroup data) to the server.
873 Send a bundle containing data (usually changegroup data) to the server.
740
874
741 Accepts the argument ``heads``, which is a space-delimited list of hex nodes
875 Accepts the argument ``heads``, which is a space-delimited list of hex nodes
742 corresponding to server repository heads observed by the client. This is used
876 corresponding to server repository heads observed by the client. This is used
743 to detect race conditions and abort push operations before a server performs
877 to detect race conditions and abort push operations before a server performs
744 too much work or a client transfers too much data.
878 too much work or a client transfers too much data.
745
879
746 The request payload consists of a bundle to be applied to the repository,
880 The request payload consists of a bundle to be applied to the repository,
747 similarly to as if :hg:`unbundle` were called.
881 similarly to as if :hg:`unbundle` were called.
748
882
749 In most scenarios, a special ``push response`` type is returned. This type
883 In most scenarios, a special ``push response`` type is returned. This type
750 contains an integer describing the change in heads as a result of the
884 contains an integer describing the change in heads as a result of the
751 operation. A value of ``0`` indicates nothing changed. ``1`` means the number
885 operation. A value of ``0`` indicates nothing changed. ``1`` means the number
752 of heads remained the same. Values ``2`` and larger indicate the number of
886 of heads remained the same. Values ``2`` and larger indicate the number of
753 added heads minus 1. e.g. ``3`` means 2 heads were added. Negative values
887 added heads minus 1. e.g. ``3`` means 2 heads were added. Negative values
754 indicate the number of fewer heads, also off by 1. e.g. ``-2`` means there
888 indicate the number of fewer heads, also off by 1. e.g. ``-2`` means there
755 is 1 fewer head.
889 is 1 fewer head.
756
890
757 The encoding of the ``push response`` type varies by transport.
891 The encoding of the ``push response`` type varies by transport.
758
892
759 For the SSH transport, this type is composed of 2 ``string`` responses: an
893 For the SSH transport, this type is composed of 2 ``string`` responses: an
760 empty response (``0\n``) followed by the integer result value. e.g.
894 empty response (``0\n``) followed by the integer result value. e.g.
761 ``1\n2``. So the full response might be ``0\n1\n2``.
895 ``1\n2``. So the full response might be ``0\n1\n2``.
762
896
763 For the HTTP transport, the response is a ``string`` type composed of an
897 For the HTTP transport, the response is a ``string`` type composed of an
764 integer result value followed by a newline (``\n``) followed by string
898 integer result value followed by a newline (``\n``) followed by string
765 content holding server output that should be displayed on the client (output
899 content holding server output that should be displayed on the client (output
766 hooks, etc).
900 hooks, etc).
767
901
768 In some cases, the server may respond with a ``bundle2`` bundle. In this
902 In some cases, the server may respond with a ``bundle2`` bundle. In this
769 case, the response type is ``stream``. For the HTTP transport, the response
903 case, the response type is ``stream``. For the HTTP transport, the response
770 is zlib compressed.
904 is zlib compressed.
771
905
772 The server may also respond with a generic error type, which contains a string
906 The server may also respond with a generic error type, which contains a string
773 indicating the failure.
907 indicating the failure.
General Comments 0
You need to be logged in to leave comments. Login now