##// END OF EJS Templates
sshserver: flush stream after command dispatch...
marmoute -
r43166:7e19b640 default
parent child Browse files
Show More
@@ -1,804 +1,806 b''
1 # Copyright 21 May 2005 - (c) 2005 Jake Edge <jake@edge2.net>
1 # Copyright 21 May 2005 - (c) 2005 Jake Edge <jake@edge2.net>
2 # Copyright 2005-2007 Matt Mackall <mpm@selenic.com>
2 # Copyright 2005-2007 Matt Mackall <mpm@selenic.com>
3 #
3 #
4 # This software may be used and distributed according to the terms of the
4 # This software may be used and distributed according to the terms of the
5 # GNU General Public License version 2 or any later version.
5 # GNU General Public License version 2 or any later version.
6
6
7 from __future__ import absolute_import
7 from __future__ import absolute_import
8
8
9 import contextlib
9 import contextlib
10 import struct
10 import struct
11 import sys
11 import sys
12 import threading
12 import threading
13
13
14 from .i18n import _
14 from .i18n import _
15 from . import (
15 from . import (
16 encoding,
16 encoding,
17 error,
17 error,
18 pycompat,
18 pycompat,
19 util,
19 util,
20 wireprototypes,
20 wireprototypes,
21 wireprotov1server,
21 wireprotov1server,
22 wireprotov2server,
22 wireprotov2server,
23 )
23 )
24 from .interfaces import (
24 from .interfaces import (
25 util as interfaceutil,
25 util as interfaceutil,
26 )
26 )
27 from .utils import (
27 from .utils import (
28 cborutil,
28 cborutil,
29 compression,
29 compression,
30 )
30 )
31
31
32 stringio = util.stringio
32 stringio = util.stringio
33
33
34 urlerr = util.urlerr
34 urlerr = util.urlerr
35 urlreq = util.urlreq
35 urlreq = util.urlreq
36
36
37 HTTP_OK = 200
37 HTTP_OK = 200
38
38
39 HGTYPE = 'application/mercurial-0.1'
39 HGTYPE = 'application/mercurial-0.1'
40 HGTYPE2 = 'application/mercurial-0.2'
40 HGTYPE2 = 'application/mercurial-0.2'
41 HGERRTYPE = 'application/hg-error'
41 HGERRTYPE = 'application/hg-error'
42
42
43 SSHV1 = wireprototypes.SSHV1
43 SSHV1 = wireprototypes.SSHV1
44 SSHV2 = wireprototypes.SSHV2
44 SSHV2 = wireprototypes.SSHV2
45
45
46 def decodevaluefromheaders(req, headerprefix):
46 def decodevaluefromheaders(req, headerprefix):
47 """Decode a long value from multiple HTTP request headers.
47 """Decode a long value from multiple HTTP request headers.
48
48
49 Returns the value as a bytes, not a str.
49 Returns the value as a bytes, not a str.
50 """
50 """
51 chunks = []
51 chunks = []
52 i = 1
52 i = 1
53 while True:
53 while True:
54 v = req.headers.get(b'%s-%d' % (headerprefix, i))
54 v = req.headers.get(b'%s-%d' % (headerprefix, i))
55 if v is None:
55 if v is None:
56 break
56 break
57 chunks.append(pycompat.bytesurl(v))
57 chunks.append(pycompat.bytesurl(v))
58 i += 1
58 i += 1
59
59
60 return ''.join(chunks)
60 return ''.join(chunks)
61
61
62 @interfaceutil.implementer(wireprototypes.baseprotocolhandler)
62 @interfaceutil.implementer(wireprototypes.baseprotocolhandler)
63 class httpv1protocolhandler(object):
63 class httpv1protocolhandler(object):
64 def __init__(self, req, ui, checkperm):
64 def __init__(self, req, ui, checkperm):
65 self._req = req
65 self._req = req
66 self._ui = ui
66 self._ui = ui
67 self._checkperm = checkperm
67 self._checkperm = checkperm
68 self._protocaps = None
68 self._protocaps = None
69
69
70 @property
70 @property
71 def name(self):
71 def name(self):
72 return 'http-v1'
72 return 'http-v1'
73
73
74 def getargs(self, args):
74 def getargs(self, args):
75 knownargs = self._args()
75 knownargs = self._args()
76 data = {}
76 data = {}
77 keys = args.split()
77 keys = args.split()
78 for k in keys:
78 for k in keys:
79 if k == '*':
79 if k == '*':
80 star = {}
80 star = {}
81 for key in knownargs.keys():
81 for key in knownargs.keys():
82 if key != 'cmd' and key not in keys:
82 if key != 'cmd' and key not in keys:
83 star[key] = knownargs[key][0]
83 star[key] = knownargs[key][0]
84 data['*'] = star
84 data['*'] = star
85 else:
85 else:
86 data[k] = knownargs[k][0]
86 data[k] = knownargs[k][0]
87 return [data[k] for k in keys]
87 return [data[k] for k in keys]
88
88
89 def _args(self):
89 def _args(self):
90 args = self._req.qsparams.asdictoflists()
90 args = self._req.qsparams.asdictoflists()
91 postlen = int(self._req.headers.get(b'X-HgArgs-Post', 0))
91 postlen = int(self._req.headers.get(b'X-HgArgs-Post', 0))
92 if postlen:
92 if postlen:
93 args.update(urlreq.parseqs(
93 args.update(urlreq.parseqs(
94 self._req.bodyfh.read(postlen), keep_blank_values=True))
94 self._req.bodyfh.read(postlen), keep_blank_values=True))
95 return args
95 return args
96
96
97 argvalue = decodevaluefromheaders(self._req, b'X-HgArg')
97 argvalue = decodevaluefromheaders(self._req, b'X-HgArg')
98 args.update(urlreq.parseqs(argvalue, keep_blank_values=True))
98 args.update(urlreq.parseqs(argvalue, keep_blank_values=True))
99 return args
99 return args
100
100
101 def getprotocaps(self):
101 def getprotocaps(self):
102 if self._protocaps is None:
102 if self._protocaps is None:
103 value = decodevaluefromheaders(self._req, b'X-HgProto')
103 value = decodevaluefromheaders(self._req, b'X-HgProto')
104 self._protocaps = set(value.split(' '))
104 self._protocaps = set(value.split(' '))
105 return self._protocaps
105 return self._protocaps
106
106
107 def getpayload(self):
107 def getpayload(self):
108 # Existing clients *always* send Content-Length.
108 # Existing clients *always* send Content-Length.
109 length = int(self._req.headers[b'Content-Length'])
109 length = int(self._req.headers[b'Content-Length'])
110
110
111 # If httppostargs is used, we need to read Content-Length
111 # If httppostargs is used, we need to read Content-Length
112 # minus the amount that was consumed by args.
112 # minus the amount that was consumed by args.
113 length -= int(self._req.headers.get(b'X-HgArgs-Post', 0))
113 length -= int(self._req.headers.get(b'X-HgArgs-Post', 0))
114 return util.filechunkiter(self._req.bodyfh, limit=length)
114 return util.filechunkiter(self._req.bodyfh, limit=length)
115
115
116 @contextlib.contextmanager
116 @contextlib.contextmanager
117 def mayberedirectstdio(self):
117 def mayberedirectstdio(self):
118 oldout = self._ui.fout
118 oldout = self._ui.fout
119 olderr = self._ui.ferr
119 olderr = self._ui.ferr
120
120
121 out = util.stringio()
121 out = util.stringio()
122
122
123 try:
123 try:
124 self._ui.fout = out
124 self._ui.fout = out
125 self._ui.ferr = out
125 self._ui.ferr = out
126 yield out
126 yield out
127 finally:
127 finally:
128 self._ui.fout = oldout
128 self._ui.fout = oldout
129 self._ui.ferr = olderr
129 self._ui.ferr = olderr
130
130
131 def client(self):
131 def client(self):
132 return 'remote:%s:%s:%s' % (
132 return 'remote:%s:%s:%s' % (
133 self._req.urlscheme,
133 self._req.urlscheme,
134 urlreq.quote(self._req.remotehost or ''),
134 urlreq.quote(self._req.remotehost or ''),
135 urlreq.quote(self._req.remoteuser or ''))
135 urlreq.quote(self._req.remoteuser or ''))
136
136
137 def addcapabilities(self, repo, caps):
137 def addcapabilities(self, repo, caps):
138 caps.append(b'batch')
138 caps.append(b'batch')
139
139
140 caps.append('httpheader=%d' %
140 caps.append('httpheader=%d' %
141 repo.ui.configint('server', 'maxhttpheaderlen'))
141 repo.ui.configint('server', 'maxhttpheaderlen'))
142 if repo.ui.configbool('experimental', 'httppostargs'):
142 if repo.ui.configbool('experimental', 'httppostargs'):
143 caps.append('httppostargs')
143 caps.append('httppostargs')
144
144
145 # FUTURE advertise 0.2rx once support is implemented
145 # FUTURE advertise 0.2rx once support is implemented
146 # FUTURE advertise minrx and mintx after consulting config option
146 # FUTURE advertise minrx and mintx after consulting config option
147 caps.append('httpmediatype=0.1rx,0.1tx,0.2tx')
147 caps.append('httpmediatype=0.1rx,0.1tx,0.2tx')
148
148
149 compengines = wireprototypes.supportedcompengines(repo.ui,
149 compengines = wireprototypes.supportedcompengines(repo.ui,
150 compression.SERVERROLE)
150 compression.SERVERROLE)
151 if compengines:
151 if compengines:
152 comptypes = ','.join(urlreq.quote(e.wireprotosupport().name)
152 comptypes = ','.join(urlreq.quote(e.wireprotosupport().name)
153 for e in compengines)
153 for e in compengines)
154 caps.append('compression=%s' % comptypes)
154 caps.append('compression=%s' % comptypes)
155
155
156 return caps
156 return caps
157
157
158 def checkperm(self, perm):
158 def checkperm(self, perm):
159 return self._checkperm(perm)
159 return self._checkperm(perm)
160
160
161 # This method exists mostly so that extensions like remotefilelog can
161 # This method exists mostly so that extensions like remotefilelog can
162 # disable a kludgey legacy method only over http. As of early 2018,
162 # disable a kludgey legacy method only over http. As of early 2018,
163 # there are no other known users, so with any luck we can discard this
163 # there are no other known users, so with any luck we can discard this
164 # hook if remotefilelog becomes a first-party extension.
164 # hook if remotefilelog becomes a first-party extension.
165 def iscmd(cmd):
165 def iscmd(cmd):
166 return cmd in wireprotov1server.commands
166 return cmd in wireprotov1server.commands
167
167
168 def handlewsgirequest(rctx, req, res, checkperm):
168 def handlewsgirequest(rctx, req, res, checkperm):
169 """Possibly process a wire protocol request.
169 """Possibly process a wire protocol request.
170
170
171 If the current request is a wire protocol request, the request is
171 If the current request is a wire protocol request, the request is
172 processed by this function.
172 processed by this function.
173
173
174 ``req`` is a ``parsedrequest`` instance.
174 ``req`` is a ``parsedrequest`` instance.
175 ``res`` is a ``wsgiresponse`` instance.
175 ``res`` is a ``wsgiresponse`` instance.
176
176
177 Returns a bool indicating if the request was serviced. If set, the caller
177 Returns a bool indicating if the request was serviced. If set, the caller
178 should stop processing the request, as a response has already been issued.
178 should stop processing the request, as a response has already been issued.
179 """
179 """
180 # Avoid cycle involving hg module.
180 # Avoid cycle involving hg module.
181 from .hgweb import common as hgwebcommon
181 from .hgweb import common as hgwebcommon
182
182
183 repo = rctx.repo
183 repo = rctx.repo
184
184
185 # HTTP version 1 wire protocol requests are denoted by a "cmd" query
185 # HTTP version 1 wire protocol requests are denoted by a "cmd" query
186 # string parameter. If it isn't present, this isn't a wire protocol
186 # string parameter. If it isn't present, this isn't a wire protocol
187 # request.
187 # request.
188 if 'cmd' not in req.qsparams:
188 if 'cmd' not in req.qsparams:
189 return False
189 return False
190
190
191 cmd = req.qsparams['cmd']
191 cmd = req.qsparams['cmd']
192
192
193 # The "cmd" request parameter is used by both the wire protocol and hgweb.
193 # The "cmd" request parameter is used by both the wire protocol and hgweb.
194 # While not all wire protocol commands are available for all transports,
194 # While not all wire protocol commands are available for all transports,
195 # if we see a "cmd" value that resembles a known wire protocol command, we
195 # if we see a "cmd" value that resembles a known wire protocol command, we
196 # route it to a protocol handler. This is better than routing possible
196 # route it to a protocol handler. This is better than routing possible
197 # wire protocol requests to hgweb because it prevents hgweb from using
197 # wire protocol requests to hgweb because it prevents hgweb from using
198 # known wire protocol commands and it is less confusing for machine
198 # known wire protocol commands and it is less confusing for machine
199 # clients.
199 # clients.
200 if not iscmd(cmd):
200 if not iscmd(cmd):
201 return False
201 return False
202
202
203 # The "cmd" query string argument is only valid on the root path of the
203 # The "cmd" query string argument is only valid on the root path of the
204 # repo. e.g. ``/?cmd=foo``, ``/repo?cmd=foo``. URL paths within the repo
204 # repo. e.g. ``/?cmd=foo``, ``/repo?cmd=foo``. URL paths within the repo
205 # like ``/blah?cmd=foo`` are not allowed. So don't recognize the request
205 # like ``/blah?cmd=foo`` are not allowed. So don't recognize the request
206 # in this case. We send an HTTP 404 for backwards compatibility reasons.
206 # in this case. We send an HTTP 404 for backwards compatibility reasons.
207 if req.dispatchpath:
207 if req.dispatchpath:
208 res.status = hgwebcommon.statusmessage(404)
208 res.status = hgwebcommon.statusmessage(404)
209 res.headers['Content-Type'] = HGTYPE
209 res.headers['Content-Type'] = HGTYPE
210 # TODO This is not a good response to issue for this request. This
210 # TODO This is not a good response to issue for this request. This
211 # is mostly for BC for now.
211 # is mostly for BC for now.
212 res.setbodybytes('0\n%s\n' % b'Not Found')
212 res.setbodybytes('0\n%s\n' % b'Not Found')
213 return True
213 return True
214
214
215 proto = httpv1protocolhandler(req, repo.ui,
215 proto = httpv1protocolhandler(req, repo.ui,
216 lambda perm: checkperm(rctx, req, perm))
216 lambda perm: checkperm(rctx, req, perm))
217
217
218 # The permissions checker should be the only thing that can raise an
218 # The permissions checker should be the only thing that can raise an
219 # ErrorResponse. It is kind of a layer violation to catch an hgweb
219 # ErrorResponse. It is kind of a layer violation to catch an hgweb
220 # exception here. So consider refactoring into a exception type that
220 # exception here. So consider refactoring into a exception type that
221 # is associated with the wire protocol.
221 # is associated with the wire protocol.
222 try:
222 try:
223 _callhttp(repo, req, res, proto, cmd)
223 _callhttp(repo, req, res, proto, cmd)
224 except hgwebcommon.ErrorResponse as e:
224 except hgwebcommon.ErrorResponse as e:
225 for k, v in e.headers:
225 for k, v in e.headers:
226 res.headers[k] = v
226 res.headers[k] = v
227 res.status = hgwebcommon.statusmessage(e.code, pycompat.bytestr(e))
227 res.status = hgwebcommon.statusmessage(e.code, pycompat.bytestr(e))
228 # TODO This response body assumes the failed command was
228 # TODO This response body assumes the failed command was
229 # "unbundle." That assumption is not always valid.
229 # "unbundle." That assumption is not always valid.
230 res.setbodybytes('0\n%s\n' % pycompat.bytestr(e))
230 res.setbodybytes('0\n%s\n' % pycompat.bytestr(e))
231
231
232 return True
232 return True
233
233
234 def _availableapis(repo):
234 def _availableapis(repo):
235 apis = set()
235 apis = set()
236
236
237 # Registered APIs are made available via config options of the name of
237 # Registered APIs are made available via config options of the name of
238 # the protocol.
238 # the protocol.
239 for k, v in API_HANDLERS.items():
239 for k, v in API_HANDLERS.items():
240 section, option = v['config']
240 section, option = v['config']
241 if repo.ui.configbool(section, option):
241 if repo.ui.configbool(section, option):
242 apis.add(k)
242 apis.add(k)
243
243
244 return apis
244 return apis
245
245
246 def handlewsgiapirequest(rctx, req, res, checkperm):
246 def handlewsgiapirequest(rctx, req, res, checkperm):
247 """Handle requests to /api/*."""
247 """Handle requests to /api/*."""
248 assert req.dispatchparts[0] == b'api'
248 assert req.dispatchparts[0] == b'api'
249
249
250 repo = rctx.repo
250 repo = rctx.repo
251
251
252 # This whole URL space is experimental for now. But we want to
252 # This whole URL space is experimental for now. But we want to
253 # reserve the URL space. So, 404 all URLs if the feature isn't enabled.
253 # reserve the URL space. So, 404 all URLs if the feature isn't enabled.
254 if not repo.ui.configbool('experimental', 'web.apiserver'):
254 if not repo.ui.configbool('experimental', 'web.apiserver'):
255 res.status = b'404 Not Found'
255 res.status = b'404 Not Found'
256 res.headers[b'Content-Type'] = b'text/plain'
256 res.headers[b'Content-Type'] = b'text/plain'
257 res.setbodybytes(_('Experimental API server endpoint not enabled'))
257 res.setbodybytes(_('Experimental API server endpoint not enabled'))
258 return
258 return
259
259
260 # The URL space is /api/<protocol>/*. The structure of URLs under varies
260 # The URL space is /api/<protocol>/*. The structure of URLs under varies
261 # by <protocol>.
261 # by <protocol>.
262
262
263 availableapis = _availableapis(repo)
263 availableapis = _availableapis(repo)
264
264
265 # Requests to /api/ list available APIs.
265 # Requests to /api/ list available APIs.
266 if req.dispatchparts == [b'api']:
266 if req.dispatchparts == [b'api']:
267 res.status = b'200 OK'
267 res.status = b'200 OK'
268 res.headers[b'Content-Type'] = b'text/plain'
268 res.headers[b'Content-Type'] = b'text/plain'
269 lines = [_('APIs can be accessed at /api/<name>, where <name> can be '
269 lines = [_('APIs can be accessed at /api/<name>, where <name> can be '
270 'one of the following:\n')]
270 'one of the following:\n')]
271 if availableapis:
271 if availableapis:
272 lines.extend(sorted(availableapis))
272 lines.extend(sorted(availableapis))
273 else:
273 else:
274 lines.append(_('(no available APIs)\n'))
274 lines.append(_('(no available APIs)\n'))
275 res.setbodybytes(b'\n'.join(lines))
275 res.setbodybytes(b'\n'.join(lines))
276 return
276 return
277
277
278 proto = req.dispatchparts[1]
278 proto = req.dispatchparts[1]
279
279
280 if proto not in API_HANDLERS:
280 if proto not in API_HANDLERS:
281 res.status = b'404 Not Found'
281 res.status = b'404 Not Found'
282 res.headers[b'Content-Type'] = b'text/plain'
282 res.headers[b'Content-Type'] = b'text/plain'
283 res.setbodybytes(_('Unknown API: %s\nKnown APIs: %s') % (
283 res.setbodybytes(_('Unknown API: %s\nKnown APIs: %s') % (
284 proto, b', '.join(sorted(availableapis))))
284 proto, b', '.join(sorted(availableapis))))
285 return
285 return
286
286
287 if proto not in availableapis:
287 if proto not in availableapis:
288 res.status = b'404 Not Found'
288 res.status = b'404 Not Found'
289 res.headers[b'Content-Type'] = b'text/plain'
289 res.headers[b'Content-Type'] = b'text/plain'
290 res.setbodybytes(_('API %s not enabled\n') % proto)
290 res.setbodybytes(_('API %s not enabled\n') % proto)
291 return
291 return
292
292
293 API_HANDLERS[proto]['handler'](rctx, req, res, checkperm,
293 API_HANDLERS[proto]['handler'](rctx, req, res, checkperm,
294 req.dispatchparts[2:])
294 req.dispatchparts[2:])
295
295
296 # Maps API name to metadata so custom API can be registered.
296 # Maps API name to metadata so custom API can be registered.
297 # Keys are:
297 # Keys are:
298 #
298 #
299 # config
299 # config
300 # Config option that controls whether service is enabled.
300 # Config option that controls whether service is enabled.
301 # handler
301 # handler
302 # Callable receiving (rctx, req, res, checkperm, urlparts) that is called
302 # Callable receiving (rctx, req, res, checkperm, urlparts) that is called
303 # when a request to this API is received.
303 # when a request to this API is received.
304 # apidescriptor
304 # apidescriptor
305 # Callable receiving (req, repo) that is called to obtain an API
305 # Callable receiving (req, repo) that is called to obtain an API
306 # descriptor for this service. The response must be serializable to CBOR.
306 # descriptor for this service. The response must be serializable to CBOR.
307 API_HANDLERS = {
307 API_HANDLERS = {
308 wireprotov2server.HTTP_WIREPROTO_V2: {
308 wireprotov2server.HTTP_WIREPROTO_V2: {
309 'config': ('experimental', 'web.api.http-v2'),
309 'config': ('experimental', 'web.api.http-v2'),
310 'handler': wireprotov2server.handlehttpv2request,
310 'handler': wireprotov2server.handlehttpv2request,
311 'apidescriptor': wireprotov2server.httpv2apidescriptor,
311 'apidescriptor': wireprotov2server.httpv2apidescriptor,
312 },
312 },
313 }
313 }
314
314
315 def _httpresponsetype(ui, proto, prefer_uncompressed):
315 def _httpresponsetype(ui, proto, prefer_uncompressed):
316 """Determine the appropriate response type and compression settings.
316 """Determine the appropriate response type and compression settings.
317
317
318 Returns a tuple of (mediatype, compengine, engineopts).
318 Returns a tuple of (mediatype, compengine, engineopts).
319 """
319 """
320 # Determine the response media type and compression engine based
320 # Determine the response media type and compression engine based
321 # on the request parameters.
321 # on the request parameters.
322
322
323 if '0.2' in proto.getprotocaps():
323 if '0.2' in proto.getprotocaps():
324 # All clients are expected to support uncompressed data.
324 # All clients are expected to support uncompressed data.
325 if prefer_uncompressed:
325 if prefer_uncompressed:
326 return HGTYPE2, compression._noopengine(), {}
326 return HGTYPE2, compression._noopengine(), {}
327
327
328 # Now find an agreed upon compression format.
328 # Now find an agreed upon compression format.
329 compformats = wireprotov1server.clientcompressionsupport(proto)
329 compformats = wireprotov1server.clientcompressionsupport(proto)
330 for engine in wireprototypes.supportedcompengines(ui,
330 for engine in wireprototypes.supportedcompengines(ui,
331 compression.SERVERROLE):
331 compression.SERVERROLE):
332 if engine.wireprotosupport().name in compformats:
332 if engine.wireprotosupport().name in compformats:
333 opts = {}
333 opts = {}
334 level = ui.configint('server', '%slevel' % engine.name())
334 level = ui.configint('server', '%slevel' % engine.name())
335 if level is not None:
335 if level is not None:
336 opts['level'] = level
336 opts['level'] = level
337
337
338 return HGTYPE2, engine, opts
338 return HGTYPE2, engine, opts
339
339
340 # No mutually supported compression format. Fall back to the
340 # No mutually supported compression format. Fall back to the
341 # legacy protocol.
341 # legacy protocol.
342
342
343 # Don't allow untrusted settings because disabling compression or
343 # Don't allow untrusted settings because disabling compression or
344 # setting a very high compression level could lead to flooding
344 # setting a very high compression level could lead to flooding
345 # the server's network or CPU.
345 # the server's network or CPU.
346 opts = {'level': ui.configint('server', 'zliblevel')}
346 opts = {'level': ui.configint('server', 'zliblevel')}
347 return HGTYPE, util.compengines['zlib'], opts
347 return HGTYPE, util.compengines['zlib'], opts
348
348
349 def processcapabilitieshandshake(repo, req, res, proto):
349 def processcapabilitieshandshake(repo, req, res, proto):
350 """Called during a ?cmd=capabilities request.
350 """Called during a ?cmd=capabilities request.
351
351
352 If the client is advertising support for a newer protocol, we send
352 If the client is advertising support for a newer protocol, we send
353 a CBOR response with information about available services. If no
353 a CBOR response with information about available services. If no
354 advertised services are available, we don't handle the request.
354 advertised services are available, we don't handle the request.
355 """
355 """
356 # Fall back to old behavior unless the API server is enabled.
356 # Fall back to old behavior unless the API server is enabled.
357 if not repo.ui.configbool('experimental', 'web.apiserver'):
357 if not repo.ui.configbool('experimental', 'web.apiserver'):
358 return False
358 return False
359
359
360 clientapis = decodevaluefromheaders(req, b'X-HgUpgrade')
360 clientapis = decodevaluefromheaders(req, b'X-HgUpgrade')
361 protocaps = decodevaluefromheaders(req, b'X-HgProto')
361 protocaps = decodevaluefromheaders(req, b'X-HgProto')
362 if not clientapis or not protocaps:
362 if not clientapis or not protocaps:
363 return False
363 return False
364
364
365 # We currently only support CBOR responses.
365 # We currently only support CBOR responses.
366 protocaps = set(protocaps.split(' '))
366 protocaps = set(protocaps.split(' '))
367 if b'cbor' not in protocaps:
367 if b'cbor' not in protocaps:
368 return False
368 return False
369
369
370 descriptors = {}
370 descriptors = {}
371
371
372 for api in sorted(set(clientapis.split()) & _availableapis(repo)):
372 for api in sorted(set(clientapis.split()) & _availableapis(repo)):
373 handler = API_HANDLERS[api]
373 handler = API_HANDLERS[api]
374
374
375 descriptorfn = handler.get('apidescriptor')
375 descriptorfn = handler.get('apidescriptor')
376 if not descriptorfn:
376 if not descriptorfn:
377 continue
377 continue
378
378
379 descriptors[api] = descriptorfn(req, repo)
379 descriptors[api] = descriptorfn(req, repo)
380
380
381 v1caps = wireprotov1server.dispatch(repo, proto, 'capabilities')
381 v1caps = wireprotov1server.dispatch(repo, proto, 'capabilities')
382 assert isinstance(v1caps, wireprototypes.bytesresponse)
382 assert isinstance(v1caps, wireprototypes.bytesresponse)
383
383
384 m = {
384 m = {
385 # TODO allow this to be configurable.
385 # TODO allow this to be configurable.
386 'apibase': 'api/',
386 'apibase': 'api/',
387 'apis': descriptors,
387 'apis': descriptors,
388 'v1capabilities': v1caps.data,
388 'v1capabilities': v1caps.data,
389 }
389 }
390
390
391 res.status = b'200 OK'
391 res.status = b'200 OK'
392 res.headers[b'Content-Type'] = b'application/mercurial-cbor'
392 res.headers[b'Content-Type'] = b'application/mercurial-cbor'
393 res.setbodybytes(b''.join(cborutil.streamencode(m)))
393 res.setbodybytes(b''.join(cborutil.streamencode(m)))
394
394
395 return True
395 return True
396
396
397 def _callhttp(repo, req, res, proto, cmd):
397 def _callhttp(repo, req, res, proto, cmd):
398 # Avoid cycle involving hg module.
398 # Avoid cycle involving hg module.
399 from .hgweb import common as hgwebcommon
399 from .hgweb import common as hgwebcommon
400
400
401 def genversion2(gen, engine, engineopts):
401 def genversion2(gen, engine, engineopts):
402 # application/mercurial-0.2 always sends a payload header
402 # application/mercurial-0.2 always sends a payload header
403 # identifying the compression engine.
403 # identifying the compression engine.
404 name = engine.wireprotosupport().name
404 name = engine.wireprotosupport().name
405 assert 0 < len(name) < 256
405 assert 0 < len(name) < 256
406 yield struct.pack('B', len(name))
406 yield struct.pack('B', len(name))
407 yield name
407 yield name
408
408
409 for chunk in gen:
409 for chunk in gen:
410 yield chunk
410 yield chunk
411
411
412 def setresponse(code, contenttype, bodybytes=None, bodygen=None):
412 def setresponse(code, contenttype, bodybytes=None, bodygen=None):
413 if code == HTTP_OK:
413 if code == HTTP_OK:
414 res.status = '200 Script output follows'
414 res.status = '200 Script output follows'
415 else:
415 else:
416 res.status = hgwebcommon.statusmessage(code)
416 res.status = hgwebcommon.statusmessage(code)
417
417
418 res.headers['Content-Type'] = contenttype
418 res.headers['Content-Type'] = contenttype
419
419
420 if bodybytes is not None:
420 if bodybytes is not None:
421 res.setbodybytes(bodybytes)
421 res.setbodybytes(bodybytes)
422 if bodygen is not None:
422 if bodygen is not None:
423 res.setbodygen(bodygen)
423 res.setbodygen(bodygen)
424
424
425 if not wireprotov1server.commands.commandavailable(cmd, proto):
425 if not wireprotov1server.commands.commandavailable(cmd, proto):
426 setresponse(HTTP_OK, HGERRTYPE,
426 setresponse(HTTP_OK, HGERRTYPE,
427 _('requested wire protocol command is not available over '
427 _('requested wire protocol command is not available over '
428 'HTTP'))
428 'HTTP'))
429 return
429 return
430
430
431 proto.checkperm(wireprotov1server.commands[cmd].permission)
431 proto.checkperm(wireprotov1server.commands[cmd].permission)
432
432
433 # Possibly handle a modern client wanting to switch protocols.
433 # Possibly handle a modern client wanting to switch protocols.
434 if (cmd == 'capabilities' and
434 if (cmd == 'capabilities' and
435 processcapabilitieshandshake(repo, req, res, proto)):
435 processcapabilitieshandshake(repo, req, res, proto)):
436
436
437 return
437 return
438
438
439 rsp = wireprotov1server.dispatch(repo, proto, cmd)
439 rsp = wireprotov1server.dispatch(repo, proto, cmd)
440
440
441 if isinstance(rsp, bytes):
441 if isinstance(rsp, bytes):
442 setresponse(HTTP_OK, HGTYPE, bodybytes=rsp)
442 setresponse(HTTP_OK, HGTYPE, bodybytes=rsp)
443 elif isinstance(rsp, wireprototypes.bytesresponse):
443 elif isinstance(rsp, wireprototypes.bytesresponse):
444 setresponse(HTTP_OK, HGTYPE, bodybytes=rsp.data)
444 setresponse(HTTP_OK, HGTYPE, bodybytes=rsp.data)
445 elif isinstance(rsp, wireprototypes.streamreslegacy):
445 elif isinstance(rsp, wireprototypes.streamreslegacy):
446 setresponse(HTTP_OK, HGTYPE, bodygen=rsp.gen)
446 setresponse(HTTP_OK, HGTYPE, bodygen=rsp.gen)
447 elif isinstance(rsp, wireprototypes.streamres):
447 elif isinstance(rsp, wireprototypes.streamres):
448 gen = rsp.gen
448 gen = rsp.gen
449
449
450 # This code for compression should not be streamres specific. It
450 # This code for compression should not be streamres specific. It
451 # is here because we only compress streamres at the moment.
451 # is here because we only compress streamres at the moment.
452 mediatype, engine, engineopts = _httpresponsetype(
452 mediatype, engine, engineopts = _httpresponsetype(
453 repo.ui, proto, rsp.prefer_uncompressed)
453 repo.ui, proto, rsp.prefer_uncompressed)
454 gen = engine.compressstream(gen, engineopts)
454 gen = engine.compressstream(gen, engineopts)
455
455
456 if mediatype == HGTYPE2:
456 if mediatype == HGTYPE2:
457 gen = genversion2(gen, engine, engineopts)
457 gen = genversion2(gen, engine, engineopts)
458
458
459 setresponse(HTTP_OK, mediatype, bodygen=gen)
459 setresponse(HTTP_OK, mediatype, bodygen=gen)
460 elif isinstance(rsp, wireprototypes.pushres):
460 elif isinstance(rsp, wireprototypes.pushres):
461 rsp = '%d\n%s' % (rsp.res, rsp.output)
461 rsp = '%d\n%s' % (rsp.res, rsp.output)
462 setresponse(HTTP_OK, HGTYPE, bodybytes=rsp)
462 setresponse(HTTP_OK, HGTYPE, bodybytes=rsp)
463 elif isinstance(rsp, wireprototypes.pusherr):
463 elif isinstance(rsp, wireprototypes.pusherr):
464 rsp = '0\n%s\n' % rsp.res
464 rsp = '0\n%s\n' % rsp.res
465 res.drain = True
465 res.drain = True
466 setresponse(HTTP_OK, HGTYPE, bodybytes=rsp)
466 setresponse(HTTP_OK, HGTYPE, bodybytes=rsp)
467 elif isinstance(rsp, wireprototypes.ooberror):
467 elif isinstance(rsp, wireprototypes.ooberror):
468 setresponse(HTTP_OK, HGERRTYPE, bodybytes=rsp.message)
468 setresponse(HTTP_OK, HGERRTYPE, bodybytes=rsp.message)
469 else:
469 else:
470 raise error.ProgrammingError('hgweb.protocol internal failure', rsp)
470 raise error.ProgrammingError('hgweb.protocol internal failure', rsp)
471
471
472 def _sshv1respondbytes(fout, value):
472 def _sshv1respondbytes(fout, value):
473 """Send a bytes response for protocol version 1."""
473 """Send a bytes response for protocol version 1."""
474 fout.write('%d\n' % len(value))
474 fout.write('%d\n' % len(value))
475 fout.write(value)
475 fout.write(value)
476 fout.flush()
476 fout.flush()
477
477
478 def _sshv1respondstream(fout, source):
478 def _sshv1respondstream(fout, source):
479 write = fout.write
479 write = fout.write
480 for chunk in source.gen:
480 for chunk in source.gen:
481 write(chunk)
481 write(chunk)
482 fout.flush()
482 fout.flush()
483
483
484 def _sshv1respondooberror(fout, ferr, rsp):
484 def _sshv1respondooberror(fout, ferr, rsp):
485 ferr.write(b'%s\n-\n' % rsp)
485 ferr.write(b'%s\n-\n' % rsp)
486 ferr.flush()
486 ferr.flush()
487 fout.write(b'\n')
487 fout.write(b'\n')
488 fout.flush()
488 fout.flush()
489
489
490 @interfaceutil.implementer(wireprototypes.baseprotocolhandler)
490 @interfaceutil.implementer(wireprototypes.baseprotocolhandler)
491 class sshv1protocolhandler(object):
491 class sshv1protocolhandler(object):
492 """Handler for requests services via version 1 of SSH protocol."""
492 """Handler for requests services via version 1 of SSH protocol."""
493 def __init__(self, ui, fin, fout):
493 def __init__(self, ui, fin, fout):
494 self._ui = ui
494 self._ui = ui
495 self._fin = fin
495 self._fin = fin
496 self._fout = fout
496 self._fout = fout
497 self._protocaps = set()
497 self._protocaps = set()
498
498
499 @property
499 @property
500 def name(self):
500 def name(self):
501 return wireprototypes.SSHV1
501 return wireprototypes.SSHV1
502
502
503 def getargs(self, args):
503 def getargs(self, args):
504 data = {}
504 data = {}
505 keys = args.split()
505 keys = args.split()
506 for n in pycompat.xrange(len(keys)):
506 for n in pycompat.xrange(len(keys)):
507 argline = self._fin.readline()[:-1]
507 argline = self._fin.readline()[:-1]
508 arg, l = argline.split()
508 arg, l = argline.split()
509 if arg not in keys:
509 if arg not in keys:
510 raise error.Abort(_("unexpected parameter %r") % arg)
510 raise error.Abort(_("unexpected parameter %r") % arg)
511 if arg == '*':
511 if arg == '*':
512 star = {}
512 star = {}
513 for k in pycompat.xrange(int(l)):
513 for k in pycompat.xrange(int(l)):
514 argline = self._fin.readline()[:-1]
514 argline = self._fin.readline()[:-1]
515 arg, l = argline.split()
515 arg, l = argline.split()
516 val = self._fin.read(int(l))
516 val = self._fin.read(int(l))
517 star[arg] = val
517 star[arg] = val
518 data['*'] = star
518 data['*'] = star
519 else:
519 else:
520 val = self._fin.read(int(l))
520 val = self._fin.read(int(l))
521 data[arg] = val
521 data[arg] = val
522 return [data[k] for k in keys]
522 return [data[k] for k in keys]
523
523
524 def getprotocaps(self):
524 def getprotocaps(self):
525 return self._protocaps
525 return self._protocaps
526
526
527 def getpayload(self):
527 def getpayload(self):
528 # We initially send an empty response. This tells the client it is
528 # We initially send an empty response. This tells the client it is
529 # OK to start sending data. If a client sees any other response, it
529 # OK to start sending data. If a client sees any other response, it
530 # interprets it as an error.
530 # interprets it as an error.
531 _sshv1respondbytes(self._fout, b'')
531 _sshv1respondbytes(self._fout, b'')
532
532
533 # The file is in the form:
533 # The file is in the form:
534 #
534 #
535 # <chunk size>\n<chunk>
535 # <chunk size>\n<chunk>
536 # ...
536 # ...
537 # 0\n
537 # 0\n
538 count = int(self._fin.readline())
538 count = int(self._fin.readline())
539 while count:
539 while count:
540 yield self._fin.read(count)
540 yield self._fin.read(count)
541 count = int(self._fin.readline())
541 count = int(self._fin.readline())
542
542
543 @contextlib.contextmanager
543 @contextlib.contextmanager
544 def mayberedirectstdio(self):
544 def mayberedirectstdio(self):
545 yield None
545 yield None
546
546
547 def client(self):
547 def client(self):
548 client = encoding.environ.get('SSH_CLIENT', '').split(' ', 1)[0]
548 client = encoding.environ.get('SSH_CLIENT', '').split(' ', 1)[0]
549 return 'remote:ssh:' + client
549 return 'remote:ssh:' + client
550
550
551 def addcapabilities(self, repo, caps):
551 def addcapabilities(self, repo, caps):
552 if self.name == wireprototypes.SSHV1:
552 if self.name == wireprototypes.SSHV1:
553 caps.append(b'protocaps')
553 caps.append(b'protocaps')
554 caps.append(b'batch')
554 caps.append(b'batch')
555 return caps
555 return caps
556
556
557 def checkperm(self, perm):
557 def checkperm(self, perm):
558 pass
558 pass
559
559
560 class sshv2protocolhandler(sshv1protocolhandler):
560 class sshv2protocolhandler(sshv1protocolhandler):
561 """Protocol handler for version 2 of the SSH protocol."""
561 """Protocol handler for version 2 of the SSH protocol."""
562
562
563 @property
563 @property
564 def name(self):
564 def name(self):
565 return wireprototypes.SSHV2
565 return wireprototypes.SSHV2
566
566
567 def addcapabilities(self, repo, caps):
567 def addcapabilities(self, repo, caps):
568 return caps
568 return caps
569
569
570 def _runsshserver(ui, repo, fin, fout, ev):
570 def _runsshserver(ui, repo, fin, fout, ev):
571 # This function operates like a state machine of sorts. The following
571 # This function operates like a state machine of sorts. The following
572 # states are defined:
572 # states are defined:
573 #
573 #
574 # protov1-serving
574 # protov1-serving
575 # Server is in protocol version 1 serving mode. Commands arrive on
575 # Server is in protocol version 1 serving mode. Commands arrive on
576 # new lines. These commands are processed in this state, one command
576 # new lines. These commands are processed in this state, one command
577 # after the other.
577 # after the other.
578 #
578 #
579 # protov2-serving
579 # protov2-serving
580 # Server is in protocol version 2 serving mode.
580 # Server is in protocol version 2 serving mode.
581 #
581 #
582 # upgrade-initial
582 # upgrade-initial
583 # The server is going to process an upgrade request.
583 # The server is going to process an upgrade request.
584 #
584 #
585 # upgrade-v2-filter-legacy-handshake
585 # upgrade-v2-filter-legacy-handshake
586 # The protocol is being upgraded to version 2. The server is expecting
586 # The protocol is being upgraded to version 2. The server is expecting
587 # the legacy handshake from version 1.
587 # the legacy handshake from version 1.
588 #
588 #
589 # upgrade-v2-finish
589 # upgrade-v2-finish
590 # The upgrade to version 2 of the protocol is imminent.
590 # The upgrade to version 2 of the protocol is imminent.
591 #
591 #
592 # shutdown
592 # shutdown
593 # The server is shutting down, possibly in reaction to a client event.
593 # The server is shutting down, possibly in reaction to a client event.
594 #
594 #
595 # And here are their transitions:
595 # And here are their transitions:
596 #
596 #
597 # protov1-serving -> shutdown
597 # protov1-serving -> shutdown
598 # When server receives an empty request or encounters another
598 # When server receives an empty request or encounters another
599 # error.
599 # error.
600 #
600 #
601 # protov1-serving -> upgrade-initial
601 # protov1-serving -> upgrade-initial
602 # An upgrade request line was seen.
602 # An upgrade request line was seen.
603 #
603 #
604 # upgrade-initial -> upgrade-v2-filter-legacy-handshake
604 # upgrade-initial -> upgrade-v2-filter-legacy-handshake
605 # Upgrade to version 2 in progress. Server is expecting to
605 # Upgrade to version 2 in progress. Server is expecting to
606 # process a legacy handshake.
606 # process a legacy handshake.
607 #
607 #
608 # upgrade-v2-filter-legacy-handshake -> shutdown
608 # upgrade-v2-filter-legacy-handshake -> shutdown
609 # Client did not fulfill upgrade handshake requirements.
609 # Client did not fulfill upgrade handshake requirements.
610 #
610 #
611 # upgrade-v2-filter-legacy-handshake -> upgrade-v2-finish
611 # upgrade-v2-filter-legacy-handshake -> upgrade-v2-finish
612 # Client fulfilled version 2 upgrade requirements. Finishing that
612 # Client fulfilled version 2 upgrade requirements. Finishing that
613 # upgrade.
613 # upgrade.
614 #
614 #
615 # upgrade-v2-finish -> protov2-serving
615 # upgrade-v2-finish -> protov2-serving
616 # Protocol upgrade to version 2 complete. Server can now speak protocol
616 # Protocol upgrade to version 2 complete. Server can now speak protocol
617 # version 2.
617 # version 2.
618 #
618 #
619 # protov2-serving -> protov1-serving
619 # protov2-serving -> protov1-serving
620 # Ths happens by default since protocol version 2 is the same as
620 # Ths happens by default since protocol version 2 is the same as
621 # version 1 except for the handshake.
621 # version 1 except for the handshake.
622
622
623 state = 'protov1-serving'
623 state = 'protov1-serving'
624 proto = sshv1protocolhandler(ui, fin, fout)
624 proto = sshv1protocolhandler(ui, fin, fout)
625 protoswitched = False
625 protoswitched = False
626
626
627 while not ev.is_set():
627 while not ev.is_set():
628 if state == 'protov1-serving':
628 if state == 'protov1-serving':
629 # Commands are issued on new lines.
629 # Commands are issued on new lines.
630 request = fin.readline()[:-1]
630 request = fin.readline()[:-1]
631
631
632 # Empty lines signal to terminate the connection.
632 # Empty lines signal to terminate the connection.
633 if not request:
633 if not request:
634 state = 'shutdown'
634 state = 'shutdown'
635 continue
635 continue
636
636
637 # It looks like a protocol upgrade request. Transition state to
637 # It looks like a protocol upgrade request. Transition state to
638 # handle it.
638 # handle it.
639 if request.startswith(b'upgrade '):
639 if request.startswith(b'upgrade '):
640 if protoswitched:
640 if protoswitched:
641 _sshv1respondooberror(fout, ui.ferr,
641 _sshv1respondooberror(fout, ui.ferr,
642 b'cannot upgrade protocols multiple '
642 b'cannot upgrade protocols multiple '
643 b'times')
643 b'times')
644 state = 'shutdown'
644 state = 'shutdown'
645 continue
645 continue
646
646
647 state = 'upgrade-initial'
647 state = 'upgrade-initial'
648 continue
648 continue
649
649
650 available = wireprotov1server.commands.commandavailable(
650 available = wireprotov1server.commands.commandavailable(
651 request, proto)
651 request, proto)
652
652
653 # This command isn't available. Send an empty response and go
653 # This command isn't available. Send an empty response and go
654 # back to waiting for a new command.
654 # back to waiting for a new command.
655 if not available:
655 if not available:
656 _sshv1respondbytes(fout, b'')
656 _sshv1respondbytes(fout, b'')
657 continue
657 continue
658
658
659 rsp = wireprotov1server.dispatch(repo, proto, request)
659 rsp = wireprotov1server.dispatch(repo, proto, request)
660 repo.ui.fout.flush()
661 repo.ui.ferr.flush()
660
662
661 if isinstance(rsp, bytes):
663 if isinstance(rsp, bytes):
662 _sshv1respondbytes(fout, rsp)
664 _sshv1respondbytes(fout, rsp)
663 elif isinstance(rsp, wireprototypes.bytesresponse):
665 elif isinstance(rsp, wireprototypes.bytesresponse):
664 _sshv1respondbytes(fout, rsp.data)
666 _sshv1respondbytes(fout, rsp.data)
665 elif isinstance(rsp, wireprototypes.streamres):
667 elif isinstance(rsp, wireprototypes.streamres):
666 _sshv1respondstream(fout, rsp)
668 _sshv1respondstream(fout, rsp)
667 elif isinstance(rsp, wireprototypes.streamreslegacy):
669 elif isinstance(rsp, wireprototypes.streamreslegacy):
668 _sshv1respondstream(fout, rsp)
670 _sshv1respondstream(fout, rsp)
669 elif isinstance(rsp, wireprototypes.pushres):
671 elif isinstance(rsp, wireprototypes.pushres):
670 _sshv1respondbytes(fout, b'')
672 _sshv1respondbytes(fout, b'')
671 _sshv1respondbytes(fout, b'%d' % rsp.res)
673 _sshv1respondbytes(fout, b'%d' % rsp.res)
672 elif isinstance(rsp, wireprototypes.pusherr):
674 elif isinstance(rsp, wireprototypes.pusherr):
673 _sshv1respondbytes(fout, rsp.res)
675 _sshv1respondbytes(fout, rsp.res)
674 elif isinstance(rsp, wireprototypes.ooberror):
676 elif isinstance(rsp, wireprototypes.ooberror):
675 _sshv1respondooberror(fout, ui.ferr, rsp.message)
677 _sshv1respondooberror(fout, ui.ferr, rsp.message)
676 else:
678 else:
677 raise error.ProgrammingError('unhandled response type from '
679 raise error.ProgrammingError('unhandled response type from '
678 'wire protocol command: %s' % rsp)
680 'wire protocol command: %s' % rsp)
679
681
680 # For now, protocol version 2 serving just goes back to version 1.
682 # For now, protocol version 2 serving just goes back to version 1.
681 elif state == 'protov2-serving':
683 elif state == 'protov2-serving':
682 state = 'protov1-serving'
684 state = 'protov1-serving'
683 continue
685 continue
684
686
685 elif state == 'upgrade-initial':
687 elif state == 'upgrade-initial':
686 # We should never transition into this state if we've switched
688 # We should never transition into this state if we've switched
687 # protocols.
689 # protocols.
688 assert not protoswitched
690 assert not protoswitched
689 assert proto.name == wireprototypes.SSHV1
691 assert proto.name == wireprototypes.SSHV1
690
692
691 # Expected: upgrade <token> <capabilities>
693 # Expected: upgrade <token> <capabilities>
692 # If we get something else, the request is malformed. It could be
694 # If we get something else, the request is malformed. It could be
693 # from a future client that has altered the upgrade line content.
695 # from a future client that has altered the upgrade line content.
694 # We treat this as an unknown command.
696 # We treat this as an unknown command.
695 try:
697 try:
696 token, caps = request.split(b' ')[1:]
698 token, caps = request.split(b' ')[1:]
697 except ValueError:
699 except ValueError:
698 _sshv1respondbytes(fout, b'')
700 _sshv1respondbytes(fout, b'')
699 state = 'protov1-serving'
701 state = 'protov1-serving'
700 continue
702 continue
701
703
702 # Send empty response if we don't support upgrading protocols.
704 # Send empty response if we don't support upgrading protocols.
703 if not ui.configbool('experimental', 'sshserver.support-v2'):
705 if not ui.configbool('experimental', 'sshserver.support-v2'):
704 _sshv1respondbytes(fout, b'')
706 _sshv1respondbytes(fout, b'')
705 state = 'protov1-serving'
707 state = 'protov1-serving'
706 continue
708 continue
707
709
708 try:
710 try:
709 caps = urlreq.parseqs(caps)
711 caps = urlreq.parseqs(caps)
710 except ValueError:
712 except ValueError:
711 _sshv1respondbytes(fout, b'')
713 _sshv1respondbytes(fout, b'')
712 state = 'protov1-serving'
714 state = 'protov1-serving'
713 continue
715 continue
714
716
715 # We don't see an upgrade request to protocol version 2. Ignore
717 # We don't see an upgrade request to protocol version 2. Ignore
716 # the upgrade request.
718 # the upgrade request.
717 wantedprotos = caps.get(b'proto', [b''])[0]
719 wantedprotos = caps.get(b'proto', [b''])[0]
718 if SSHV2 not in wantedprotos:
720 if SSHV2 not in wantedprotos:
719 _sshv1respondbytes(fout, b'')
721 _sshv1respondbytes(fout, b'')
720 state = 'protov1-serving'
722 state = 'protov1-serving'
721 continue
723 continue
722
724
723 # It looks like we can honor this upgrade request to protocol 2.
725 # It looks like we can honor this upgrade request to protocol 2.
724 # Filter the rest of the handshake protocol request lines.
726 # Filter the rest of the handshake protocol request lines.
725 state = 'upgrade-v2-filter-legacy-handshake'
727 state = 'upgrade-v2-filter-legacy-handshake'
726 continue
728 continue
727
729
728 elif state == 'upgrade-v2-filter-legacy-handshake':
730 elif state == 'upgrade-v2-filter-legacy-handshake':
729 # Client should have sent legacy handshake after an ``upgrade``
731 # Client should have sent legacy handshake after an ``upgrade``
730 # request. Expected lines:
732 # request. Expected lines:
731 #
733 #
732 # hello
734 # hello
733 # between
735 # between
734 # pairs 81
736 # pairs 81
735 # 0000...-0000...
737 # 0000...-0000...
736
738
737 ok = True
739 ok = True
738 for line in (b'hello', b'between', b'pairs 81'):
740 for line in (b'hello', b'between', b'pairs 81'):
739 request = fin.readline()[:-1]
741 request = fin.readline()[:-1]
740
742
741 if request != line:
743 if request != line:
742 _sshv1respondooberror(fout, ui.ferr,
744 _sshv1respondooberror(fout, ui.ferr,
743 b'malformed handshake protocol: '
745 b'malformed handshake protocol: '
744 b'missing %s' % line)
746 b'missing %s' % line)
745 ok = False
747 ok = False
746 state = 'shutdown'
748 state = 'shutdown'
747 break
749 break
748
750
749 if not ok:
751 if not ok:
750 continue
752 continue
751
753
752 request = fin.read(81)
754 request = fin.read(81)
753 if request != b'%s-%s' % (b'0' * 40, b'0' * 40):
755 if request != b'%s-%s' % (b'0' * 40, b'0' * 40):
754 _sshv1respondooberror(fout, ui.ferr,
756 _sshv1respondooberror(fout, ui.ferr,
755 b'malformed handshake protocol: '
757 b'malformed handshake protocol: '
756 b'missing between argument value')
758 b'missing between argument value')
757 state = 'shutdown'
759 state = 'shutdown'
758 continue
760 continue
759
761
760 state = 'upgrade-v2-finish'
762 state = 'upgrade-v2-finish'
761 continue
763 continue
762
764
763 elif state == 'upgrade-v2-finish':
765 elif state == 'upgrade-v2-finish':
764 # Send the upgrade response.
766 # Send the upgrade response.
765 fout.write(b'upgraded %s %s\n' % (token, SSHV2))
767 fout.write(b'upgraded %s %s\n' % (token, SSHV2))
766 servercaps = wireprotov1server.capabilities(repo, proto)
768 servercaps = wireprotov1server.capabilities(repo, proto)
767 rsp = b'capabilities: %s' % servercaps.data
769 rsp = b'capabilities: %s' % servercaps.data
768 fout.write(b'%d\n%s\n' % (len(rsp), rsp))
770 fout.write(b'%d\n%s\n' % (len(rsp), rsp))
769 fout.flush()
771 fout.flush()
770
772
771 proto = sshv2protocolhandler(ui, fin, fout)
773 proto = sshv2protocolhandler(ui, fin, fout)
772 protoswitched = True
774 protoswitched = True
773
775
774 state = 'protov2-serving'
776 state = 'protov2-serving'
775 continue
777 continue
776
778
777 elif state == 'shutdown':
779 elif state == 'shutdown':
778 break
780 break
779
781
780 else:
782 else:
781 raise error.ProgrammingError('unhandled ssh server state: %s' %
783 raise error.ProgrammingError('unhandled ssh server state: %s' %
782 state)
784 state)
783
785
784 class sshserver(object):
786 class sshserver(object):
785 def __init__(self, ui, repo, logfh=None):
787 def __init__(self, ui, repo, logfh=None):
786 self._ui = ui
788 self._ui = ui
787 self._repo = repo
789 self._repo = repo
788 self._fin, self._fout = ui.protectfinout()
790 self._fin, self._fout = ui.protectfinout()
789
791
790 # Log write I/O to stdout and stderr if configured.
792 # Log write I/O to stdout and stderr if configured.
791 if logfh:
793 if logfh:
792 self._fout = util.makeloggingfileobject(
794 self._fout = util.makeloggingfileobject(
793 logfh, self._fout, 'o', logdata=True)
795 logfh, self._fout, 'o', logdata=True)
794 ui.ferr = util.makeloggingfileobject(
796 ui.ferr = util.makeloggingfileobject(
795 logfh, ui.ferr, 'e', logdata=True)
797 logfh, ui.ferr, 'e', logdata=True)
796
798
797 def serve_forever(self):
799 def serve_forever(self):
798 self.serveuntil(threading.Event())
800 self.serveuntil(threading.Event())
799 self._ui.restorefinout(self._fin, self._fout)
801 self._ui.restorefinout(self._fin, self._fout)
800 sys.exit(0)
802 sys.exit(0)
801
803
802 def serveuntil(self, ev):
804 def serveuntil(self, ev):
803 """Serve until a threading.Event is set."""
805 """Serve until a threading.Event is set."""
804 _runsshserver(self._ui, self._repo, self._fin, self._fout, ev)
806 _runsshserver(self._ui, self._repo, self._fin, self._fout, ev)
@@ -1,246 +1,246 b''
1 ================================
1 ================================
2 Test corner case around bookmark
2 Test corner case around bookmark
3 ================================
3 ================================
4
4
5 This test file is meant to gather test around bookmark that are specific
5 This test file is meant to gather test around bookmark that are specific
6 enough to not find a place elsewhere.
6 enough to not find a place elsewhere.
7
7
8 Test bookmark/changelog race condition
8 Test bookmark/changelog race condition
9 ======================================
9 ======================================
10
10
11 The data from the bookmark file are filtered to only contains bookmark with
11 The data from the bookmark file are filtered to only contains bookmark with
12 node known to the changelog. If the cache invalidation between these two bits
12 node known to the changelog. If the cache invalidation between these two bits
13 goes wrong, bookmark can be dropped.
13 goes wrong, bookmark can be dropped.
14
14
15 global setup
15 global setup
16 ------------
16 ------------
17
17
18 $ cat >> $HGRCPATH << EOF
18 $ cat >> $HGRCPATH << EOF
19 > [ui]
19 > [ui]
20 > ssh = "$PYTHON" "$TESTDIR/dummyssh"
20 > ssh = "$PYTHON" "$TESTDIR/dummyssh"
21 > [server]
21 > [server]
22 > concurrent-push-mode=check-related
22 > concurrent-push-mode=check-related
23 > EOF
23 > EOF
24
24
25 Setup
25 Setup
26 -----
26 -----
27
27
28 initial repository setup
28 initial repository setup
29
29
30 $ hg init bookrace-server
30 $ hg init bookrace-server
31 $ cd bookrace-server
31 $ cd bookrace-server
32 $ echo a > a
32 $ echo a > a
33 $ hg add a
33 $ hg add a
34 $ hg commit -m root
34 $ hg commit -m root
35 $ echo a >> a
35 $ echo a >> a
36 $ hg bookmark book-A
36 $ hg bookmark book-A
37 $ hg commit -m A0
37 $ hg commit -m A0
38 $ hg up 'desc(root)'
38 $ hg up 'desc(root)'
39 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
39 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
40 (leaving bookmark book-A)
40 (leaving bookmark book-A)
41 $ echo b > b
41 $ echo b > b
42 $ hg add b
42 $ hg add b
43 $ hg bookmark book-B
43 $ hg bookmark book-B
44 $ hg commit -m B0
44 $ hg commit -m B0
45 created new head
45 created new head
46 $ hg up null
46 $ hg up null
47 0 files updated, 0 files merged, 2 files removed, 0 files unresolved
47 0 files updated, 0 files merged, 2 files removed, 0 files unresolved
48 (leaving bookmark book-B)
48 (leaving bookmark book-B)
49 $ hg phase --public --rev 'all()'
49 $ hg phase --public --rev 'all()'
50 $ hg log -G
50 $ hg log -G
51 o changeset: 2:c79985706978
51 o changeset: 2:c79985706978
52 | bookmark: book-B
52 | bookmark: book-B
53 | tag: tip
53 | tag: tip
54 | parent: 0:6569b5a81c7e
54 | parent: 0:6569b5a81c7e
55 | user: test
55 | user: test
56 | date: Thu Jan 01 00:00:00 1970 +0000
56 | date: Thu Jan 01 00:00:00 1970 +0000
57 | summary: B0
57 | summary: B0
58 |
58 |
59 | o changeset: 1:39c28d785860
59 | o changeset: 1:39c28d785860
60 |/ bookmark: book-A
60 |/ bookmark: book-A
61 | user: test
61 | user: test
62 | date: Thu Jan 01 00:00:00 1970 +0000
62 | date: Thu Jan 01 00:00:00 1970 +0000
63 | summary: A0
63 | summary: A0
64 |
64 |
65 o changeset: 0:6569b5a81c7e
65 o changeset: 0:6569b5a81c7e
66 user: test
66 user: test
67 date: Thu Jan 01 00:00:00 1970 +0000
67 date: Thu Jan 01 00:00:00 1970 +0000
68 summary: root
68 summary: root
69
69
70 $ hg book
70 $ hg book
71 book-A 1:39c28d785860
71 book-A 1:39c28d785860
72 book-B 2:c79985706978
72 book-B 2:c79985706978
73 $ cd ..
73 $ cd ..
74
74
75 Add new changeset on each bookmark in distinct clones
75 Add new changeset on each bookmark in distinct clones
76
76
77 $ hg clone ssh://user@dummy/bookrace-server client-A
77 $ hg clone ssh://user@dummy/bookrace-server client-A
78 requesting all changes
78 requesting all changes
79 adding changesets
79 adding changesets
80 adding manifests
80 adding manifests
81 adding file changes
81 adding file changes
82 added 3 changesets with 3 changes to 2 files (+1 heads)
82 added 3 changesets with 3 changes to 2 files (+1 heads)
83 new changesets 6569b5a81c7e:c79985706978
83 new changesets 6569b5a81c7e:c79985706978
84 updating to branch default
84 updating to branch default
85 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
85 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
86 $ hg -R client-A update book-A
86 $ hg -R client-A update book-A
87 1 files updated, 0 files merged, 1 files removed, 0 files unresolved
87 1 files updated, 0 files merged, 1 files removed, 0 files unresolved
88 (activating bookmark book-A)
88 (activating bookmark book-A)
89 $ echo a >> client-A/a
89 $ echo a >> client-A/a
90 $ hg -R client-A commit -m A1
90 $ hg -R client-A commit -m A1
91 $ hg clone ssh://user@dummy/bookrace-server client-B
91 $ hg clone ssh://user@dummy/bookrace-server client-B
92 requesting all changes
92 requesting all changes
93 adding changesets
93 adding changesets
94 adding manifests
94 adding manifests
95 adding file changes
95 adding file changes
96 added 3 changesets with 3 changes to 2 files (+1 heads)
96 added 3 changesets with 3 changes to 2 files (+1 heads)
97 new changesets 6569b5a81c7e:c79985706978
97 new changesets 6569b5a81c7e:c79985706978
98 updating to branch default
98 updating to branch default
99 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
99 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
100 $ hg -R client-B update book-B
100 $ hg -R client-B update book-B
101 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
101 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
102 (activating bookmark book-B)
102 (activating bookmark book-B)
103 $ echo b >> client-B/b
103 $ echo b >> client-B/b
104 $ hg -R client-B commit -m B1
104 $ hg -R client-B commit -m B1
105
105
106 extension to reproduce the race
106 extension to reproduce the race
107 -------------------------------
107 -------------------------------
108
108
109 If two process are pushing we want to make sure the following happens:
109 If two process are pushing we want to make sure the following happens:
110
110
111 * process A read changelog
111 * process A read changelog
112 * process B to its full push
112 * process B to its full push
113 * process A read bookmarks
113 * process A read bookmarks
114 * process A proceed with rest of the push
114 * process A proceed with rest of the push
115
115
116 We build a server side extension for this purpose
116 We build a server side extension for this purpose
117
117
118 $ cat > bookrace.py << EOF
118 $ cat > bookrace.py << EOF
119 > import atexit
119 > import atexit
120 > import os
120 > import os
121 > import time
121 > import time
122 > from mercurial import bookmarks, error, extensions
122 > from mercurial import bookmarks, error, extensions
123 >
123 >
124 > def wait(repo):
124 > def wait(repo):
125 > if not os.path.exists('push-A-started'):
125 > if not os.path.exists('push-A-started'):
126 > assert repo._currentlock(repo._lockref) is None
126 > assert repo._currentlock(repo._lockref) is None
127 > assert repo._currentlock(repo._wlockref) is None
127 > assert repo._currentlock(repo._wlockref) is None
128 > repo.ui.status(b'setting raced push up\n')
128 > repo.ui.status(b'setting raced push up\n')
129 > with open('push-A-started', 'w'):
129 > with open('push-A-started', 'w'):
130 > pass
130 > pass
131 > clock = 300
131 > clock = 300
132 > while not os.path.exists('push-B-done'):
132 > while not os.path.exists('push-B-done'):
133 > clock -= 1
133 > clock -= 1
134 > if clock <= 0:
134 > if clock <= 0:
135 > raise error.Abort("race scenario timed out")
135 > raise error.Abort("race scenario timed out")
136 > time.sleep(0.1)
136 > time.sleep(0.1)
137 >
137 >
138 > def reposetup(ui, repo):
138 > def reposetup(ui, repo):
139 > class racedrepo(repo.__class__):
139 > class racedrepo(repo.__class__):
140 > @property
140 > @property
141 > def _bookmarks(self):
141 > def _bookmarks(self):
142 > wait(self)
142 > wait(self)
143 > return super(racedrepo, self)._bookmarks
143 > return super(racedrepo, self)._bookmarks
144 > repo.__class__ = racedrepo
144 > repo.__class__ = racedrepo
145 >
145 >
146 > def e():
146 > def e():
147 > with open('push-A-done', 'w'):
147 > with open('push-A-done', 'w'):
148 > pass
148 > pass
149 > atexit.register(e)
149 > atexit.register(e)
150 > EOF
150 > EOF
151
151
152 Actual test
152 Actual test
153 -----------
153 -----------
154
154
155 Start the raced push.
155 Start the raced push.
156
156
157 $ cat >> bookrace-server/.hg/hgrc << EOF
157 $ cat >> bookrace-server/.hg/hgrc << EOF
158 > [extensions]
158 > [extensions]
159 > bookrace=$TESTTMP/bookrace.py
159 > bookrace=$TESTTMP/bookrace.py
160 > EOF
160 > EOF
161 $ hg push -R client-A -r book-A >push-output.txt 2>&1 &
161 $ hg push -R client-A -r book-A >push-output.txt 2>&1 &
162
162
163 Wait up to 30 seconds for that push to start.
163 Wait up to 30 seconds for that push to start.
164
164
165 $ clock=30
165 $ clock=30
166 $ while [ ! -f push-A-started ] && [ $clock -gt 0 ] ; do
166 $ while [ ! -f push-A-started ] && [ $clock -gt 0 ] ; do
167 > clock=`expr $clock - 1`
167 > clock=`expr $clock - 1`
168 > sleep 1
168 > sleep 1
169 > done
169 > done
170
170
171 Do the other push.
171 Do the other push.
172
172
173 $ cat >> bookrace-server/.hg/hgrc << EOF
173 $ cat >> bookrace-server/.hg/hgrc << EOF
174 > [extensions]
174 > [extensions]
175 > bookrace=!
175 > bookrace=!
176 > EOF
176 > EOF
177
177
178 $ hg push -R client-B -r book-B
178 $ hg push -R client-B -r book-B
179 pushing to ssh://user@dummy/bookrace-server
179 pushing to ssh://user@dummy/bookrace-server
180 searching for changes
180 searching for changes
181 remote: adding changesets
181 remote: adding changesets
182 remote: adding manifests
182 remote: adding manifests
183 remote: adding file changes
183 remote: adding file changes
184 remote: added 1 changesets with 1 changes to 1 files
184 remote: added 1 changesets with 1 changes to 1 files
185 updating bookmark book-B
185 updating bookmark book-B
186
186
187 Signal the raced put that we are done (it waits up to 30 seconds).
187 Signal the raced put that we are done (it waits up to 30 seconds).
188
188
189 $ touch push-B-done
189 $ touch push-B-done
190
190
191 Wait for the raced push to finish (with the remaning of the initial 30 seconds).
191 Wait for the raced push to finish (with the remaning of the initial 30 seconds).
192
192
193 $ while [ ! -f push-A-done ] && [ $clock -gt 0 ] ; do
193 $ while [ ! -f push-A-done ] && [ $clock -gt 0 ] ; do
194 > clock=`expr $clock - 1`
194 > clock=`expr $clock - 1`
195 > sleep 1
195 > sleep 1
196 > done
196 > done
197
197
198 Check raced push output.
198 Check raced push output.
199
199
200 $ cat push-output.txt
200 $ cat push-output.txt
201 pushing to ssh://user@dummy/bookrace-server
201 pushing to ssh://user@dummy/bookrace-server
202 searching for changes
202 searching for changes
203 remote: setting raced push up
203 remote has heads on branch 'default' that are not known locally: f26c3b5167d1
204 remote has heads on branch 'default' that are not known locally: f26c3b5167d1
204 remote: setting raced push up
205 remote: adding changesets
205 remote: adding changesets
206 remote: adding manifests
206 remote: adding manifests
207 remote: adding file changes
207 remote: adding file changes
208 remote: added 1 changesets with 1 changes to 1 files
208 remote: added 1 changesets with 1 changes to 1 files
209 updating bookmark book-A
209 updating bookmark book-A
210
210
211 Check result of the push.
211 Check result of the push.
212
212
213 $ hg -R bookrace-server log -G
213 $ hg -R bookrace-server log -G
214 o changeset: 4:9ce3b28c16de
214 o changeset: 4:9ce3b28c16de
215 | bookmark: book-A
215 | bookmark: book-A
216 | tag: tip
216 | tag: tip
217 | parent: 1:39c28d785860
217 | parent: 1:39c28d785860
218 | user: test
218 | user: test
219 | date: Thu Jan 01 00:00:00 1970 +0000
219 | date: Thu Jan 01 00:00:00 1970 +0000
220 | summary: A1
220 | summary: A1
221 |
221 |
222 | o changeset: 3:f26c3b5167d1
222 | o changeset: 3:f26c3b5167d1
223 | | bookmark: book-B
223 | | bookmark: book-B
224 | | user: test
224 | | user: test
225 | | date: Thu Jan 01 00:00:00 1970 +0000
225 | | date: Thu Jan 01 00:00:00 1970 +0000
226 | | summary: B1
226 | | summary: B1
227 | |
227 | |
228 | o changeset: 2:c79985706978
228 | o changeset: 2:c79985706978
229 | | parent: 0:6569b5a81c7e
229 | | parent: 0:6569b5a81c7e
230 | | user: test
230 | | user: test
231 | | date: Thu Jan 01 00:00:00 1970 +0000
231 | | date: Thu Jan 01 00:00:00 1970 +0000
232 | | summary: B0
232 | | summary: B0
233 | |
233 | |
234 o | changeset: 1:39c28d785860
234 o | changeset: 1:39c28d785860
235 |/ user: test
235 |/ user: test
236 | date: Thu Jan 01 00:00:00 1970 +0000
236 | date: Thu Jan 01 00:00:00 1970 +0000
237 | summary: A0
237 | summary: A0
238 |
238 |
239 o changeset: 0:6569b5a81c7e
239 o changeset: 0:6569b5a81c7e
240 user: test
240 user: test
241 date: Thu Jan 01 00:00:00 1970 +0000
241 date: Thu Jan 01 00:00:00 1970 +0000
242 summary: root
242 summary: root
243
243
244 $ hg -R bookrace-server book
244 $ hg -R bookrace-server book
245 book-A 4:9ce3b28c16de
245 book-A 4:9ce3b28c16de
246 book-B 3:f26c3b5167d1
246 book-B 3:f26c3b5167d1
@@ -1,2199 +1,2201 b''
1 #require no-chg
1 #require no-chg
2
2
3 $ cat > hgrc-sshv2 << EOF
3 $ cat > hgrc-sshv2 << EOF
4 > %include $HGRCPATH
4 > %include $HGRCPATH
5 > [experimental]
5 > [experimental]
6 > sshpeer.advertise-v2 = true
6 > sshpeer.advertise-v2 = true
7 > sshserver.support-v2 = true
7 > sshserver.support-v2 = true
8 > EOF
8 > EOF
9
9
10 Helper function to run protocol tests against multiple protocol versions.
10 Helper function to run protocol tests against multiple protocol versions.
11 This is easier than using #testcases because managing differences between
11 This is easier than using #testcases because managing differences between
12 protocols with inline conditional output is hard to read.
12 protocols with inline conditional output is hard to read.
13
13
14 $ debugwireproto() {
14 $ debugwireproto() {
15 > commands=`cat -`
15 > commands=`cat -`
16 > echo 'testing ssh1'
16 > echo 'testing ssh1'
17 > echo "${commands}" | hg --verbose debugwireproto --localssh
17 > echo "${commands}" | hg --verbose debugwireproto --localssh
18 > echo ""
18 > echo ""
19 > echo 'testing ssh2'
19 > echo 'testing ssh2'
20 > echo "${commands}" | HGRCPATH=$TESTTMP/hgrc-sshv2 hg --verbose debugwireproto --localssh
20 > echo "${commands}" | HGRCPATH=$TESTTMP/hgrc-sshv2 hg --verbose debugwireproto --localssh
21 > }
21 > }
22
22
23 $ cat >> $HGRCPATH << EOF
23 $ cat >> $HGRCPATH << EOF
24 > [ui]
24 > [ui]
25 > ssh = "$PYTHON" "$TESTDIR/dummyssh"
25 > ssh = "$PYTHON" "$TESTDIR/dummyssh"
26 > [devel]
26 > [devel]
27 > debug.peer-request = true
27 > debug.peer-request = true
28 > [extensions]
28 > [extensions]
29 > sshprotoext = $TESTDIR/sshprotoext.py
29 > sshprotoext = $TESTDIR/sshprotoext.py
30 > EOF
30 > EOF
31
31
32 $ hg init server
32 $ hg init server
33 $ cd server
33 $ cd server
34 $ echo 0 > foo
34 $ echo 0 > foo
35 $ hg -q add foo
35 $ hg -q add foo
36 $ hg commit -m initial
36 $ hg commit -m initial
37
37
38 A no-op connection performs a handshake
38 A no-op connection performs a handshake
39
39
40 $ hg debugwireproto --localssh << EOF
40 $ hg debugwireproto --localssh << EOF
41 > EOF
41 > EOF
42 creating ssh peer from handshake results
42 creating ssh peer from handshake results
43
43
44 Raw peers don't perform any activity
44 Raw peers don't perform any activity
45
45
46 $ hg debugwireproto --localssh --peer raw << EOF
46 $ hg debugwireproto --localssh --peer raw << EOF
47 > EOF
47 > EOF
48 using raw connection to peer
48 using raw connection to peer
49 $ hg debugwireproto --localssh --peer ssh1 << EOF
49 $ hg debugwireproto --localssh --peer ssh1 << EOF
50 > EOF
50 > EOF
51 creating ssh peer for wire protocol version 1
51 creating ssh peer for wire protocol version 1
52 $ hg debugwireproto --localssh --peer ssh2 << EOF
52 $ hg debugwireproto --localssh --peer ssh2 << EOF
53 > EOF
53 > EOF
54 creating ssh peer for wire protocol version 2
54 creating ssh peer for wire protocol version 2
55
55
56 Test a normal behaving server, for sanity
56 Test a normal behaving server, for sanity
57
57
58 $ cd ..
58 $ cd ..
59
59
60 $ hg --debug debugpeer ssh://user@dummy/server
60 $ hg --debug debugpeer ssh://user@dummy/server
61 running * "*/tests/dummyssh" 'user@dummy' 'hg -R server serve --stdio' (glob) (no-windows !)
61 running * "*/tests/dummyssh" 'user@dummy' 'hg -R server serve --stdio' (glob) (no-windows !)
62 running * "*\tests/dummyssh" "user@dummy" "hg -R server serve --stdio" (glob) (windows !)
62 running * "*\tests/dummyssh" "user@dummy" "hg -R server serve --stdio" (glob) (windows !)
63 devel-peer-request: hello+between
63 devel-peer-request: hello+between
64 devel-peer-request: pairs: 81 bytes
64 devel-peer-request: pairs: 81 bytes
65 sending hello command
65 sending hello command
66 sending between command
66 sending between command
67 remote: 440
67 remote: 440
68 remote: capabilities: batch branchmap $USUAL_BUNDLE2_CAPS$ changegroupsubset getbundle known lookup protocaps pushkey streamreqs=generaldelta,revlogv1,sparserevlog unbundle=HG10GZ,HG10BZ,HG10UN unbundlehash
68 remote: capabilities: batch branchmap $USUAL_BUNDLE2_CAPS$ changegroupsubset getbundle known lookup protocaps pushkey streamreqs=generaldelta,revlogv1,sparserevlog unbundle=HG10GZ,HG10BZ,HG10UN unbundlehash
69 remote: 1
69 remote: 1
70 devel-peer-request: protocaps
70 devel-peer-request: protocaps
71 devel-peer-request: caps: * bytes (glob)
71 devel-peer-request: caps: * bytes (glob)
72 sending protocaps command
72 sending protocaps command
73 url: ssh://user@dummy/server
73 url: ssh://user@dummy/server
74 local: no
74 local: no
75 pushable: yes
75 pushable: yes
76
76
77 Server should answer the "hello" command in isolation
77 Server should answer the "hello" command in isolation
78
78
79 $ hg -R server debugwireproto --localssh --peer raw << EOF
79 $ hg -R server debugwireproto --localssh --peer raw << EOF
80 > raw
80 > raw
81 > hello\n
81 > hello\n
82 > readline
82 > readline
83 > readline
83 > readline
84 > EOF
84 > EOF
85 using raw connection to peer
85 using raw connection to peer
86 i> write(6) -> 6:
86 i> write(6) -> 6:
87 i> hello\n
87 i> hello\n
88 o> readline() -> 4:
88 o> readline() -> 4:
89 o> 440\n
89 o> 440\n
90 o> readline() -> 440:
90 o> readline() -> 440:
91 o> capabilities: batch branchmap $USUAL_BUNDLE2_CAPS$ changegroupsubset getbundle known lookup protocaps pushkey streamreqs=generaldelta,revlogv1,sparserevlog unbundle=HG10GZ,HG10BZ,HG10UN unbundlehash\n
91 o> capabilities: batch branchmap $USUAL_BUNDLE2_CAPS$ changegroupsubset getbundle known lookup protocaps pushkey streamreqs=generaldelta,revlogv1,sparserevlog unbundle=HG10GZ,HG10BZ,HG10UN unbundlehash\n
92
92
93 `hg debugserve --sshstdio` works
93 `hg debugserve --sshstdio` works
94
94
95 $ cd server
95 $ cd server
96 $ hg debugserve --sshstdio << EOF
96 $ hg debugserve --sshstdio << EOF
97 > hello
97 > hello
98 > EOF
98 > EOF
99 440
99 440
100 capabilities: batch branchmap $USUAL_BUNDLE2_CAPS$ changegroupsubset getbundle known lookup protocaps pushkey streamreqs=generaldelta,revlogv1,sparserevlog unbundle=HG10GZ,HG10BZ,HG10UN unbundlehash
100 capabilities: batch branchmap $USUAL_BUNDLE2_CAPS$ changegroupsubset getbundle known lookup protocaps pushkey streamreqs=generaldelta,revlogv1,sparserevlog unbundle=HG10GZ,HG10BZ,HG10UN unbundlehash
101
101
102 I/O logging works
102 I/O logging works
103
103
104 $ hg debugserve --sshstdio --logiofd 1 << EOF
104 $ hg debugserve --sshstdio --logiofd 1 << EOF
105 > hello
105 > hello
106 > EOF
106 > EOF
107 e> flush() -> None
107 o> write(4) -> 4:
108 o> write(4) -> 4:
108 o> 440\n
109 o> 440\n
109 o> write(440) -> 440:
110 o> write(440) -> 440:
110 o> capabilities: batch branchmap $USUAL_BUNDLE2_CAPS$ changegroupsubset getbundle known lookup protocaps pushkey streamreqs=generaldelta,revlogv1,sparserevlog unbundle=HG10GZ,HG10BZ,HG10UN unbundlehash\n
111 o> capabilities: batch branchmap $USUAL_BUNDLE2_CAPS$ changegroupsubset getbundle known lookup protocaps pushkey streamreqs=generaldelta,revlogv1,sparserevlog unbundle=HG10GZ,HG10BZ,HG10UN unbundlehash\n
111 440
112 440
112 capabilities: batch branchmap $USUAL_BUNDLE2_CAPS$ changegroupsubset getbundle known lookup protocaps pushkey streamreqs=generaldelta,revlogv1,sparserevlog unbundle=HG10GZ,HG10BZ,HG10UN unbundlehash
113 capabilities: batch branchmap $USUAL_BUNDLE2_CAPS$ changegroupsubset getbundle known lookup protocaps pushkey streamreqs=generaldelta,revlogv1,sparserevlog unbundle=HG10GZ,HG10BZ,HG10UN unbundlehash
113 o> flush() -> None
114 o> flush() -> None
114
115
115 $ hg debugserve --sshstdio --logiofile $TESTTMP/io << EOF
116 $ hg debugserve --sshstdio --logiofile $TESTTMP/io << EOF
116 > hello
117 > hello
117 > EOF
118 > EOF
118 440
119 440
119 capabilities: batch branchmap $USUAL_BUNDLE2_CAPS$ changegroupsubset getbundle known lookup protocaps pushkey streamreqs=generaldelta,revlogv1,sparserevlog unbundle=HG10GZ,HG10BZ,HG10UN unbundlehash
120 capabilities: batch branchmap $USUAL_BUNDLE2_CAPS$ changegroupsubset getbundle known lookup protocaps pushkey streamreqs=generaldelta,revlogv1,sparserevlog unbundle=HG10GZ,HG10BZ,HG10UN unbundlehash
120
121
121 $ cat $TESTTMP/io
122 $ cat $TESTTMP/io
123 e> flush() -> None
122 o> write(4) -> 4:
124 o> write(4) -> 4:
123 o> 440\n
125 o> 440\n
124 o> write(440) -> 440:
126 o> write(440) -> 440:
125 o> capabilities: batch branchmap $USUAL_BUNDLE2_CAPS$ changegroupsubset getbundle known lookup protocaps pushkey streamreqs=generaldelta,revlogv1,sparserevlog unbundle=HG10GZ,HG10BZ,HG10UN unbundlehash\n
127 o> capabilities: batch branchmap $USUAL_BUNDLE2_CAPS$ changegroupsubset getbundle known lookup protocaps pushkey streamreqs=generaldelta,revlogv1,sparserevlog unbundle=HG10GZ,HG10BZ,HG10UN unbundlehash\n
126 o> flush() -> None
128 o> flush() -> None
127
129
128 $ cd ..
130 $ cd ..
129
131
130 >=0.9.1 clients send a "hello" + "between" for the null range as part of handshake.
132 >=0.9.1 clients send a "hello" + "between" for the null range as part of handshake.
131 Server should reply with capabilities and should send "1\n\n" as a successful
133 Server should reply with capabilities and should send "1\n\n" as a successful
132 reply with empty response to the "between".
134 reply with empty response to the "between".
133
135
134 $ hg -R server debugwireproto --localssh --peer raw << EOF
136 $ hg -R server debugwireproto --localssh --peer raw << EOF
135 > raw
137 > raw
136 > hello\n
138 > hello\n
137 > readline
139 > readline
138 > readline
140 > readline
139 > raw
141 > raw
140 > between\n
142 > between\n
141 > pairs 81\n
143 > pairs 81\n
142 > 0000000000000000000000000000000000000000-0000000000000000000000000000000000000000
144 > 0000000000000000000000000000000000000000-0000000000000000000000000000000000000000
143 > readline
145 > readline
144 > readline
146 > readline
145 > EOF
147 > EOF
146 using raw connection to peer
148 using raw connection to peer
147 i> write(6) -> 6:
149 i> write(6) -> 6:
148 i> hello\n
150 i> hello\n
149 o> readline() -> 4:
151 o> readline() -> 4:
150 o> 440\n
152 o> 440\n
151 o> readline() -> 440:
153 o> readline() -> 440:
152 o> capabilities: batch branchmap $USUAL_BUNDLE2_CAPS$ changegroupsubset getbundle known lookup protocaps pushkey streamreqs=generaldelta,revlogv1,sparserevlog unbundle=HG10GZ,HG10BZ,HG10UN unbundlehash\n
154 o> capabilities: batch branchmap $USUAL_BUNDLE2_CAPS$ changegroupsubset getbundle known lookup protocaps pushkey streamreqs=generaldelta,revlogv1,sparserevlog unbundle=HG10GZ,HG10BZ,HG10UN unbundlehash\n
153 i> write(98) -> 98:
155 i> write(98) -> 98:
154 i> between\n
156 i> between\n
155 i> pairs 81\n
157 i> pairs 81\n
156 i> 0000000000000000000000000000000000000000-0000000000000000000000000000000000000000
158 i> 0000000000000000000000000000000000000000-0000000000000000000000000000000000000000
157 o> readline() -> 2:
159 o> readline() -> 2:
158 o> 1\n
160 o> 1\n
159 o> readline() -> 1:
161 o> readline() -> 1:
160 o> \n
162 o> \n
161
163
162 SSH banner is not printed by default, ignored by clients
164 SSH banner is not printed by default, ignored by clients
163
165
164 $ SSHSERVERMODE=banner hg debugpeer ssh://user@dummy/server
166 $ SSHSERVERMODE=banner hg debugpeer ssh://user@dummy/server
165 url: ssh://user@dummy/server
167 url: ssh://user@dummy/server
166 local: no
168 local: no
167 pushable: yes
169 pushable: yes
168
170
169 --debug will print the banner
171 --debug will print the banner
170
172
171 $ SSHSERVERMODE=banner hg --debug debugpeer ssh://user@dummy/server
173 $ SSHSERVERMODE=banner hg --debug debugpeer ssh://user@dummy/server
172 running * "*/tests/dummyssh" 'user@dummy' 'hg -R server serve --stdio' (glob) (no-windows !)
174 running * "*/tests/dummyssh" 'user@dummy' 'hg -R server serve --stdio' (glob) (no-windows !)
173 running * "*\tests/dummyssh" "user@dummy" "hg -R server serve --stdio" (glob) (windows !)
175 running * "*\tests/dummyssh" "user@dummy" "hg -R server serve --stdio" (glob) (windows !)
174 devel-peer-request: hello+between
176 devel-peer-request: hello+between
175 devel-peer-request: pairs: 81 bytes
177 devel-peer-request: pairs: 81 bytes
176 sending hello command
178 sending hello command
177 sending between command
179 sending between command
178 remote: banner: line 0
180 remote: banner: line 0
179 remote: banner: line 1
181 remote: banner: line 1
180 remote: banner: line 2
182 remote: banner: line 2
181 remote: banner: line 3
183 remote: banner: line 3
182 remote: banner: line 4
184 remote: banner: line 4
183 remote: banner: line 5
185 remote: banner: line 5
184 remote: banner: line 6
186 remote: banner: line 6
185 remote: banner: line 7
187 remote: banner: line 7
186 remote: banner: line 8
188 remote: banner: line 8
187 remote: banner: line 9
189 remote: banner: line 9
188 remote: 440
190 remote: 440
189 remote: capabilities: batch branchmap $USUAL_BUNDLE2_CAPS$ changegroupsubset getbundle known lookup protocaps pushkey streamreqs=generaldelta,revlogv1,sparserevlog unbundle=HG10GZ,HG10BZ,HG10UN unbundlehash
191 remote: capabilities: batch branchmap $USUAL_BUNDLE2_CAPS$ changegroupsubset getbundle known lookup protocaps pushkey streamreqs=generaldelta,revlogv1,sparserevlog unbundle=HG10GZ,HG10BZ,HG10UN unbundlehash
190 remote: 1
192 remote: 1
191 devel-peer-request: protocaps
193 devel-peer-request: protocaps
192 devel-peer-request: caps: * bytes (glob)
194 devel-peer-request: caps: * bytes (glob)
193 sending protocaps command
195 sending protocaps command
194 url: ssh://user@dummy/server
196 url: ssh://user@dummy/server
195 local: no
197 local: no
196 pushable: yes
198 pushable: yes
197
199
198 And test the banner with the raw protocol
200 And test the banner with the raw protocol
199
201
200 $ SSHSERVERMODE=banner hg -R server debugwireproto --localssh --peer raw << EOF
202 $ SSHSERVERMODE=banner hg -R server debugwireproto --localssh --peer raw << EOF
201 > raw
203 > raw
202 > hello\n
204 > hello\n
203 > readline
205 > readline
204 > readline
206 > readline
205 > readline
207 > readline
206 > readline
208 > readline
207 > readline
209 > readline
208 > readline
210 > readline
209 > readline
211 > readline
210 > readline
212 > readline
211 > readline
213 > readline
212 > readline
214 > readline
213 > readline
215 > readline
214 > readline
216 > readline
215 > raw
217 > raw
216 > between\n
218 > between\n
217 > pairs 81\n
219 > pairs 81\n
218 > 0000000000000000000000000000000000000000-0000000000000000000000000000000000000000
220 > 0000000000000000000000000000000000000000-0000000000000000000000000000000000000000
219 > readline
221 > readline
220 > readline
222 > readline
221 > EOF
223 > EOF
222 using raw connection to peer
224 using raw connection to peer
223 i> write(6) -> 6:
225 i> write(6) -> 6:
224 i> hello\n
226 i> hello\n
225 o> readline() -> 15:
227 o> readline() -> 15:
226 o> banner: line 0\n
228 o> banner: line 0\n
227 o> readline() -> 15:
229 o> readline() -> 15:
228 o> banner: line 1\n
230 o> banner: line 1\n
229 o> readline() -> 15:
231 o> readline() -> 15:
230 o> banner: line 2\n
232 o> banner: line 2\n
231 o> readline() -> 15:
233 o> readline() -> 15:
232 o> banner: line 3\n
234 o> banner: line 3\n
233 o> readline() -> 15:
235 o> readline() -> 15:
234 o> banner: line 4\n
236 o> banner: line 4\n
235 o> readline() -> 15:
237 o> readline() -> 15:
236 o> banner: line 5\n
238 o> banner: line 5\n
237 o> readline() -> 15:
239 o> readline() -> 15:
238 o> banner: line 6\n
240 o> banner: line 6\n
239 o> readline() -> 15:
241 o> readline() -> 15:
240 o> banner: line 7\n
242 o> banner: line 7\n
241 o> readline() -> 15:
243 o> readline() -> 15:
242 o> banner: line 8\n
244 o> banner: line 8\n
243 o> readline() -> 15:
245 o> readline() -> 15:
244 o> banner: line 9\n
246 o> banner: line 9\n
245 o> readline() -> 4:
247 o> readline() -> 4:
246 o> 440\n
248 o> 440\n
247 o> readline() -> 440:
249 o> readline() -> 440:
248 o> capabilities: batch branchmap $USUAL_BUNDLE2_CAPS$ changegroupsubset getbundle known lookup protocaps pushkey streamreqs=generaldelta,revlogv1,sparserevlog unbundle=HG10GZ,HG10BZ,HG10UN unbundlehash\n
250 o> capabilities: batch branchmap $USUAL_BUNDLE2_CAPS$ changegroupsubset getbundle known lookup protocaps pushkey streamreqs=generaldelta,revlogv1,sparserevlog unbundle=HG10GZ,HG10BZ,HG10UN unbundlehash\n
249 i> write(98) -> 98:
251 i> write(98) -> 98:
250 i> between\n
252 i> between\n
251 i> pairs 81\n
253 i> pairs 81\n
252 i> 0000000000000000000000000000000000000000-0000000000000000000000000000000000000000
254 i> 0000000000000000000000000000000000000000-0000000000000000000000000000000000000000
253 o> readline() -> 2:
255 o> readline() -> 2:
254 o> 1\n
256 o> 1\n
255 o> readline() -> 1:
257 o> readline() -> 1:
256 o> \n
258 o> \n
257
259
258 Connecting to a <0.9.1 server that doesn't support the hello command.
260 Connecting to a <0.9.1 server that doesn't support the hello command.
259 The client should refuse, as we dropped support for connecting to such
261 The client should refuse, as we dropped support for connecting to such
260 servers.
262 servers.
261
263
262 $ SSHSERVERMODE=no-hello hg --debug debugpeer ssh://user@dummy/server
264 $ SSHSERVERMODE=no-hello hg --debug debugpeer ssh://user@dummy/server
263 running * "*/tests/dummyssh" 'user@dummy' 'hg -R server serve --stdio' (glob) (no-windows !)
265 running * "*/tests/dummyssh" 'user@dummy' 'hg -R server serve --stdio' (glob) (no-windows !)
264 running * "*\tests/dummyssh" "user@dummy" "hg -R server serve --stdio" (glob) (windows !)
266 running * "*\tests/dummyssh" "user@dummy" "hg -R server serve --stdio" (glob) (windows !)
265 devel-peer-request: hello+between
267 devel-peer-request: hello+between
266 devel-peer-request: pairs: 81 bytes
268 devel-peer-request: pairs: 81 bytes
267 sending hello command
269 sending hello command
268 sending between command
270 sending between command
269 remote: 0
271 remote: 0
270 remote: 1
272 remote: 1
271 abort: no suitable response from remote hg!
273 abort: no suitable response from remote hg!
272 [255]
274 [255]
273
275
274 Sending an unknown command to the server results in an empty response to that command
276 Sending an unknown command to the server results in an empty response to that command
275
277
276 $ hg -R server debugwireproto --localssh --peer raw << EOF
278 $ hg -R server debugwireproto --localssh --peer raw << EOF
277 > raw
279 > raw
278 > pre-hello\n
280 > pre-hello\n
279 > readline
281 > readline
280 > raw
282 > raw
281 > hello\n
283 > hello\n
282 > readline
284 > readline
283 > raw
285 > raw
284 > between\n
286 > between\n
285 > pairs 81\n
287 > pairs 81\n
286 > 0000000000000000000000000000000000000000-0000000000000000000000000000000000000000
288 > 0000000000000000000000000000000000000000-0000000000000000000000000000000000000000
287 > readline
289 > readline
288 > readline
290 > readline
289 > EOF
291 > EOF
290 using raw connection to peer
292 using raw connection to peer
291 i> write(10) -> 10:
293 i> write(10) -> 10:
292 i> pre-hello\n
294 i> pre-hello\n
293 o> readline() -> 2:
295 o> readline() -> 2:
294 o> 0\n
296 o> 0\n
295 i> write(6) -> 6:
297 i> write(6) -> 6:
296 i> hello\n
298 i> hello\n
297 o> readline() -> 4:
299 o> readline() -> 4:
298 o> 440\n
300 o> 440\n
299 i> write(98) -> 98:
301 i> write(98) -> 98:
300 i> between\n
302 i> between\n
301 i> pairs 81\n
303 i> pairs 81\n
302 i> 0000000000000000000000000000000000000000-0000000000000000000000000000000000000000
304 i> 0000000000000000000000000000000000000000-0000000000000000000000000000000000000000
303 o> readline() -> 440:
305 o> readline() -> 440:
304 o> capabilities: batch branchmap $USUAL_BUNDLE2_CAPS$ changegroupsubset getbundle known lookup protocaps pushkey streamreqs=generaldelta,revlogv1,sparserevlog unbundle=HG10GZ,HG10BZ,HG10UN unbundlehash\n
306 o> capabilities: batch branchmap $USUAL_BUNDLE2_CAPS$ changegroupsubset getbundle known lookup protocaps pushkey streamreqs=generaldelta,revlogv1,sparserevlog unbundle=HG10GZ,HG10BZ,HG10UN unbundlehash\n
305 o> readline() -> 2:
307 o> readline() -> 2:
306 o> 1\n
308 o> 1\n
307
309
308 $ hg --config sshpeer.mode=extra-handshake-commands --config sshpeer.handshake-mode=pre-no-args --debug debugpeer ssh://user@dummy/server
310 $ hg --config sshpeer.mode=extra-handshake-commands --config sshpeer.handshake-mode=pre-no-args --debug debugpeer ssh://user@dummy/server
309 running * "*/tests/dummyssh" 'user@dummy' 'hg -R server serve --stdio' (glob) (no-windows !)
311 running * "*/tests/dummyssh" 'user@dummy' 'hg -R server serve --stdio' (glob) (no-windows !)
310 running * "*\tests/dummyssh" "user@dummy" "hg -R server serve --stdio" (glob) (windows !)
312 running * "*\tests/dummyssh" "user@dummy" "hg -R server serve --stdio" (glob) (windows !)
311 sending no-args command
313 sending no-args command
312 devel-peer-request: hello+between
314 devel-peer-request: hello+between
313 devel-peer-request: pairs: 81 bytes
315 devel-peer-request: pairs: 81 bytes
314 sending hello command
316 sending hello command
315 sending between command
317 sending between command
316 remote: 0
318 remote: 0
317 remote: 440
319 remote: 440
318 remote: capabilities: batch branchmap $USUAL_BUNDLE2_CAPS$ changegroupsubset getbundle known lookup protocaps pushkey streamreqs=generaldelta,revlogv1,sparserevlog unbundle=HG10GZ,HG10BZ,HG10UN unbundlehash
320 remote: capabilities: batch branchmap $USUAL_BUNDLE2_CAPS$ changegroupsubset getbundle known lookup protocaps pushkey streamreqs=generaldelta,revlogv1,sparserevlog unbundle=HG10GZ,HG10BZ,HG10UN unbundlehash
319 remote: 1
321 remote: 1
320 devel-peer-request: protocaps
322 devel-peer-request: protocaps
321 devel-peer-request: caps: * bytes (glob)
323 devel-peer-request: caps: * bytes (glob)
322 sending protocaps command
324 sending protocaps command
323 url: ssh://user@dummy/server
325 url: ssh://user@dummy/server
324 local: no
326 local: no
325 pushable: yes
327 pushable: yes
326
328
327 Send multiple unknown commands before hello
329 Send multiple unknown commands before hello
328
330
329 $ hg -R server debugwireproto --localssh --peer raw << EOF
331 $ hg -R server debugwireproto --localssh --peer raw << EOF
330 > raw
332 > raw
331 > unknown1\n
333 > unknown1\n
332 > readline
334 > readline
333 > raw
335 > raw
334 > unknown2\n
336 > unknown2\n
335 > readline
337 > readline
336 > raw
338 > raw
337 > unknown3\n
339 > unknown3\n
338 > readline
340 > readline
339 > raw
341 > raw
340 > hello\n
342 > hello\n
341 > readline
343 > readline
342 > readline
344 > readline
343 > raw
345 > raw
344 > between\n
346 > between\n
345 > pairs 81\n
347 > pairs 81\n
346 > 0000000000000000000000000000000000000000-0000000000000000000000000000000000000000
348 > 0000000000000000000000000000000000000000-0000000000000000000000000000000000000000
347 > readline
349 > readline
348 > readline
350 > readline
349 > EOF
351 > EOF
350 using raw connection to peer
352 using raw connection to peer
351 i> write(9) -> 9:
353 i> write(9) -> 9:
352 i> unknown1\n
354 i> unknown1\n
353 o> readline() -> 2:
355 o> readline() -> 2:
354 o> 0\n
356 o> 0\n
355 i> write(9) -> 9:
357 i> write(9) -> 9:
356 i> unknown2\n
358 i> unknown2\n
357 o> readline() -> 2:
359 o> readline() -> 2:
358 o> 0\n
360 o> 0\n
359 i> write(9) -> 9:
361 i> write(9) -> 9:
360 i> unknown3\n
362 i> unknown3\n
361 o> readline() -> 2:
363 o> readline() -> 2:
362 o> 0\n
364 o> 0\n
363 i> write(6) -> 6:
365 i> write(6) -> 6:
364 i> hello\n
366 i> hello\n
365 o> readline() -> 4:
367 o> readline() -> 4:
366 o> 440\n
368 o> 440\n
367 o> readline() -> 440:
369 o> readline() -> 440:
368 o> capabilities: batch branchmap $USUAL_BUNDLE2_CAPS$ changegroupsubset getbundle known lookup protocaps pushkey streamreqs=generaldelta,revlogv1,sparserevlog unbundle=HG10GZ,HG10BZ,HG10UN unbundlehash\n
370 o> capabilities: batch branchmap $USUAL_BUNDLE2_CAPS$ changegroupsubset getbundle known lookup protocaps pushkey streamreqs=generaldelta,revlogv1,sparserevlog unbundle=HG10GZ,HG10BZ,HG10UN unbundlehash\n
369 i> write(98) -> 98:
371 i> write(98) -> 98:
370 i> between\n
372 i> between\n
371 i> pairs 81\n
373 i> pairs 81\n
372 i> 0000000000000000000000000000000000000000-0000000000000000000000000000000000000000
374 i> 0000000000000000000000000000000000000000-0000000000000000000000000000000000000000
373 o> readline() -> 2:
375 o> readline() -> 2:
374 o> 1\n
376 o> 1\n
375 o> readline() -> 1:
377 o> readline() -> 1:
376 o> \n
378 o> \n
377
379
378 $ hg --config sshpeer.mode=extra-handshake-commands --config sshpeer.handshake-mode=pre-multiple-no-args --debug debugpeer ssh://user@dummy/server
380 $ hg --config sshpeer.mode=extra-handshake-commands --config sshpeer.handshake-mode=pre-multiple-no-args --debug debugpeer ssh://user@dummy/server
379 running * "*/tests/dummyssh" 'user@dummy' 'hg -R server serve --stdio' (glob) (no-windows !)
381 running * "*/tests/dummyssh" 'user@dummy' 'hg -R server serve --stdio' (glob) (no-windows !)
380 running * "*\tests/dummyssh" "user@dummy" "hg -R server serve --stdio" (glob) (windows !)
382 running * "*\tests/dummyssh" "user@dummy" "hg -R server serve --stdio" (glob) (windows !)
381 sending unknown1 command
383 sending unknown1 command
382 sending unknown2 command
384 sending unknown2 command
383 sending unknown3 command
385 sending unknown3 command
384 devel-peer-request: hello+between
386 devel-peer-request: hello+between
385 devel-peer-request: pairs: 81 bytes
387 devel-peer-request: pairs: 81 bytes
386 sending hello command
388 sending hello command
387 sending between command
389 sending between command
388 remote: 0
390 remote: 0
389 remote: 0
391 remote: 0
390 remote: 0
392 remote: 0
391 remote: 440
393 remote: 440
392 remote: capabilities: batch branchmap $USUAL_BUNDLE2_CAPS$ changegroupsubset getbundle known lookup protocaps pushkey streamreqs=generaldelta,revlogv1,sparserevlog unbundle=HG10GZ,HG10BZ,HG10UN unbundlehash
394 remote: capabilities: batch branchmap $USUAL_BUNDLE2_CAPS$ changegroupsubset getbundle known lookup protocaps pushkey streamreqs=generaldelta,revlogv1,sparserevlog unbundle=HG10GZ,HG10BZ,HG10UN unbundlehash
393 remote: 1
395 remote: 1
394 devel-peer-request: protocaps
396 devel-peer-request: protocaps
395 devel-peer-request: caps: * bytes (glob)
397 devel-peer-request: caps: * bytes (glob)
396 sending protocaps command
398 sending protocaps command
397 url: ssh://user@dummy/server
399 url: ssh://user@dummy/server
398 local: no
400 local: no
399 pushable: yes
401 pushable: yes
400
402
401 Send an unknown command before hello that has arguments
403 Send an unknown command before hello that has arguments
402
404
403 $ cd server
405 $ cd server
404
406
405 $ hg debugwireproto --localssh --peer raw << EOF
407 $ hg debugwireproto --localssh --peer raw << EOF
406 > raw
408 > raw
407 > with-args\n
409 > with-args\n
408 > foo 13\n
410 > foo 13\n
409 > value for foo\n
411 > value for foo\n
410 > bar 13\n
412 > bar 13\n
411 > value for bar\n
413 > value for bar\n
412 > readline
414 > readline
413 > readline
415 > readline
414 > readline
416 > readline
415 > readline
417 > readline
416 > readline
418 > readline
417 > raw
419 > raw
418 > hello\n
420 > hello\n
419 > readline
421 > readline
420 > readline
422 > readline
421 > raw
423 > raw
422 > between\n
424 > between\n
423 > pairs 81\n
425 > pairs 81\n
424 > 0000000000000000000000000000000000000000-0000000000000000000000000000000000000000
426 > 0000000000000000000000000000000000000000-0000000000000000000000000000000000000000
425 > readline
427 > readline
426 > readline
428 > readline
427 > EOF
429 > EOF
428 using raw connection to peer
430 using raw connection to peer
429 i> write(52) -> 52:
431 i> write(52) -> 52:
430 i> with-args\n
432 i> with-args\n
431 i> foo 13\n
433 i> foo 13\n
432 i> value for foo\n
434 i> value for foo\n
433 i> bar 13\n
435 i> bar 13\n
434 i> value for bar\n
436 i> value for bar\n
435 o> readline() -> 2:
437 o> readline() -> 2:
436 o> 0\n
438 o> 0\n
437 o> readline() -> 2:
439 o> readline() -> 2:
438 o> 0\n
440 o> 0\n
439 o> readline() -> 2:
441 o> readline() -> 2:
440 o> 0\n
442 o> 0\n
441 o> readline() -> 2:
443 o> readline() -> 2:
442 o> 0\n
444 o> 0\n
443 o> readline() -> 2:
445 o> readline() -> 2:
444 o> 0\n
446 o> 0\n
445 i> write(6) -> 6:
447 i> write(6) -> 6:
446 i> hello\n
448 i> hello\n
447 o> readline() -> 4:
449 o> readline() -> 4:
448 o> 440\n
450 o> 440\n
449 o> readline() -> 440:
451 o> readline() -> 440:
450 o> capabilities: batch branchmap $USUAL_BUNDLE2_CAPS$ changegroupsubset getbundle known lookup protocaps pushkey streamreqs=generaldelta,revlogv1,sparserevlog unbundle=HG10GZ,HG10BZ,HG10UN unbundlehash\n
452 o> capabilities: batch branchmap $USUAL_BUNDLE2_CAPS$ changegroupsubset getbundle known lookup protocaps pushkey streamreqs=generaldelta,revlogv1,sparserevlog unbundle=HG10GZ,HG10BZ,HG10UN unbundlehash\n
451 i> write(98) -> 98:
453 i> write(98) -> 98:
452 i> between\n
454 i> between\n
453 i> pairs 81\n
455 i> pairs 81\n
454 i> 0000000000000000000000000000000000000000-0000000000000000000000000000000000000000
456 i> 0000000000000000000000000000000000000000-0000000000000000000000000000000000000000
455 o> readline() -> 2:
457 o> readline() -> 2:
456 o> 1\n
458 o> 1\n
457 o> readline() -> 1:
459 o> readline() -> 1:
458 o> \n
460 o> \n
459
461
460 Send an unknown command having an argument that looks numeric
462 Send an unknown command having an argument that looks numeric
461
463
462 $ hg debugwireproto --localssh --peer raw << EOF
464 $ hg debugwireproto --localssh --peer raw << EOF
463 > raw
465 > raw
464 > unknown\n
466 > unknown\n
465 > foo 1\n
467 > foo 1\n
466 > 0\n
468 > 0\n
467 > readline
469 > readline
468 > readline
470 > readline
469 > readline
471 > readline
470 > raw
472 > raw
471 > hello\n
473 > hello\n
472 > readline
474 > readline
473 > readline
475 > readline
474 > raw
476 > raw
475 > between\n
477 > between\n
476 > pairs 81\n
478 > pairs 81\n
477 > 0000000000000000000000000000000000000000-0000000000000000000000000000000000000000
479 > 0000000000000000000000000000000000000000-0000000000000000000000000000000000000000
478 > readline
480 > readline
479 > readline
481 > readline
480 > EOF
482 > EOF
481 using raw connection to peer
483 using raw connection to peer
482 i> write(16) -> 16:
484 i> write(16) -> 16:
483 i> unknown\n
485 i> unknown\n
484 i> foo 1\n
486 i> foo 1\n
485 i> 0\n
487 i> 0\n
486 o> readline() -> 2:
488 o> readline() -> 2:
487 o> 0\n
489 o> 0\n
488 o> readline() -> 2:
490 o> readline() -> 2:
489 o> 0\n
491 o> 0\n
490 o> readline() -> 2:
492 o> readline() -> 2:
491 o> 0\n
493 o> 0\n
492 i> write(6) -> 6:
494 i> write(6) -> 6:
493 i> hello\n
495 i> hello\n
494 o> readline() -> 4:
496 o> readline() -> 4:
495 o> 440\n
497 o> 440\n
496 o> readline() -> 440:
498 o> readline() -> 440:
497 o> capabilities: batch branchmap $USUAL_BUNDLE2_CAPS$ changegroupsubset getbundle known lookup protocaps pushkey streamreqs=generaldelta,revlogv1,sparserevlog unbundle=HG10GZ,HG10BZ,HG10UN unbundlehash\n
499 o> capabilities: batch branchmap $USUAL_BUNDLE2_CAPS$ changegroupsubset getbundle known lookup protocaps pushkey streamreqs=generaldelta,revlogv1,sparserevlog unbundle=HG10GZ,HG10BZ,HG10UN unbundlehash\n
498 i> write(98) -> 98:
500 i> write(98) -> 98:
499 i> between\n
501 i> between\n
500 i> pairs 81\n
502 i> pairs 81\n
501 i> 0000000000000000000000000000000000000000-0000000000000000000000000000000000000000
503 i> 0000000000000000000000000000000000000000-0000000000000000000000000000000000000000
502 o> readline() -> 2:
504 o> readline() -> 2:
503 o> 1\n
505 o> 1\n
504 o> readline() -> 1:
506 o> readline() -> 1:
505 o> \n
507 o> \n
506
508
507 $ hg debugwireproto --localssh --peer raw << EOF
509 $ hg debugwireproto --localssh --peer raw << EOF
508 > raw
510 > raw
509 > unknown\n
511 > unknown\n
510 > foo 1\n
512 > foo 1\n
511 > 1\n
513 > 1\n
512 > readline
514 > readline
513 > readline
515 > readline
514 > readline
516 > readline
515 > raw
517 > raw
516 > hello\n
518 > hello\n
517 > readline
519 > readline
518 > readline
520 > readline
519 > raw
521 > raw
520 > between\n
522 > between\n
521 > pairs 81\n
523 > pairs 81\n
522 > 0000000000000000000000000000000000000000-0000000000000000000000000000000000000000
524 > 0000000000000000000000000000000000000000-0000000000000000000000000000000000000000
523 > readline
525 > readline
524 > readline
526 > readline
525 > EOF
527 > EOF
526 using raw connection to peer
528 using raw connection to peer
527 i> write(16) -> 16:
529 i> write(16) -> 16:
528 i> unknown\n
530 i> unknown\n
529 i> foo 1\n
531 i> foo 1\n
530 i> 1\n
532 i> 1\n
531 o> readline() -> 2:
533 o> readline() -> 2:
532 o> 0\n
534 o> 0\n
533 o> readline() -> 2:
535 o> readline() -> 2:
534 o> 0\n
536 o> 0\n
535 o> readline() -> 2:
537 o> readline() -> 2:
536 o> 0\n
538 o> 0\n
537 i> write(6) -> 6:
539 i> write(6) -> 6:
538 i> hello\n
540 i> hello\n
539 o> readline() -> 4:
541 o> readline() -> 4:
540 o> 440\n
542 o> 440\n
541 o> readline() -> 440:
543 o> readline() -> 440:
542 o> capabilities: batch branchmap $USUAL_BUNDLE2_CAPS$ changegroupsubset getbundle known lookup protocaps pushkey streamreqs=generaldelta,revlogv1,sparserevlog unbundle=HG10GZ,HG10BZ,HG10UN unbundlehash\n
544 o> capabilities: batch branchmap $USUAL_BUNDLE2_CAPS$ changegroupsubset getbundle known lookup protocaps pushkey streamreqs=generaldelta,revlogv1,sparserevlog unbundle=HG10GZ,HG10BZ,HG10UN unbundlehash\n
543 i> write(98) -> 98:
545 i> write(98) -> 98:
544 i> between\n
546 i> between\n
545 i> pairs 81\n
547 i> pairs 81\n
546 i> 0000000000000000000000000000000000000000-0000000000000000000000000000000000000000
548 i> 0000000000000000000000000000000000000000-0000000000000000000000000000000000000000
547 o> readline() -> 2:
549 o> readline() -> 2:
548 o> 1\n
550 o> 1\n
549 o> readline() -> 1:
551 o> readline() -> 1:
550 o> \n
552 o> \n
551
553
552 When sending a dict argument value, it is serialized to
554 When sending a dict argument value, it is serialized to
553 "<arg> <item count>" followed by "<key> <len>\n<value>" for each item
555 "<arg> <item count>" followed by "<key> <len>\n<value>" for each item
554 in the dict.
556 in the dict.
555
557
556 Dictionary value for unknown command
558 Dictionary value for unknown command
557
559
558 $ hg debugwireproto --localssh --peer raw << EOF
560 $ hg debugwireproto --localssh --peer raw << EOF
559 > raw
561 > raw
560 > unknown\n
562 > unknown\n
561 > dict 3\n
563 > dict 3\n
562 > key1 3\n
564 > key1 3\n
563 > foo\n
565 > foo\n
564 > key2 3\n
566 > key2 3\n
565 > bar\n
567 > bar\n
566 > key3 3\n
568 > key3 3\n
567 > baz\n
569 > baz\n
568 > readline
570 > readline
569 > readline
571 > readline
570 > readline
572 > readline
571 > readline
573 > readline
572 > readline
574 > readline
573 > readline
575 > readline
574 > readline
576 > readline
575 > readline
577 > readline
576 > raw
578 > raw
577 > hello\n
579 > hello\n
578 > readline
580 > readline
579 > readline
581 > readline
580 > EOF
582 > EOF
581 using raw connection to peer
583 using raw connection to peer
582 i> write(48) -> 48:
584 i> write(48) -> 48:
583 i> unknown\n
585 i> unknown\n
584 i> dict 3\n
586 i> dict 3\n
585 i> key1 3\n
587 i> key1 3\n
586 i> foo\n
588 i> foo\n
587 i> key2 3\n
589 i> key2 3\n
588 i> bar\n
590 i> bar\n
589 i> key3 3\n
591 i> key3 3\n
590 i> baz\n
592 i> baz\n
591 o> readline() -> 2:
593 o> readline() -> 2:
592 o> 0\n
594 o> 0\n
593 o> readline() -> 2:
595 o> readline() -> 2:
594 o> 0\n
596 o> 0\n
595 o> readline() -> 2:
597 o> readline() -> 2:
596 o> 0\n
598 o> 0\n
597 o> readline() -> 2:
599 o> readline() -> 2:
598 o> 0\n
600 o> 0\n
599 o> readline() -> 2:
601 o> readline() -> 2:
600 o> 0\n
602 o> 0\n
601 o> readline() -> 2:
603 o> readline() -> 2:
602 o> 0\n
604 o> 0\n
603 o> readline() -> 2:
605 o> readline() -> 2:
604 o> 0\n
606 o> 0\n
605 o> readline() -> 2:
607 o> readline() -> 2:
606 o> 0\n
608 o> 0\n
607 i> write(6) -> 6:
609 i> write(6) -> 6:
608 i> hello\n
610 i> hello\n
609 o> readline() -> 4:
611 o> readline() -> 4:
610 o> 440\n
612 o> 440\n
611 o> readline() -> 440:
613 o> readline() -> 440:
612 o> capabilities: batch branchmap $USUAL_BUNDLE2_CAPS$ changegroupsubset getbundle known lookup protocaps pushkey streamreqs=generaldelta,revlogv1,sparserevlog unbundle=HG10GZ,HG10BZ,HG10UN unbundlehash\n
614 o> capabilities: batch branchmap $USUAL_BUNDLE2_CAPS$ changegroupsubset getbundle known lookup protocaps pushkey streamreqs=generaldelta,revlogv1,sparserevlog unbundle=HG10GZ,HG10BZ,HG10UN unbundlehash\n
613
615
614 Incomplete dictionary send
616 Incomplete dictionary send
615
617
616 $ hg debugwireproto --localssh --peer raw << EOF
618 $ hg debugwireproto --localssh --peer raw << EOF
617 > raw
619 > raw
618 > unknown\n
620 > unknown\n
619 > dict 3\n
621 > dict 3\n
620 > key1 3\n
622 > key1 3\n
621 > foo\n
623 > foo\n
622 > readline
624 > readline
623 > readline
625 > readline
624 > readline
626 > readline
625 > readline
627 > readline
626 > EOF
628 > EOF
627 using raw connection to peer
629 using raw connection to peer
628 i> write(26) -> 26:
630 i> write(26) -> 26:
629 i> unknown\n
631 i> unknown\n
630 i> dict 3\n
632 i> dict 3\n
631 i> key1 3\n
633 i> key1 3\n
632 i> foo\n
634 i> foo\n
633 o> readline() -> 2:
635 o> readline() -> 2:
634 o> 0\n
636 o> 0\n
635 o> readline() -> 2:
637 o> readline() -> 2:
636 o> 0\n
638 o> 0\n
637 o> readline() -> 2:
639 o> readline() -> 2:
638 o> 0\n
640 o> 0\n
639 o> readline() -> 2:
641 o> readline() -> 2:
640 o> 0\n
642 o> 0\n
641
643
642 Incomplete value send
644 Incomplete value send
643
645
644 $ hg debugwireproto --localssh --peer raw << EOF
646 $ hg debugwireproto --localssh --peer raw << EOF
645 > raw
647 > raw
646 > unknown\n
648 > unknown\n
647 > dict 3\n
649 > dict 3\n
648 > key1 3\n
650 > key1 3\n
649 > fo
651 > fo
650 > readline
652 > readline
651 > readline
653 > readline
652 > readline
654 > readline
653 > EOF
655 > EOF
654 using raw connection to peer
656 using raw connection to peer
655 i> write(24) -> 24:
657 i> write(24) -> 24:
656 i> unknown\n
658 i> unknown\n
657 i> dict 3\n
659 i> dict 3\n
658 i> key1 3\n
660 i> key1 3\n
659 i> fo
661 i> fo
660 o> readline() -> 2:
662 o> readline() -> 2:
661 o> 0\n
663 o> 0\n
662 o> readline() -> 2:
664 o> readline() -> 2:
663 o> 0\n
665 o> 0\n
664 o> readline() -> 2:
666 o> readline() -> 2:
665 o> 0\n
667 o> 0\n
666
668
667 Send a command line with spaces
669 Send a command line with spaces
668
670
669 $ hg debugwireproto --localssh --peer raw << EOF
671 $ hg debugwireproto --localssh --peer raw << EOF
670 > raw
672 > raw
671 > unknown withspace\n
673 > unknown withspace\n
672 > readline
674 > readline
673 > raw
675 > raw
674 > hello\n
676 > hello\n
675 > readline
677 > readline
676 > readline
678 > readline
677 > raw
679 > raw
678 > between\n
680 > between\n
679 > pairs 81\n
681 > pairs 81\n
680 > 0000000000000000000000000000000000000000-0000000000000000000000000000000000000000
682 > 0000000000000000000000000000000000000000-0000000000000000000000000000000000000000
681 > readline
683 > readline
682 > readline
684 > readline
683 > EOF
685 > EOF
684 using raw connection to peer
686 using raw connection to peer
685 i> write(18) -> 18:
687 i> write(18) -> 18:
686 i> unknown withspace\n
688 i> unknown withspace\n
687 o> readline() -> 2:
689 o> readline() -> 2:
688 o> 0\n
690 o> 0\n
689 i> write(6) -> 6:
691 i> write(6) -> 6:
690 i> hello\n
692 i> hello\n
691 o> readline() -> 4:
693 o> readline() -> 4:
692 o> 440\n
694 o> 440\n
693 o> readline() -> 440:
695 o> readline() -> 440:
694 o> capabilities: batch branchmap $USUAL_BUNDLE2_CAPS$ changegroupsubset getbundle known lookup protocaps pushkey streamreqs=generaldelta,revlogv1,sparserevlog unbundle=HG10GZ,HG10BZ,HG10UN unbundlehash\n
696 o> capabilities: batch branchmap $USUAL_BUNDLE2_CAPS$ changegroupsubset getbundle known lookup protocaps pushkey streamreqs=generaldelta,revlogv1,sparserevlog unbundle=HG10GZ,HG10BZ,HG10UN unbundlehash\n
695 i> write(98) -> 98:
697 i> write(98) -> 98:
696 i> between\n
698 i> between\n
697 i> pairs 81\n
699 i> pairs 81\n
698 i> 0000000000000000000000000000000000000000-0000000000000000000000000000000000000000
700 i> 0000000000000000000000000000000000000000-0000000000000000000000000000000000000000
699 o> readline() -> 2:
701 o> readline() -> 2:
700 o> 1\n
702 o> 1\n
701 o> readline() -> 1:
703 o> readline() -> 1:
702 o> \n
704 o> \n
703
705
704 $ hg debugwireproto --localssh --peer raw << EOF
706 $ hg debugwireproto --localssh --peer raw << EOF
705 > raw
707 > raw
706 > unknown with multiple spaces\n
708 > unknown with multiple spaces\n
707 > readline
709 > readline
708 > raw
710 > raw
709 > hello\n
711 > hello\n
710 > readline
712 > readline
711 > readline
713 > readline
712 > raw
714 > raw
713 > between\n
715 > between\n
714 > pairs 81\n
716 > pairs 81\n
715 > 0000000000000000000000000000000000000000-0000000000000000000000000000000000000000
717 > 0000000000000000000000000000000000000000-0000000000000000000000000000000000000000
716 > readline
718 > readline
717 > EOF
719 > EOF
718 using raw connection to peer
720 using raw connection to peer
719 i> write(29) -> 29:
721 i> write(29) -> 29:
720 i> unknown with multiple spaces\n
722 i> unknown with multiple spaces\n
721 o> readline() -> 2:
723 o> readline() -> 2:
722 o> 0\n
724 o> 0\n
723 i> write(6) -> 6:
725 i> write(6) -> 6:
724 i> hello\n
726 i> hello\n
725 o> readline() -> 4:
727 o> readline() -> 4:
726 o> 440\n
728 o> 440\n
727 o> readline() -> 440:
729 o> readline() -> 440:
728 o> capabilities: batch branchmap $USUAL_BUNDLE2_CAPS$ changegroupsubset getbundle known lookup protocaps pushkey streamreqs=generaldelta,revlogv1,sparserevlog unbundle=HG10GZ,HG10BZ,HG10UN unbundlehash\n
730 o> capabilities: batch branchmap $USUAL_BUNDLE2_CAPS$ changegroupsubset getbundle known lookup protocaps pushkey streamreqs=generaldelta,revlogv1,sparserevlog unbundle=HG10GZ,HG10BZ,HG10UN unbundlehash\n
729 i> write(98) -> 98:
731 i> write(98) -> 98:
730 i> between\n
732 i> between\n
731 i> pairs 81\n
733 i> pairs 81\n
732 i> 0000000000000000000000000000000000000000-0000000000000000000000000000000000000000
734 i> 0000000000000000000000000000000000000000-0000000000000000000000000000000000000000
733 o> readline() -> 2:
735 o> readline() -> 2:
734 o> 1\n
736 o> 1\n
735
737
736 $ hg debugwireproto --localssh --peer raw << EOF
738 $ hg debugwireproto --localssh --peer raw << EOF
737 > raw
739 > raw
738 > unknown with spaces\n
740 > unknown with spaces\n
739 > key 10\n
741 > key 10\n
740 > some value\n
742 > some value\n
741 > readline
743 > readline
742 > readline
744 > readline
743 > readline
745 > readline
744 > raw
746 > raw
745 > hello\n
747 > hello\n
746 > readline
748 > readline
747 > readline
749 > readline
748 > raw
750 > raw
749 > between\n
751 > between\n
750 > pairs 81\n
752 > pairs 81\n
751 > 0000000000000000000000000000000000000000-0000000000000000000000000000000000000000
753 > 0000000000000000000000000000000000000000-0000000000000000000000000000000000000000
752 > readline
754 > readline
753 > readline
755 > readline
754 > EOF
756 > EOF
755 using raw connection to peer
757 using raw connection to peer
756 i> write(38) -> 38:
758 i> write(38) -> 38:
757 i> unknown with spaces\n
759 i> unknown with spaces\n
758 i> key 10\n
760 i> key 10\n
759 i> some value\n
761 i> some value\n
760 o> readline() -> 2:
762 o> readline() -> 2:
761 o> 0\n
763 o> 0\n
762 o> readline() -> 2:
764 o> readline() -> 2:
763 o> 0\n
765 o> 0\n
764 o> readline() -> 2:
766 o> readline() -> 2:
765 o> 0\n
767 o> 0\n
766 i> write(6) -> 6:
768 i> write(6) -> 6:
767 i> hello\n
769 i> hello\n
768 o> readline() -> 4:
770 o> readline() -> 4:
769 o> 440\n
771 o> 440\n
770 o> readline() -> 440:
772 o> readline() -> 440:
771 o> capabilities: batch branchmap $USUAL_BUNDLE2_CAPS$ changegroupsubset getbundle known lookup protocaps pushkey streamreqs=generaldelta,revlogv1,sparserevlog unbundle=HG10GZ,HG10BZ,HG10UN unbundlehash\n
773 o> capabilities: batch branchmap $USUAL_BUNDLE2_CAPS$ changegroupsubset getbundle known lookup protocaps pushkey streamreqs=generaldelta,revlogv1,sparserevlog unbundle=HG10GZ,HG10BZ,HG10UN unbundlehash\n
772 i> write(98) -> 98:
774 i> write(98) -> 98:
773 i> between\n
775 i> between\n
774 i> pairs 81\n
776 i> pairs 81\n
775 i> 0000000000000000000000000000000000000000-0000000000000000000000000000000000000000
777 i> 0000000000000000000000000000000000000000-0000000000000000000000000000000000000000
776 o> readline() -> 2:
778 o> readline() -> 2:
777 o> 1\n
779 o> 1\n
778 o> readline() -> 1:
780 o> readline() -> 1:
779 o> \n
781 o> \n
780 Send an unknown command after the "between"
782 Send an unknown command after the "between"
781
783
782 $ hg debugwireproto --localssh --peer raw << EOF
784 $ hg debugwireproto --localssh --peer raw << EOF
783 > raw
785 > raw
784 > hello\n
786 > hello\n
785 > readline
787 > readline
786 > readline
788 > readline
787 > raw
789 > raw
788 > between\n
790 > between\n
789 > pairs 81\n
791 > pairs 81\n
790 > 0000000000000000000000000000000000000000-0000000000000000000000000000000000000000unknown
792 > 0000000000000000000000000000000000000000-0000000000000000000000000000000000000000unknown
791 > readline
793 > readline
792 > readline
794 > readline
793 > EOF
795 > EOF
794 using raw connection to peer
796 using raw connection to peer
795 i> write(6) -> 6:
797 i> write(6) -> 6:
796 i> hello\n
798 i> hello\n
797 o> readline() -> 4:
799 o> readline() -> 4:
798 o> 440\n
800 o> 440\n
799 o> readline() -> 440:
801 o> readline() -> 440:
800 o> capabilities: batch branchmap $USUAL_BUNDLE2_CAPS$ changegroupsubset getbundle known lookup protocaps pushkey streamreqs=generaldelta,revlogv1,sparserevlog unbundle=HG10GZ,HG10BZ,HG10UN unbundlehash\n
802 o> capabilities: batch branchmap $USUAL_BUNDLE2_CAPS$ changegroupsubset getbundle known lookup protocaps pushkey streamreqs=generaldelta,revlogv1,sparserevlog unbundle=HG10GZ,HG10BZ,HG10UN unbundlehash\n
801 i> write(105) -> 105:
803 i> write(105) -> 105:
802 i> between\n
804 i> between\n
803 i> pairs 81\n
805 i> pairs 81\n
804 i> 0000000000000000000000000000000000000000-0000000000000000000000000000000000000000unknown
806 i> 0000000000000000000000000000000000000000-0000000000000000000000000000000000000000unknown
805 o> readline() -> 2:
807 o> readline() -> 2:
806 o> 1\n
808 o> 1\n
807 o> readline() -> 1:
809 o> readline() -> 1:
808 o> \n
810 o> \n
809
811
810 And one with arguments
812 And one with arguments
811
813
812 $ hg debugwireproto --localssh --peer raw << EOF
814 $ hg debugwireproto --localssh --peer raw << EOF
813 > raw
815 > raw
814 > hello\n
816 > hello\n
815 > between\n
817 > between\n
816 > pairs 81\n
818 > pairs 81\n
817 > 0000000000000000000000000000000000000000-0000000000000000000000000000000000000000
819 > 0000000000000000000000000000000000000000-0000000000000000000000000000000000000000
818 > readline
820 > readline
819 > readline
821 > readline
820 > readline
822 > readline
821 > readline
823 > readline
822 > raw
824 > raw
823 > unknown\n
825 > unknown\n
824 > foo 5\n
826 > foo 5\n
825 > \nvalue\n
827 > \nvalue\n
826 > bar 3\n
828 > bar 3\n
827 > baz\n
829 > baz\n
828 > readline
830 > readline
829 > readline
831 > readline
830 > readline
832 > readline
831 > EOF
833 > EOF
832 using raw connection to peer
834 using raw connection to peer
833 i> write(104) -> 104:
835 i> write(104) -> 104:
834 i> hello\n
836 i> hello\n
835 i> between\n
837 i> between\n
836 i> pairs 81\n
838 i> pairs 81\n
837 i> 0000000000000000000000000000000000000000-0000000000000000000000000000000000000000
839 i> 0000000000000000000000000000000000000000-0000000000000000000000000000000000000000
838 o> readline() -> 4:
840 o> readline() -> 4:
839 o> 440\n
841 o> 440\n
840 o> readline() -> 440:
842 o> readline() -> 440:
841 o> capabilities: batch branchmap $USUAL_BUNDLE2_CAPS$ changegroupsubset getbundle known lookup protocaps pushkey streamreqs=generaldelta,revlogv1,sparserevlog unbundle=HG10GZ,HG10BZ,HG10UN unbundlehash\n
843 o> capabilities: batch branchmap $USUAL_BUNDLE2_CAPS$ changegroupsubset getbundle known lookup protocaps pushkey streamreqs=generaldelta,revlogv1,sparserevlog unbundle=HG10GZ,HG10BZ,HG10UN unbundlehash\n
842 o> readline() -> 2:
844 o> readline() -> 2:
843 o> 1\n
845 o> 1\n
844 o> readline() -> 1:
846 o> readline() -> 1:
845 o> \n
847 o> \n
846 i> write(31) -> 31:
848 i> write(31) -> 31:
847 i> unknown\n
849 i> unknown\n
848 i> foo 5\n
850 i> foo 5\n
849 i> \n
851 i> \n
850 i> value\n
852 i> value\n
851 i> bar 3\n
853 i> bar 3\n
852 i> baz\n
854 i> baz\n
853 o> readline() -> 2:
855 o> readline() -> 2:
854 o> 0\n
856 o> 0\n
855 o> readline() -> 2:
857 o> readline() -> 2:
856 o> 0\n
858 o> 0\n
857 o> readline() -> 0:
859 o> readline() -> 0:
858
860
859 Send a valid command before the handshake
861 Send a valid command before the handshake
860
862
861 $ hg debugwireproto --localssh --peer raw << EOF
863 $ hg debugwireproto --localssh --peer raw << EOF
862 > raw
864 > raw
863 > heads\n
865 > heads\n
864 > readline
866 > readline
865 > raw
867 > raw
866 > hello\n
868 > hello\n
867 > between\n
869 > between\n
868 > pairs 81\n
870 > pairs 81\n
869 > 0000000000000000000000000000000000000000-0000000000000000000000000000000000000000
871 > 0000000000000000000000000000000000000000-0000000000000000000000000000000000000000
870 > readline
872 > readline
871 > readline
873 > readline
872 > readline
874 > readline
873 > readline
875 > readline
874 > EOF
876 > EOF
875 using raw connection to peer
877 using raw connection to peer
876 i> write(6) -> 6:
878 i> write(6) -> 6:
877 i> heads\n
879 i> heads\n
878 o> readline() -> 3:
880 o> readline() -> 3:
879 o> 41\n
881 o> 41\n
880 i> write(104) -> 104:
882 i> write(104) -> 104:
881 i> hello\n
883 i> hello\n
882 i> between\n
884 i> between\n
883 i> pairs 81\n
885 i> pairs 81\n
884 i> 0000000000000000000000000000000000000000-0000000000000000000000000000000000000000
886 i> 0000000000000000000000000000000000000000-0000000000000000000000000000000000000000
885 o> readline() -> 41:
887 o> readline() -> 41:
886 o> 68986213bd4485ea51533535e3fc9e78007a711f\n
888 o> 68986213bd4485ea51533535e3fc9e78007a711f\n
887 o> readline() -> 4:
889 o> readline() -> 4:
888 o> 440\n
890 o> 440\n
889 o> readline() -> 440:
891 o> readline() -> 440:
890 o> capabilities: batch branchmap $USUAL_BUNDLE2_CAPS$ changegroupsubset getbundle known lookup protocaps pushkey streamreqs=generaldelta,revlogv1,sparserevlog unbundle=HG10GZ,HG10BZ,HG10UN unbundlehash\n
892 o> capabilities: batch branchmap $USUAL_BUNDLE2_CAPS$ changegroupsubset getbundle known lookup protocaps pushkey streamreqs=generaldelta,revlogv1,sparserevlog unbundle=HG10GZ,HG10BZ,HG10UN unbundlehash\n
891 o> readline() -> 2:
893 o> readline() -> 2:
892 o> 1\n
894 o> 1\n
893
895
894 And a variation that doesn't send the between command
896 And a variation that doesn't send the between command
895
897
896 $ hg debugwireproto --localssh --peer raw << EOF
898 $ hg debugwireproto --localssh --peer raw << EOF
897 > raw
899 > raw
898 > heads\n
900 > heads\n
899 > readline
901 > readline
900 > raw
902 > raw
901 > hello\n
903 > hello\n
902 > readline
904 > readline
903 > readline
905 > readline
904 > EOF
906 > EOF
905 using raw connection to peer
907 using raw connection to peer
906 i> write(6) -> 6:
908 i> write(6) -> 6:
907 i> heads\n
909 i> heads\n
908 o> readline() -> 3:
910 o> readline() -> 3:
909 o> 41\n
911 o> 41\n
910 i> write(6) -> 6:
912 i> write(6) -> 6:
911 i> hello\n
913 i> hello\n
912 o> readline() -> 41:
914 o> readline() -> 41:
913 o> 68986213bd4485ea51533535e3fc9e78007a711f\n
915 o> 68986213bd4485ea51533535e3fc9e78007a711f\n
914 o> readline() -> 4:
916 o> readline() -> 4:
915 o> 440\n
917 o> 440\n
916
918
917 Send an upgrade request to a server that doesn't support that command
919 Send an upgrade request to a server that doesn't support that command
918
920
919 $ hg debugwireproto --localssh --peer raw << EOF
921 $ hg debugwireproto --localssh --peer raw << EOF
920 > raw
922 > raw
921 > upgrade 2e82ab3f-9ce3-4b4e-8f8c-6fd1c0e9e23a proto=irrelevant1%2Cirrelevant2\n
923 > upgrade 2e82ab3f-9ce3-4b4e-8f8c-6fd1c0e9e23a proto=irrelevant1%2Cirrelevant2\n
922 > readline
924 > readline
923 > raw
925 > raw
924 > hello\n
926 > hello\n
925 > between\n
927 > between\n
926 > pairs 81\n
928 > pairs 81\n
927 > 0000000000000000000000000000000000000000-0000000000000000000000000000000000000000
929 > 0000000000000000000000000000000000000000-0000000000000000000000000000000000000000
928 > readline
930 > readline
929 > readline
931 > readline
930 > readline
932 > readline
931 > readline
933 > readline
932 > EOF
934 > EOF
933 using raw connection to peer
935 using raw connection to peer
934 i> write(77) -> 77:
936 i> write(77) -> 77:
935 i> upgrade 2e82ab3f-9ce3-4b4e-8f8c-6fd1c0e9e23a proto=irrelevant1%2Cirrelevant2\n
937 i> upgrade 2e82ab3f-9ce3-4b4e-8f8c-6fd1c0e9e23a proto=irrelevant1%2Cirrelevant2\n
936 o> readline() -> 2:
938 o> readline() -> 2:
937 o> 0\n
939 o> 0\n
938 i> write(104) -> 104:
940 i> write(104) -> 104:
939 i> hello\n
941 i> hello\n
940 i> between\n
942 i> between\n
941 i> pairs 81\n
943 i> pairs 81\n
942 i> 0000000000000000000000000000000000000000-0000000000000000000000000000000000000000
944 i> 0000000000000000000000000000000000000000-0000000000000000000000000000000000000000
943 o> readline() -> 4:
945 o> readline() -> 4:
944 o> 440\n
946 o> 440\n
945 o> readline() -> 440:
947 o> readline() -> 440:
946 o> capabilities: batch branchmap $USUAL_BUNDLE2_CAPS$ changegroupsubset getbundle known lookup protocaps pushkey streamreqs=generaldelta,revlogv1,sparserevlog unbundle=HG10GZ,HG10BZ,HG10UN unbundlehash\n
948 o> capabilities: batch branchmap $USUAL_BUNDLE2_CAPS$ changegroupsubset getbundle known lookup protocaps pushkey streamreqs=generaldelta,revlogv1,sparserevlog unbundle=HG10GZ,HG10BZ,HG10UN unbundlehash\n
947 o> readline() -> 2:
949 o> readline() -> 2:
948 o> 1\n
950 o> 1\n
949 o> readline() -> 1:
951 o> readline() -> 1:
950 o> \n
952 o> \n
951
953
952 $ cd ..
954 $ cd ..
953
955
954 $ hg --config experimental.sshpeer.advertise-v2=true --debug debugpeer ssh://user@dummy/server
956 $ hg --config experimental.sshpeer.advertise-v2=true --debug debugpeer ssh://user@dummy/server
955 running * "*/tests/dummyssh" 'user@dummy' 'hg -R server serve --stdio' (glob) (no-windows !)
957 running * "*/tests/dummyssh" 'user@dummy' 'hg -R server serve --stdio' (glob) (no-windows !)
956 running * "*\tests/dummyssh" "user@dummy" "hg -R server serve --stdio" (glob) (windows !)
958 running * "*\tests/dummyssh" "user@dummy" "hg -R server serve --stdio" (glob) (windows !)
957 sending upgrade request: * proto=exp-ssh-v2-0003 (glob)
959 sending upgrade request: * proto=exp-ssh-v2-0003 (glob)
958 devel-peer-request: hello+between
960 devel-peer-request: hello+between
959 devel-peer-request: pairs: 81 bytes
961 devel-peer-request: pairs: 81 bytes
960 sending hello command
962 sending hello command
961 sending between command
963 sending between command
962 remote: 0
964 remote: 0
963 remote: 440
965 remote: 440
964 remote: capabilities: batch branchmap $USUAL_BUNDLE2_CAPS$ changegroupsubset getbundle known lookup protocaps pushkey streamreqs=generaldelta,revlogv1,sparserevlog unbundle=HG10GZ,HG10BZ,HG10UN unbundlehash
966 remote: capabilities: batch branchmap $USUAL_BUNDLE2_CAPS$ changegroupsubset getbundle known lookup protocaps pushkey streamreqs=generaldelta,revlogv1,sparserevlog unbundle=HG10GZ,HG10BZ,HG10UN unbundlehash
965 remote: 1
967 remote: 1
966 devel-peer-request: protocaps
968 devel-peer-request: protocaps
967 devel-peer-request: caps: * bytes (glob)
969 devel-peer-request: caps: * bytes (glob)
968 sending protocaps command
970 sending protocaps command
969 url: ssh://user@dummy/server
971 url: ssh://user@dummy/server
970 local: no
972 local: no
971 pushable: yes
973 pushable: yes
972
974
973 Enable version 2 support on server. We need to do this in hgrc because we can't
975 Enable version 2 support on server. We need to do this in hgrc because we can't
974 use --config with `hg serve --stdio`.
976 use --config with `hg serve --stdio`.
975
977
976 $ cat >> server/.hg/hgrc << EOF
978 $ cat >> server/.hg/hgrc << EOF
977 > [experimental]
979 > [experimental]
978 > sshserver.support-v2 = true
980 > sshserver.support-v2 = true
979 > EOF
981 > EOF
980
982
981 Send an upgrade request to a server that supports upgrade
983 Send an upgrade request to a server that supports upgrade
982
984
983 $ cd server
985 $ cd server
984
986
985 $ hg debugwireproto --localssh --peer raw << EOF
987 $ hg debugwireproto --localssh --peer raw << EOF
986 > raw
988 > raw
987 > upgrade this-is-some-token proto=exp-ssh-v2-0003\n
989 > upgrade this-is-some-token proto=exp-ssh-v2-0003\n
988 > hello\n
990 > hello\n
989 > between\n
991 > between\n
990 > pairs 81\n
992 > pairs 81\n
991 > 0000000000000000000000000000000000000000-0000000000000000000000000000000000000000
993 > 0000000000000000000000000000000000000000-0000000000000000000000000000000000000000
992 > readline
994 > readline
993 > readline
995 > readline
994 > readline
996 > readline
995 > EOF
997 > EOF
996 using raw connection to peer
998 using raw connection to peer
997 i> write(153) -> 153:
999 i> write(153) -> 153:
998 i> upgrade this-is-some-token proto=exp-ssh-v2-0003\n
1000 i> upgrade this-is-some-token proto=exp-ssh-v2-0003\n
999 i> hello\n
1001 i> hello\n
1000 i> between\n
1002 i> between\n
1001 i> pairs 81\n
1003 i> pairs 81\n
1002 i> 0000000000000000000000000000000000000000-0000000000000000000000000000000000000000
1004 i> 0000000000000000000000000000000000000000-0000000000000000000000000000000000000000
1003 o> readline() -> 44:
1005 o> readline() -> 44:
1004 o> upgraded this-is-some-token exp-ssh-v2-0003\n
1006 o> upgraded this-is-some-token exp-ssh-v2-0003\n
1005 o> readline() -> 4:
1007 o> readline() -> 4:
1006 o> 439\n
1008 o> 439\n
1007 o> readline() -> 440:
1009 o> readline() -> 440:
1008 o> capabilities: batch branchmap $USUAL_BUNDLE2_CAPS$ changegroupsubset getbundle known lookup protocaps pushkey streamreqs=generaldelta,revlogv1,sparserevlog unbundle=HG10GZ,HG10BZ,HG10UN unbundlehash\n
1010 o> capabilities: batch branchmap $USUAL_BUNDLE2_CAPS$ changegroupsubset getbundle known lookup protocaps pushkey streamreqs=generaldelta,revlogv1,sparserevlog unbundle=HG10GZ,HG10BZ,HG10UN unbundlehash\n
1009
1011
1010 $ cd ..
1012 $ cd ..
1011
1013
1012 $ hg --config experimental.sshpeer.advertise-v2=true --debug debugpeer ssh://user@dummy/server
1014 $ hg --config experimental.sshpeer.advertise-v2=true --debug debugpeer ssh://user@dummy/server
1013 running * "*/tests/dummyssh" 'user@dummy' 'hg -R server serve --stdio' (glob) (no-windows !)
1015 running * "*/tests/dummyssh" 'user@dummy' 'hg -R server serve --stdio' (glob) (no-windows !)
1014 running * "*\tests/dummyssh" "user@dummy" "hg -R server serve --stdio" (glob) (windows !)
1016 running * "*\tests/dummyssh" "user@dummy" "hg -R server serve --stdio" (glob) (windows !)
1015 sending upgrade request: * proto=exp-ssh-v2-0003 (glob)
1017 sending upgrade request: * proto=exp-ssh-v2-0003 (glob)
1016 devel-peer-request: hello+between
1018 devel-peer-request: hello+between
1017 devel-peer-request: pairs: 81 bytes
1019 devel-peer-request: pairs: 81 bytes
1018 sending hello command
1020 sending hello command
1019 sending between command
1021 sending between command
1020 protocol upgraded to exp-ssh-v2-0003
1022 protocol upgraded to exp-ssh-v2-0003
1021 remote: capabilities: batch branchmap $USUAL_BUNDLE2_CAPS$ changegroupsubset getbundle known lookup protocaps pushkey streamreqs=generaldelta,revlogv1,sparserevlog unbundle=HG10GZ,HG10BZ,HG10UN unbundlehash
1023 remote: capabilities: batch branchmap $USUAL_BUNDLE2_CAPS$ changegroupsubset getbundle known lookup protocaps pushkey streamreqs=generaldelta,revlogv1,sparserevlog unbundle=HG10GZ,HG10BZ,HG10UN unbundlehash
1022 devel-peer-request: protocaps
1024 devel-peer-request: protocaps
1023 devel-peer-request: caps: * bytes (glob)
1025 devel-peer-request: caps: * bytes (glob)
1024 sending protocaps command
1026 sending protocaps command
1025 url: ssh://user@dummy/server
1027 url: ssh://user@dummy/server
1026 local: no
1028 local: no
1027 pushable: yes
1029 pushable: yes
1028
1030
1029 Verify the peer has capabilities
1031 Verify the peer has capabilities
1030
1032
1031 $ hg --config experimental.sshpeer.advertise-v2=true --debug debugcapabilities ssh://user@dummy/server
1033 $ hg --config experimental.sshpeer.advertise-v2=true --debug debugcapabilities ssh://user@dummy/server
1032 running * "*/tests/dummyssh" 'user@dummy' 'hg -R server serve --stdio' (glob) (no-windows !)
1034 running * "*/tests/dummyssh" 'user@dummy' 'hg -R server serve --stdio' (glob) (no-windows !)
1033 running * "*\tests/dummyssh" "user@dummy" "hg -R server serve --stdio" (glob) (windows !)
1035 running * "*\tests/dummyssh" "user@dummy" "hg -R server serve --stdio" (glob) (windows !)
1034 sending upgrade request: * proto=exp-ssh-v2-0003 (glob)
1036 sending upgrade request: * proto=exp-ssh-v2-0003 (glob)
1035 devel-peer-request: hello+between
1037 devel-peer-request: hello+between
1036 devel-peer-request: pairs: 81 bytes
1038 devel-peer-request: pairs: 81 bytes
1037 sending hello command
1039 sending hello command
1038 sending between command
1040 sending between command
1039 protocol upgraded to exp-ssh-v2-0003
1041 protocol upgraded to exp-ssh-v2-0003
1040 remote: capabilities: batch branchmap $USUAL_BUNDLE2_CAPS$ changegroupsubset getbundle known lookup protocaps pushkey streamreqs=generaldelta,revlogv1,sparserevlog unbundle=HG10GZ,HG10BZ,HG10UN unbundlehash
1042 remote: capabilities: batch branchmap $USUAL_BUNDLE2_CAPS$ changegroupsubset getbundle known lookup protocaps pushkey streamreqs=generaldelta,revlogv1,sparserevlog unbundle=HG10GZ,HG10BZ,HG10UN unbundlehash
1041 devel-peer-request: protocaps
1043 devel-peer-request: protocaps
1042 devel-peer-request: caps: * bytes (glob)
1044 devel-peer-request: caps: * bytes (glob)
1043 sending protocaps command
1045 sending protocaps command
1044 Main capabilities:
1046 Main capabilities:
1045 batch
1047 batch
1046 branchmap
1048 branchmap
1047 $USUAL_BUNDLE2_CAPS$
1049 $USUAL_BUNDLE2_CAPS$
1048 changegroupsubset
1050 changegroupsubset
1049 getbundle
1051 getbundle
1050 known
1052 known
1051 lookup
1053 lookup
1052 protocaps
1054 protocaps
1053 pushkey
1055 pushkey
1054 streamreqs=generaldelta,revlogv1,sparserevlog
1056 streamreqs=generaldelta,revlogv1,sparserevlog
1055 unbundle=HG10GZ,HG10BZ,HG10UN
1057 unbundle=HG10GZ,HG10BZ,HG10UN
1056 unbundlehash
1058 unbundlehash
1057 Bundle2 capabilities:
1059 Bundle2 capabilities:
1058 HG20
1060 HG20
1059 bookmarks
1061 bookmarks
1060 changegroup
1062 changegroup
1061 01
1063 01
1062 02
1064 02
1063 digests
1065 digests
1064 md5
1066 md5
1065 sha1
1067 sha1
1066 sha512
1068 sha512
1067 error
1069 error
1068 abort
1070 abort
1069 unsupportedcontent
1071 unsupportedcontent
1070 pushraced
1072 pushraced
1071 pushkey
1073 pushkey
1072 hgtagsfnodes
1074 hgtagsfnodes
1073 listkeys
1075 listkeys
1074 phases
1076 phases
1075 heads
1077 heads
1076 pushkey
1078 pushkey
1077 remote-changegroup
1079 remote-changegroup
1078 http
1080 http
1079 https
1081 https
1080 rev-branch-cache
1082 rev-branch-cache
1081 stream
1083 stream
1082 v2
1084 v2
1083
1085
1084 Command after upgrade to version 2 is processed
1086 Command after upgrade to version 2 is processed
1085
1087
1086 $ cd server
1088 $ cd server
1087
1089
1088 $ hg debugwireproto --localssh --peer raw << EOF
1090 $ hg debugwireproto --localssh --peer raw << EOF
1089 > raw
1091 > raw
1090 > upgrade this-is-some-token proto=exp-ssh-v2-0003\n
1092 > upgrade this-is-some-token proto=exp-ssh-v2-0003\n
1091 > hello\n
1093 > hello\n
1092 > between\n
1094 > between\n
1093 > pairs 81\n
1095 > pairs 81\n
1094 > 0000000000000000000000000000000000000000-0000000000000000000000000000000000000000
1096 > 0000000000000000000000000000000000000000-0000000000000000000000000000000000000000
1095 > readline
1097 > readline
1096 > readline
1098 > readline
1097 > readline
1099 > readline
1098 > raw
1100 > raw
1099 > hello\n
1101 > hello\n
1100 > readline
1102 > readline
1101 > readline
1103 > readline
1102 > EOF
1104 > EOF
1103 using raw connection to peer
1105 using raw connection to peer
1104 i> write(153) -> 153:
1106 i> write(153) -> 153:
1105 i> upgrade this-is-some-token proto=exp-ssh-v2-0003\n
1107 i> upgrade this-is-some-token proto=exp-ssh-v2-0003\n
1106 i> hello\n
1108 i> hello\n
1107 i> between\n
1109 i> between\n
1108 i> pairs 81\n
1110 i> pairs 81\n
1109 i> 0000000000000000000000000000000000000000-0000000000000000000000000000000000000000
1111 i> 0000000000000000000000000000000000000000-0000000000000000000000000000000000000000
1110 o> readline() -> 44:
1112 o> readline() -> 44:
1111 o> upgraded this-is-some-token exp-ssh-v2-0003\n
1113 o> upgraded this-is-some-token exp-ssh-v2-0003\n
1112 o> readline() -> 4:
1114 o> readline() -> 4:
1113 o> 439\n
1115 o> 439\n
1114 o> readline() -> 440:
1116 o> readline() -> 440:
1115 o> capabilities: batch branchmap $USUAL_BUNDLE2_CAPS$ changegroupsubset getbundle known lookup protocaps pushkey streamreqs=generaldelta,revlogv1,sparserevlog unbundle=HG10GZ,HG10BZ,HG10UN unbundlehash\n
1117 o> capabilities: batch branchmap $USUAL_BUNDLE2_CAPS$ changegroupsubset getbundle known lookup protocaps pushkey streamreqs=generaldelta,revlogv1,sparserevlog unbundle=HG10GZ,HG10BZ,HG10UN unbundlehash\n
1116 i> write(6) -> 6:
1118 i> write(6) -> 6:
1117 i> hello\n
1119 i> hello\n
1118 o> readline() -> 4:
1120 o> readline() -> 4:
1119 o> 424\n
1121 o> 424\n
1120 o> readline() -> 424:
1122 o> readline() -> 424:
1121 o> capabilities: branchmap $USUAL_BUNDLE2_CAPS$ changegroupsubset getbundle known lookup pushkey streamreqs=generaldelta,revlogv1,sparserevlog unbundle=HG10GZ,HG10BZ,HG10UN unbundlehash\n
1123 o> capabilities: branchmap $USUAL_BUNDLE2_CAPS$ changegroupsubset getbundle known lookup pushkey streamreqs=generaldelta,revlogv1,sparserevlog unbundle=HG10GZ,HG10BZ,HG10UN unbundlehash\n
1122
1124
1123 Multiple upgrades is not allowed
1125 Multiple upgrades is not allowed
1124
1126
1125 $ hg debugwireproto --localssh --peer raw << EOF
1127 $ hg debugwireproto --localssh --peer raw << EOF
1126 > raw
1128 > raw
1127 > upgrade this-is-some-token proto=exp-ssh-v2-0003\n
1129 > upgrade this-is-some-token proto=exp-ssh-v2-0003\n
1128 > hello\n
1130 > hello\n
1129 > between\n
1131 > between\n
1130 > pairs 81\n
1132 > pairs 81\n
1131 > 0000000000000000000000000000000000000000-0000000000000000000000000000000000000000
1133 > 0000000000000000000000000000000000000000-0000000000000000000000000000000000000000
1132 > readline
1134 > readline
1133 > readline
1135 > readline
1134 > readline
1136 > readline
1135 > raw
1137 > raw
1136 > upgrade another-token proto=irrelevant\n
1138 > upgrade another-token proto=irrelevant\n
1137 > hello\n
1139 > hello\n
1138 > readline
1140 > readline
1139 > readavailable
1141 > readavailable
1140 > EOF
1142 > EOF
1141 using raw connection to peer
1143 using raw connection to peer
1142 i> write(153) -> 153:
1144 i> write(153) -> 153:
1143 i> upgrade this-is-some-token proto=exp-ssh-v2-0003\n
1145 i> upgrade this-is-some-token proto=exp-ssh-v2-0003\n
1144 i> hello\n
1146 i> hello\n
1145 i> between\n
1147 i> between\n
1146 i> pairs 81\n
1148 i> pairs 81\n
1147 i> 0000000000000000000000000000000000000000-0000000000000000000000000000000000000000
1149 i> 0000000000000000000000000000000000000000-0000000000000000000000000000000000000000
1148 o> readline() -> 44:
1150 o> readline() -> 44:
1149 o> upgraded this-is-some-token exp-ssh-v2-0003\n
1151 o> upgraded this-is-some-token exp-ssh-v2-0003\n
1150 o> readline() -> 4:
1152 o> readline() -> 4:
1151 o> 439\n
1153 o> 439\n
1152 o> readline() -> 440:
1154 o> readline() -> 440:
1153 o> capabilities: batch branchmap $USUAL_BUNDLE2_CAPS$ changegroupsubset getbundle known lookup protocaps pushkey streamreqs=generaldelta,revlogv1,sparserevlog unbundle=HG10GZ,HG10BZ,HG10UN unbundlehash\n
1155 o> capabilities: batch branchmap $USUAL_BUNDLE2_CAPS$ changegroupsubset getbundle known lookup protocaps pushkey streamreqs=generaldelta,revlogv1,sparserevlog unbundle=HG10GZ,HG10BZ,HG10UN unbundlehash\n
1154 i> write(45) -> 45:
1156 i> write(45) -> 45:
1155 i> upgrade another-token proto=irrelevant\n
1157 i> upgrade another-token proto=irrelevant\n
1156 i> hello\n
1158 i> hello\n
1157 o> readline() -> 1:
1159 o> readline() -> 1:
1158 o> \n
1160 o> \n
1159 e> read(-1) -> 42:
1161 e> read(-1) -> 42:
1160 e> cannot upgrade protocols multiple times\n
1162 e> cannot upgrade protocols multiple times\n
1161 e> -\n
1163 e> -\n
1162
1164
1163 Malformed upgrade request line (not exactly 3 space delimited tokens)
1165 Malformed upgrade request line (not exactly 3 space delimited tokens)
1164
1166
1165 $ hg debugwireproto --localssh --peer raw << EOF
1167 $ hg debugwireproto --localssh --peer raw << EOF
1166 > raw
1168 > raw
1167 > upgrade\n
1169 > upgrade\n
1168 > readline
1170 > readline
1169 > EOF
1171 > EOF
1170 using raw connection to peer
1172 using raw connection to peer
1171 i> write(8) -> 8:
1173 i> write(8) -> 8:
1172 i> upgrade\n
1174 i> upgrade\n
1173 o> readline() -> 2:
1175 o> readline() -> 2:
1174 o> 0\n
1176 o> 0\n
1175
1177
1176 $ hg debugwireproto --localssh --peer raw << EOF
1178 $ hg debugwireproto --localssh --peer raw << EOF
1177 > raw
1179 > raw
1178 > upgrade token\n
1180 > upgrade token\n
1179 > readline
1181 > readline
1180 > EOF
1182 > EOF
1181 using raw connection to peer
1183 using raw connection to peer
1182 i> write(14) -> 14:
1184 i> write(14) -> 14:
1183 i> upgrade token\n
1185 i> upgrade token\n
1184 o> readline() -> 2:
1186 o> readline() -> 2:
1185 o> 0\n
1187 o> 0\n
1186
1188
1187 $ hg debugwireproto --localssh --peer raw << EOF
1189 $ hg debugwireproto --localssh --peer raw << EOF
1188 > raw
1190 > raw
1189 > upgrade token foo=bar extra-token\n
1191 > upgrade token foo=bar extra-token\n
1190 > readline
1192 > readline
1191 > EOF
1193 > EOF
1192 using raw connection to peer
1194 using raw connection to peer
1193 i> write(34) -> 34:
1195 i> write(34) -> 34:
1194 i> upgrade token foo=bar extra-token\n
1196 i> upgrade token foo=bar extra-token\n
1195 o> readline() -> 2:
1197 o> readline() -> 2:
1196 o> 0\n
1198 o> 0\n
1197
1199
1198 Upgrade request to unsupported protocol is ignored
1200 Upgrade request to unsupported protocol is ignored
1199
1201
1200 $ hg debugwireproto --localssh --peer raw << EOF
1202 $ hg debugwireproto --localssh --peer raw << EOF
1201 > raw
1203 > raw
1202 > upgrade this-is-some-token proto=unknown1,unknown2\n
1204 > upgrade this-is-some-token proto=unknown1,unknown2\n
1203 > readline
1205 > readline
1204 > raw
1206 > raw
1205 > hello\n
1207 > hello\n
1206 > readline
1208 > readline
1207 > readline
1209 > readline
1208 > raw
1210 > raw
1209 > between\n
1211 > between\n
1210 > pairs 81\n
1212 > pairs 81\n
1211 > 0000000000000000000000000000000000000000-0000000000000000000000000000000000000000
1213 > 0000000000000000000000000000000000000000-0000000000000000000000000000000000000000
1212 > readline
1214 > readline
1213 > readline
1215 > readline
1214 > EOF
1216 > EOF
1215 using raw connection to peer
1217 using raw connection to peer
1216 i> write(51) -> 51:
1218 i> write(51) -> 51:
1217 i> upgrade this-is-some-token proto=unknown1,unknown2\n
1219 i> upgrade this-is-some-token proto=unknown1,unknown2\n
1218 o> readline() -> 2:
1220 o> readline() -> 2:
1219 o> 0\n
1221 o> 0\n
1220 i> write(6) -> 6:
1222 i> write(6) -> 6:
1221 i> hello\n
1223 i> hello\n
1222 o> readline() -> 4:
1224 o> readline() -> 4:
1223 o> 440\n
1225 o> 440\n
1224 o> readline() -> 440:
1226 o> readline() -> 440:
1225 o> capabilities: batch branchmap $USUAL_BUNDLE2_CAPS$ changegroupsubset getbundle known lookup protocaps pushkey streamreqs=generaldelta,revlogv1,sparserevlog unbundle=HG10GZ,HG10BZ,HG10UN unbundlehash\n
1227 o> capabilities: batch branchmap $USUAL_BUNDLE2_CAPS$ changegroupsubset getbundle known lookup protocaps pushkey streamreqs=generaldelta,revlogv1,sparserevlog unbundle=HG10GZ,HG10BZ,HG10UN unbundlehash\n
1226 i> write(98) -> 98:
1228 i> write(98) -> 98:
1227 i> between\n
1229 i> between\n
1228 i> pairs 81\n
1230 i> pairs 81\n
1229 i> 0000000000000000000000000000000000000000-0000000000000000000000000000000000000000
1231 i> 0000000000000000000000000000000000000000-0000000000000000000000000000000000000000
1230 o> readline() -> 2:
1232 o> readline() -> 2:
1231 o> 1\n
1233 o> 1\n
1232 o> readline() -> 1:
1234 o> readline() -> 1:
1233 o> \n
1235 o> \n
1234
1236
1235 Upgrade request must be followed by hello + between
1237 Upgrade request must be followed by hello + between
1236
1238
1237 $ hg debugwireproto --localssh --peer raw << EOF
1239 $ hg debugwireproto --localssh --peer raw << EOF
1238 > raw
1240 > raw
1239 > upgrade token proto=exp-ssh-v2-0003\n
1241 > upgrade token proto=exp-ssh-v2-0003\n
1240 > invalid\n
1242 > invalid\n
1241 > readline
1243 > readline
1242 > readavailable
1244 > readavailable
1243 > EOF
1245 > EOF
1244 using raw connection to peer
1246 using raw connection to peer
1245 i> write(44) -> 44:
1247 i> write(44) -> 44:
1246 i> upgrade token proto=exp-ssh-v2-0003\n
1248 i> upgrade token proto=exp-ssh-v2-0003\n
1247 i> invalid\n
1249 i> invalid\n
1248 o> readline() -> 1:
1250 o> readline() -> 1:
1249 o> \n
1251 o> \n
1250 e> read(-1) -> 46:
1252 e> read(-1) -> 46:
1251 e> malformed handshake protocol: missing hello\n
1253 e> malformed handshake protocol: missing hello\n
1252 e> -\n
1254 e> -\n
1253
1255
1254 $ hg debugwireproto --localssh --peer raw << EOF
1256 $ hg debugwireproto --localssh --peer raw << EOF
1255 > raw
1257 > raw
1256 > upgrade token proto=exp-ssh-v2-0003\n
1258 > upgrade token proto=exp-ssh-v2-0003\n
1257 > hello\n
1259 > hello\n
1258 > invalid\n
1260 > invalid\n
1259 > readline
1261 > readline
1260 > readavailable
1262 > readavailable
1261 > EOF
1263 > EOF
1262 using raw connection to peer
1264 using raw connection to peer
1263 i> write(50) -> 50:
1265 i> write(50) -> 50:
1264 i> upgrade token proto=exp-ssh-v2-0003\n
1266 i> upgrade token proto=exp-ssh-v2-0003\n
1265 i> hello\n
1267 i> hello\n
1266 i> invalid\n
1268 i> invalid\n
1267 o> readline() -> 1:
1269 o> readline() -> 1:
1268 o> \n
1270 o> \n
1269 e> read(-1) -> 48:
1271 e> read(-1) -> 48:
1270 e> malformed handshake protocol: missing between\n
1272 e> malformed handshake protocol: missing between\n
1271 e> -\n
1273 e> -\n
1272
1274
1273 $ hg debugwireproto --localssh --peer raw << EOF
1275 $ hg debugwireproto --localssh --peer raw << EOF
1274 > raw
1276 > raw
1275 > upgrade token proto=exp-ssh-v2-0003\n
1277 > upgrade token proto=exp-ssh-v2-0003\n
1276 > hello\n
1278 > hello\n
1277 > between\n
1279 > between\n
1278 > invalid\n
1280 > invalid\n
1279 > readline
1281 > readline
1280 > readavailable
1282 > readavailable
1281 > EOF
1283 > EOF
1282 using raw connection to peer
1284 using raw connection to peer
1283 i> write(58) -> 58:
1285 i> write(58) -> 58:
1284 i> upgrade token proto=exp-ssh-v2-0003\n
1286 i> upgrade token proto=exp-ssh-v2-0003\n
1285 i> hello\n
1287 i> hello\n
1286 i> between\n
1288 i> between\n
1287 i> invalid\n
1289 i> invalid\n
1288 o> readline() -> 1:
1290 o> readline() -> 1:
1289 o> \n
1291 o> \n
1290 e> read(-1) -> 49:
1292 e> read(-1) -> 49:
1291 e> malformed handshake protocol: missing pairs 81\n
1293 e> malformed handshake protocol: missing pairs 81\n
1292 e> -\n
1294 e> -\n
1293
1295
1294 Legacy commands are not exposed to version 2 of protocol
1296 Legacy commands are not exposed to version 2 of protocol
1295
1297
1296 TODO re-enable these once we're back to actually using v2 commands
1298 TODO re-enable these once we're back to actually using v2 commands
1297
1299
1298 $ hg --config experimental.sshpeer.advertise-v2=true debugwireproto --localssh << EOF
1300 $ hg --config experimental.sshpeer.advertise-v2=true debugwireproto --localssh << EOF
1299 > command branches
1301 > command branches
1300 > nodes 0000000000000000000000000000000000000000
1302 > nodes 0000000000000000000000000000000000000000
1301 > EOF
1303 > EOF
1302 creating ssh peer from handshake results
1304 creating ssh peer from handshake results
1303 sending branches command
1305 sending branches command
1304 response:
1306 response:
1305
1307
1306 $ hg --config experimental.sshpeer.advertise-v2=true debugwireproto --localssh << EOF
1308 $ hg --config experimental.sshpeer.advertise-v2=true debugwireproto --localssh << EOF
1307 > command changegroup
1309 > command changegroup
1308 > roots 0000000000000000000000000000000000000000
1310 > roots 0000000000000000000000000000000000000000
1309 > EOF
1311 > EOF
1310 creating ssh peer from handshake results
1312 creating ssh peer from handshake results
1311 sending changegroup command
1313 sending changegroup command
1312 response:
1314 response:
1313
1315
1314 $ hg --config experimental.sshpeer.advertise-v2=true debugwireproto --localssh << EOF
1316 $ hg --config experimental.sshpeer.advertise-v2=true debugwireproto --localssh << EOF
1315 > command changegroupsubset
1317 > command changegroupsubset
1316 > bases 0000000000000000000000000000000000000000
1318 > bases 0000000000000000000000000000000000000000
1317 > heads 0000000000000000000000000000000000000000
1319 > heads 0000000000000000000000000000000000000000
1318 > EOF
1320 > EOF
1319 creating ssh peer from handshake results
1321 creating ssh peer from handshake results
1320 sending changegroupsubset command
1322 sending changegroupsubset command
1321 response:
1323 response:
1322
1324
1323 $ cd ..
1325 $ cd ..
1324
1326
1325 Test listkeys for listing namespaces
1327 Test listkeys for listing namespaces
1326
1328
1327 $ hg init empty
1329 $ hg init empty
1328 $ cd empty
1330 $ cd empty
1329 $ debugwireproto << EOF
1331 $ debugwireproto << EOF
1330 > command listkeys
1332 > command listkeys
1331 > namespace namespaces
1333 > namespace namespaces
1332 > EOF
1334 > EOF
1333 testing ssh1
1335 testing ssh1
1334 creating ssh peer from handshake results
1336 creating ssh peer from handshake results
1335 i> write(104) -> 104:
1337 i> write(104) -> 104:
1336 i> hello\n
1338 i> hello\n
1337 i> between\n
1339 i> between\n
1338 i> pairs 81\n
1340 i> pairs 81\n
1339 i> 0000000000000000000000000000000000000000-0000000000000000000000000000000000000000
1341 i> 0000000000000000000000000000000000000000-0000000000000000000000000000000000000000
1340 i> flush() -> None
1342 i> flush() -> None
1341 o> readline() -> 4:
1343 o> readline() -> 4:
1342 o> 440\n
1344 o> 440\n
1343 o> readline() -> 440:
1345 o> readline() -> 440:
1344 o> capabilities: batch branchmap $USUAL_BUNDLE2_CAPS$ changegroupsubset getbundle known lookup protocaps pushkey streamreqs=generaldelta,revlogv1,sparserevlog unbundle=HG10GZ,HG10BZ,HG10UN unbundlehash\n
1346 o> capabilities: batch branchmap $USUAL_BUNDLE2_CAPS$ changegroupsubset getbundle known lookup protocaps pushkey streamreqs=generaldelta,revlogv1,sparserevlog unbundle=HG10GZ,HG10BZ,HG10UN unbundlehash\n
1345 o> readline() -> 2:
1347 o> readline() -> 2:
1346 o> 1\n
1348 o> 1\n
1347 o> readline() -> 1:
1349 o> readline() -> 1:
1348 o> \n
1350 o> \n
1349 sending listkeys command
1351 sending listkeys command
1350 i> write(9) -> 9:
1352 i> write(9) -> 9:
1351 i> listkeys\n
1353 i> listkeys\n
1352 i> write(13) -> 13:
1354 i> write(13) -> 13:
1353 i> namespace 10\n
1355 i> namespace 10\n
1354 i> write(10) -> 10: namespaces
1356 i> write(10) -> 10: namespaces
1355 i> flush() -> None
1357 i> flush() -> None
1356 o> bufferedreadline() -> 3:
1358 o> bufferedreadline() -> 3:
1357 o> 30\n
1359 o> 30\n
1358 o> bufferedread(30) -> 30:
1360 o> bufferedread(30) -> 30:
1359 o> bookmarks\t\n
1361 o> bookmarks\t\n
1360 o> namespaces\t\n
1362 o> namespaces\t\n
1361 o> phases\t
1363 o> phases\t
1362 response: {
1364 response: {
1363 b'bookmarks': b'',
1365 b'bookmarks': b'',
1364 b'namespaces': b'',
1366 b'namespaces': b'',
1365 b'phases': b''
1367 b'phases': b''
1366 }
1368 }
1367
1369
1368 testing ssh2
1370 testing ssh2
1369 creating ssh peer from handshake results
1371 creating ssh peer from handshake results
1370 i> write(171) -> 171:
1372 i> write(171) -> 171:
1371 i> upgrade * proto=exp-ssh-v2-0003\n (glob)
1373 i> upgrade * proto=exp-ssh-v2-0003\n (glob)
1372 i> hello\n
1374 i> hello\n
1373 i> between\n
1375 i> between\n
1374 i> pairs 81\n
1376 i> pairs 81\n
1375 i> 0000000000000000000000000000000000000000-0000000000000000000000000000000000000000
1377 i> 0000000000000000000000000000000000000000-0000000000000000000000000000000000000000
1376 i> flush() -> None
1378 i> flush() -> None
1377 o> readline() -> 62:
1379 o> readline() -> 62:
1378 o> upgraded * exp-ssh-v2-0003\n (glob)
1380 o> upgraded * exp-ssh-v2-0003\n (glob)
1379 o> readline() -> 4:
1381 o> readline() -> 4:
1380 o> 439\n
1382 o> 439\n
1381 o> read(439) -> 439: capabilities: batch branchmap $USUAL_BUNDLE2_CAPS$ changegroupsubset getbundle known lookup protocaps pushkey streamreqs=generaldelta,revlogv1,sparserevlog unbundle=HG10GZ,HG10BZ,HG10UN unbundlehash
1383 o> read(439) -> 439: capabilities: batch branchmap $USUAL_BUNDLE2_CAPS$ changegroupsubset getbundle known lookup protocaps pushkey streamreqs=generaldelta,revlogv1,sparserevlog unbundle=HG10GZ,HG10BZ,HG10UN unbundlehash
1382 o> read(1) -> 1:
1384 o> read(1) -> 1:
1383 o> \n
1385 o> \n
1384 sending listkeys command
1386 sending listkeys command
1385 i> write(9) -> 9:
1387 i> write(9) -> 9:
1386 i> listkeys\n
1388 i> listkeys\n
1387 i> write(13) -> 13:
1389 i> write(13) -> 13:
1388 i> namespace 10\n
1390 i> namespace 10\n
1389 i> write(10) -> 10: namespaces
1391 i> write(10) -> 10: namespaces
1390 i> flush() -> None
1392 i> flush() -> None
1391 o> bufferedreadline() -> 3:
1393 o> bufferedreadline() -> 3:
1392 o> 30\n
1394 o> 30\n
1393 o> bufferedread(30) -> 30:
1395 o> bufferedread(30) -> 30:
1394 o> bookmarks\t\n
1396 o> bookmarks\t\n
1395 o> namespaces\t\n
1397 o> namespaces\t\n
1396 o> phases\t
1398 o> phases\t
1397 response: {
1399 response: {
1398 b'bookmarks': b'',
1400 b'bookmarks': b'',
1399 b'namespaces': b'',
1401 b'namespaces': b'',
1400 b'phases': b''
1402 b'phases': b''
1401 }
1403 }
1402
1404
1403 $ cd ..
1405 $ cd ..
1404
1406
1405 Test listkeys for bookmarks
1407 Test listkeys for bookmarks
1406
1408
1407 $ hg init bookmarkrepo
1409 $ hg init bookmarkrepo
1408 $ cd bookmarkrepo
1410 $ cd bookmarkrepo
1409 $ echo 0 > foo
1411 $ echo 0 > foo
1410 $ hg add foo
1412 $ hg add foo
1411 $ hg -q commit -m initial
1413 $ hg -q commit -m initial
1412 $ echo 1 > foo
1414 $ echo 1 > foo
1413 $ hg commit -m second
1415 $ hg commit -m second
1414
1416
1415 With no bookmarks set
1417 With no bookmarks set
1416
1418
1417 $ debugwireproto << EOF
1419 $ debugwireproto << EOF
1418 > command listkeys
1420 > command listkeys
1419 > namespace bookmarks
1421 > namespace bookmarks
1420 > EOF
1422 > EOF
1421 testing ssh1
1423 testing ssh1
1422 creating ssh peer from handshake results
1424 creating ssh peer from handshake results
1423 i> write(104) -> 104:
1425 i> write(104) -> 104:
1424 i> hello\n
1426 i> hello\n
1425 i> between\n
1427 i> between\n
1426 i> pairs 81\n
1428 i> pairs 81\n
1427 i> 0000000000000000000000000000000000000000-0000000000000000000000000000000000000000
1429 i> 0000000000000000000000000000000000000000-0000000000000000000000000000000000000000
1428 i> flush() -> None
1430 i> flush() -> None
1429 o> readline() -> 4:
1431 o> readline() -> 4:
1430 o> 440\n
1432 o> 440\n
1431 o> readline() -> 440:
1433 o> readline() -> 440:
1432 o> capabilities: batch branchmap $USUAL_BUNDLE2_CAPS$ changegroupsubset getbundle known lookup protocaps pushkey streamreqs=generaldelta,revlogv1,sparserevlog unbundle=HG10GZ,HG10BZ,HG10UN unbundlehash\n
1434 o> capabilities: batch branchmap $USUAL_BUNDLE2_CAPS$ changegroupsubset getbundle known lookup protocaps pushkey streamreqs=generaldelta,revlogv1,sparserevlog unbundle=HG10GZ,HG10BZ,HG10UN unbundlehash\n
1433 o> readline() -> 2:
1435 o> readline() -> 2:
1434 o> 1\n
1436 o> 1\n
1435 o> readline() -> 1:
1437 o> readline() -> 1:
1436 o> \n
1438 o> \n
1437 sending listkeys command
1439 sending listkeys command
1438 i> write(9) -> 9:
1440 i> write(9) -> 9:
1439 i> listkeys\n
1441 i> listkeys\n
1440 i> write(12) -> 12:
1442 i> write(12) -> 12:
1441 i> namespace 9\n
1443 i> namespace 9\n
1442 i> write(9) -> 9: bookmarks
1444 i> write(9) -> 9: bookmarks
1443 i> flush() -> None
1445 i> flush() -> None
1444 o> bufferedreadline() -> 2:
1446 o> bufferedreadline() -> 2:
1445 o> 0\n
1447 o> 0\n
1446 response: {}
1448 response: {}
1447
1449
1448 testing ssh2
1450 testing ssh2
1449 creating ssh peer from handshake results
1451 creating ssh peer from handshake results
1450 i> write(171) -> 171:
1452 i> write(171) -> 171:
1451 i> upgrade * proto=exp-ssh-v2-0003\n (glob)
1453 i> upgrade * proto=exp-ssh-v2-0003\n (glob)
1452 i> hello\n
1454 i> hello\n
1453 i> between\n
1455 i> between\n
1454 i> pairs 81\n
1456 i> pairs 81\n
1455 i> 0000000000000000000000000000000000000000-0000000000000000000000000000000000000000
1457 i> 0000000000000000000000000000000000000000-0000000000000000000000000000000000000000
1456 i> flush() -> None
1458 i> flush() -> None
1457 o> readline() -> 62:
1459 o> readline() -> 62:
1458 o> upgraded * exp-ssh-v2-0003\n (glob)
1460 o> upgraded * exp-ssh-v2-0003\n (glob)
1459 o> readline() -> 4:
1461 o> readline() -> 4:
1460 o> 439\n
1462 o> 439\n
1461 o> read(439) -> 439: capabilities: batch branchmap $USUAL_BUNDLE2_CAPS$ changegroupsubset getbundle known lookup protocaps pushkey streamreqs=generaldelta,revlogv1,sparserevlog unbundle=HG10GZ,HG10BZ,HG10UN unbundlehash
1463 o> read(439) -> 439: capabilities: batch branchmap $USUAL_BUNDLE2_CAPS$ changegroupsubset getbundle known lookup protocaps pushkey streamreqs=generaldelta,revlogv1,sparserevlog unbundle=HG10GZ,HG10BZ,HG10UN unbundlehash
1462 o> read(1) -> 1:
1464 o> read(1) -> 1:
1463 o> \n
1465 o> \n
1464 sending listkeys command
1466 sending listkeys command
1465 i> write(9) -> 9:
1467 i> write(9) -> 9:
1466 i> listkeys\n
1468 i> listkeys\n
1467 i> write(12) -> 12:
1469 i> write(12) -> 12:
1468 i> namespace 9\n
1470 i> namespace 9\n
1469 i> write(9) -> 9: bookmarks
1471 i> write(9) -> 9: bookmarks
1470 i> flush() -> None
1472 i> flush() -> None
1471 o> bufferedreadline() -> 2:
1473 o> bufferedreadline() -> 2:
1472 o> 0\n
1474 o> 0\n
1473 response: {}
1475 response: {}
1474
1476
1475 With a single bookmark set
1477 With a single bookmark set
1476
1478
1477 $ hg book -r 0 bookA
1479 $ hg book -r 0 bookA
1478 $ debugwireproto << EOF
1480 $ debugwireproto << EOF
1479 > command listkeys
1481 > command listkeys
1480 > namespace bookmarks
1482 > namespace bookmarks
1481 > EOF
1483 > EOF
1482 testing ssh1
1484 testing ssh1
1483 creating ssh peer from handshake results
1485 creating ssh peer from handshake results
1484 i> write(104) -> 104:
1486 i> write(104) -> 104:
1485 i> hello\n
1487 i> hello\n
1486 i> between\n
1488 i> between\n
1487 i> pairs 81\n
1489 i> pairs 81\n
1488 i> 0000000000000000000000000000000000000000-0000000000000000000000000000000000000000
1490 i> 0000000000000000000000000000000000000000-0000000000000000000000000000000000000000
1489 i> flush() -> None
1491 i> flush() -> None
1490 o> readline() -> 4:
1492 o> readline() -> 4:
1491 o> 440\n
1493 o> 440\n
1492 o> readline() -> 440:
1494 o> readline() -> 440:
1493 o> capabilities: batch branchmap $USUAL_BUNDLE2_CAPS$ changegroupsubset getbundle known lookup protocaps pushkey streamreqs=generaldelta,revlogv1,sparserevlog unbundle=HG10GZ,HG10BZ,HG10UN unbundlehash\n
1495 o> capabilities: batch branchmap $USUAL_BUNDLE2_CAPS$ changegroupsubset getbundle known lookup protocaps pushkey streamreqs=generaldelta,revlogv1,sparserevlog unbundle=HG10GZ,HG10BZ,HG10UN unbundlehash\n
1494 o> readline() -> 2:
1496 o> readline() -> 2:
1495 o> 1\n
1497 o> 1\n
1496 o> readline() -> 1:
1498 o> readline() -> 1:
1497 o> \n
1499 o> \n
1498 sending listkeys command
1500 sending listkeys command
1499 i> write(9) -> 9:
1501 i> write(9) -> 9:
1500 i> listkeys\n
1502 i> listkeys\n
1501 i> write(12) -> 12:
1503 i> write(12) -> 12:
1502 i> namespace 9\n
1504 i> namespace 9\n
1503 i> write(9) -> 9: bookmarks
1505 i> write(9) -> 9: bookmarks
1504 i> flush() -> None
1506 i> flush() -> None
1505 o> bufferedreadline() -> 3:
1507 o> bufferedreadline() -> 3:
1506 o> 46\n
1508 o> 46\n
1507 o> bufferedread(46) -> 46: bookA\t68986213bd4485ea51533535e3fc9e78007a711f
1509 o> bufferedread(46) -> 46: bookA\t68986213bd4485ea51533535e3fc9e78007a711f
1508 response: {
1510 response: {
1509 b'bookA': b'68986213bd4485ea51533535e3fc9e78007a711f'
1511 b'bookA': b'68986213bd4485ea51533535e3fc9e78007a711f'
1510 }
1512 }
1511
1513
1512 testing ssh2
1514 testing ssh2
1513 creating ssh peer from handshake results
1515 creating ssh peer from handshake results
1514 i> write(171) -> 171:
1516 i> write(171) -> 171:
1515 i> upgrade * proto=exp-ssh-v2-0003\n (glob)
1517 i> upgrade * proto=exp-ssh-v2-0003\n (glob)
1516 i> hello\n
1518 i> hello\n
1517 i> between\n
1519 i> between\n
1518 i> pairs 81\n
1520 i> pairs 81\n
1519 i> 0000000000000000000000000000000000000000-0000000000000000000000000000000000000000
1521 i> 0000000000000000000000000000000000000000-0000000000000000000000000000000000000000
1520 i> flush() -> None
1522 i> flush() -> None
1521 o> readline() -> 62:
1523 o> readline() -> 62:
1522 o> upgraded * exp-ssh-v2-0003\n (glob)
1524 o> upgraded * exp-ssh-v2-0003\n (glob)
1523 o> readline() -> 4:
1525 o> readline() -> 4:
1524 o> 439\n
1526 o> 439\n
1525 o> read(439) -> 439: capabilities: batch branchmap $USUAL_BUNDLE2_CAPS$ changegroupsubset getbundle known lookup protocaps pushkey streamreqs=generaldelta,revlogv1,sparserevlog unbundle=HG10GZ,HG10BZ,HG10UN unbundlehash
1527 o> read(439) -> 439: capabilities: batch branchmap $USUAL_BUNDLE2_CAPS$ changegroupsubset getbundle known lookup protocaps pushkey streamreqs=generaldelta,revlogv1,sparserevlog unbundle=HG10GZ,HG10BZ,HG10UN unbundlehash
1526 o> read(1) -> 1:
1528 o> read(1) -> 1:
1527 o> \n
1529 o> \n
1528 sending listkeys command
1530 sending listkeys command
1529 i> write(9) -> 9:
1531 i> write(9) -> 9:
1530 i> listkeys\n
1532 i> listkeys\n
1531 i> write(12) -> 12:
1533 i> write(12) -> 12:
1532 i> namespace 9\n
1534 i> namespace 9\n
1533 i> write(9) -> 9: bookmarks
1535 i> write(9) -> 9: bookmarks
1534 i> flush() -> None
1536 i> flush() -> None
1535 o> bufferedreadline() -> 3:
1537 o> bufferedreadline() -> 3:
1536 o> 46\n
1538 o> 46\n
1537 o> bufferedread(46) -> 46: bookA\t68986213bd4485ea51533535e3fc9e78007a711f
1539 o> bufferedread(46) -> 46: bookA\t68986213bd4485ea51533535e3fc9e78007a711f
1538 response: {
1540 response: {
1539 b'bookA': b'68986213bd4485ea51533535e3fc9e78007a711f'
1541 b'bookA': b'68986213bd4485ea51533535e3fc9e78007a711f'
1540 }
1542 }
1541
1543
1542 With multiple bookmarks set
1544 With multiple bookmarks set
1543
1545
1544 $ hg book -r 1 bookB
1546 $ hg book -r 1 bookB
1545 $ debugwireproto << EOF
1547 $ debugwireproto << EOF
1546 > command listkeys
1548 > command listkeys
1547 > namespace bookmarks
1549 > namespace bookmarks
1548 > EOF
1550 > EOF
1549 testing ssh1
1551 testing ssh1
1550 creating ssh peer from handshake results
1552 creating ssh peer from handshake results
1551 i> write(104) -> 104:
1553 i> write(104) -> 104:
1552 i> hello\n
1554 i> hello\n
1553 i> between\n
1555 i> between\n
1554 i> pairs 81\n
1556 i> pairs 81\n
1555 i> 0000000000000000000000000000000000000000-0000000000000000000000000000000000000000
1557 i> 0000000000000000000000000000000000000000-0000000000000000000000000000000000000000
1556 i> flush() -> None
1558 i> flush() -> None
1557 o> readline() -> 4:
1559 o> readline() -> 4:
1558 o> 440\n
1560 o> 440\n
1559 o> readline() -> 440:
1561 o> readline() -> 440:
1560 o> capabilities: batch branchmap $USUAL_BUNDLE2_CAPS$ changegroupsubset getbundle known lookup protocaps pushkey streamreqs=generaldelta,revlogv1,sparserevlog unbundle=HG10GZ,HG10BZ,HG10UN unbundlehash\n
1562 o> capabilities: batch branchmap $USUAL_BUNDLE2_CAPS$ changegroupsubset getbundle known lookup protocaps pushkey streamreqs=generaldelta,revlogv1,sparserevlog unbundle=HG10GZ,HG10BZ,HG10UN unbundlehash\n
1561 o> readline() -> 2:
1563 o> readline() -> 2:
1562 o> 1\n
1564 o> 1\n
1563 o> readline() -> 1:
1565 o> readline() -> 1:
1564 o> \n
1566 o> \n
1565 sending listkeys command
1567 sending listkeys command
1566 i> write(9) -> 9:
1568 i> write(9) -> 9:
1567 i> listkeys\n
1569 i> listkeys\n
1568 i> write(12) -> 12:
1570 i> write(12) -> 12:
1569 i> namespace 9\n
1571 i> namespace 9\n
1570 i> write(9) -> 9: bookmarks
1572 i> write(9) -> 9: bookmarks
1571 i> flush() -> None
1573 i> flush() -> None
1572 o> bufferedreadline() -> 3:
1574 o> bufferedreadline() -> 3:
1573 o> 93\n
1575 o> 93\n
1574 o> bufferedread(93) -> 93:
1576 o> bufferedread(93) -> 93:
1575 o> bookA\t68986213bd4485ea51533535e3fc9e78007a711f\n
1577 o> bookA\t68986213bd4485ea51533535e3fc9e78007a711f\n
1576 o> bookB\t1880f3755e2e52e3199e0ee5638128b08642f34d
1578 o> bookB\t1880f3755e2e52e3199e0ee5638128b08642f34d
1577 response: {
1579 response: {
1578 b'bookA': b'68986213bd4485ea51533535e3fc9e78007a711f',
1580 b'bookA': b'68986213bd4485ea51533535e3fc9e78007a711f',
1579 b'bookB': b'1880f3755e2e52e3199e0ee5638128b08642f34d'
1581 b'bookB': b'1880f3755e2e52e3199e0ee5638128b08642f34d'
1580 }
1582 }
1581
1583
1582 testing ssh2
1584 testing ssh2
1583 creating ssh peer from handshake results
1585 creating ssh peer from handshake results
1584 i> write(171) -> 171:
1586 i> write(171) -> 171:
1585 i> upgrade * proto=exp-ssh-v2-0003\n (glob)
1587 i> upgrade * proto=exp-ssh-v2-0003\n (glob)
1586 i> hello\n
1588 i> hello\n
1587 i> between\n
1589 i> between\n
1588 i> pairs 81\n
1590 i> pairs 81\n
1589 i> 0000000000000000000000000000000000000000-0000000000000000000000000000000000000000
1591 i> 0000000000000000000000000000000000000000-0000000000000000000000000000000000000000
1590 i> flush() -> None
1592 i> flush() -> None
1591 o> readline() -> 62:
1593 o> readline() -> 62:
1592 o> upgraded * exp-ssh-v2-0003\n (glob)
1594 o> upgraded * exp-ssh-v2-0003\n (glob)
1593 o> readline() -> 4:
1595 o> readline() -> 4:
1594 o> 439\n
1596 o> 439\n
1595 o> read(439) -> 439: capabilities: batch branchmap $USUAL_BUNDLE2_CAPS$ changegroupsubset getbundle known lookup protocaps pushkey streamreqs=generaldelta,revlogv1,sparserevlog unbundle=HG10GZ,HG10BZ,HG10UN unbundlehash
1597 o> read(439) -> 439: capabilities: batch branchmap $USUAL_BUNDLE2_CAPS$ changegroupsubset getbundle known lookup protocaps pushkey streamreqs=generaldelta,revlogv1,sparserevlog unbundle=HG10GZ,HG10BZ,HG10UN unbundlehash
1596 o> read(1) -> 1:
1598 o> read(1) -> 1:
1597 o> \n
1599 o> \n
1598 sending listkeys command
1600 sending listkeys command
1599 i> write(9) -> 9:
1601 i> write(9) -> 9:
1600 i> listkeys\n
1602 i> listkeys\n
1601 i> write(12) -> 12:
1603 i> write(12) -> 12:
1602 i> namespace 9\n
1604 i> namespace 9\n
1603 i> write(9) -> 9: bookmarks
1605 i> write(9) -> 9: bookmarks
1604 i> flush() -> None
1606 i> flush() -> None
1605 o> bufferedreadline() -> 3:
1607 o> bufferedreadline() -> 3:
1606 o> 93\n
1608 o> 93\n
1607 o> bufferedread(93) -> 93:
1609 o> bufferedread(93) -> 93:
1608 o> bookA\t68986213bd4485ea51533535e3fc9e78007a711f\n
1610 o> bookA\t68986213bd4485ea51533535e3fc9e78007a711f\n
1609 o> bookB\t1880f3755e2e52e3199e0ee5638128b08642f34d
1611 o> bookB\t1880f3755e2e52e3199e0ee5638128b08642f34d
1610 response: {
1612 response: {
1611 b'bookA': b'68986213bd4485ea51533535e3fc9e78007a711f',
1613 b'bookA': b'68986213bd4485ea51533535e3fc9e78007a711f',
1612 b'bookB': b'1880f3755e2e52e3199e0ee5638128b08642f34d'
1614 b'bookB': b'1880f3755e2e52e3199e0ee5638128b08642f34d'
1613 }
1615 }
1614
1616
1615 Test pushkey for bookmarks
1617 Test pushkey for bookmarks
1616
1618
1617 $ debugwireproto << EOF
1619 $ debugwireproto << EOF
1618 > command pushkey
1620 > command pushkey
1619 > namespace bookmarks
1621 > namespace bookmarks
1620 > key remote
1622 > key remote
1621 > old
1623 > old
1622 > new 68986213bd4485ea51533535e3fc9e78007a711f
1624 > new 68986213bd4485ea51533535e3fc9e78007a711f
1623 > EOF
1625 > EOF
1624 testing ssh1
1626 testing ssh1
1625 creating ssh peer from handshake results
1627 creating ssh peer from handshake results
1626 i> write(104) -> 104:
1628 i> write(104) -> 104:
1627 i> hello\n
1629 i> hello\n
1628 i> between\n
1630 i> between\n
1629 i> pairs 81\n
1631 i> pairs 81\n
1630 i> 0000000000000000000000000000000000000000-0000000000000000000000000000000000000000
1632 i> 0000000000000000000000000000000000000000-0000000000000000000000000000000000000000
1631 i> flush() -> None
1633 i> flush() -> None
1632 o> readline() -> 4:
1634 o> readline() -> 4:
1633 o> 440\n
1635 o> 440\n
1634 o> readline() -> 440:
1636 o> readline() -> 440:
1635 o> capabilities: batch branchmap $USUAL_BUNDLE2_CAPS$ changegroupsubset getbundle known lookup protocaps pushkey streamreqs=generaldelta,revlogv1,sparserevlog unbundle=HG10GZ,HG10BZ,HG10UN unbundlehash\n
1637 o> capabilities: batch branchmap $USUAL_BUNDLE2_CAPS$ changegroupsubset getbundle known lookup protocaps pushkey streamreqs=generaldelta,revlogv1,sparserevlog unbundle=HG10GZ,HG10BZ,HG10UN unbundlehash\n
1636 o> readline() -> 2:
1638 o> readline() -> 2:
1637 o> 1\n
1639 o> 1\n
1638 o> readline() -> 1:
1640 o> readline() -> 1:
1639 o> \n
1641 o> \n
1640 sending pushkey command
1642 sending pushkey command
1641 i> write(8) -> 8:
1643 i> write(8) -> 8:
1642 i> pushkey\n
1644 i> pushkey\n
1643 i> write(6) -> 6:
1645 i> write(6) -> 6:
1644 i> key 6\n
1646 i> key 6\n
1645 i> write(6) -> 6: remote
1647 i> write(6) -> 6: remote
1646 i> write(12) -> 12:
1648 i> write(12) -> 12:
1647 i> namespace 9\n
1649 i> namespace 9\n
1648 i> write(9) -> 9: bookmarks
1650 i> write(9) -> 9: bookmarks
1649 i> write(7) -> 7:
1651 i> write(7) -> 7:
1650 i> new 40\n
1652 i> new 40\n
1651 i> write(40) -> 40: 68986213bd4485ea51533535e3fc9e78007a711f
1653 i> write(40) -> 40: 68986213bd4485ea51533535e3fc9e78007a711f
1652 i> write(6) -> 6:
1654 i> write(6) -> 6:
1653 i> old 0\n
1655 i> old 0\n
1654 i> flush() -> None
1656 i> flush() -> None
1655 o> bufferedreadline() -> 2:
1657 o> bufferedreadline() -> 2:
1656 o> 2\n
1658 o> 2\n
1657 o> bufferedread(2) -> 2:
1659 o> bufferedread(2) -> 2:
1658 o> 1\n
1660 o> 1\n
1659 response: True
1661 response: True
1660
1662
1661 testing ssh2
1663 testing ssh2
1662 creating ssh peer from handshake results
1664 creating ssh peer from handshake results
1663 i> write(171) -> 171:
1665 i> write(171) -> 171:
1664 i> upgrade * proto=exp-ssh-v2-0003\n (glob)
1666 i> upgrade * proto=exp-ssh-v2-0003\n (glob)
1665 i> hello\n
1667 i> hello\n
1666 i> between\n
1668 i> between\n
1667 i> pairs 81\n
1669 i> pairs 81\n
1668 i> 0000000000000000000000000000000000000000-0000000000000000000000000000000000000000
1670 i> 0000000000000000000000000000000000000000-0000000000000000000000000000000000000000
1669 i> flush() -> None
1671 i> flush() -> None
1670 o> readline() -> 62:
1672 o> readline() -> 62:
1671 o> upgraded * exp-ssh-v2-0003\n (glob)
1673 o> upgraded * exp-ssh-v2-0003\n (glob)
1672 o> readline() -> 4:
1674 o> readline() -> 4:
1673 o> 439\n
1675 o> 439\n
1674 o> read(439) -> 439: capabilities: batch branchmap $USUAL_BUNDLE2_CAPS$ changegroupsubset getbundle known lookup protocaps pushkey streamreqs=generaldelta,revlogv1,sparserevlog unbundle=HG10GZ,HG10BZ,HG10UN unbundlehash
1676 o> read(439) -> 439: capabilities: batch branchmap $USUAL_BUNDLE2_CAPS$ changegroupsubset getbundle known lookup protocaps pushkey streamreqs=generaldelta,revlogv1,sparserevlog unbundle=HG10GZ,HG10BZ,HG10UN unbundlehash
1675 o> read(1) -> 1:
1677 o> read(1) -> 1:
1676 o> \n
1678 o> \n
1677 sending pushkey command
1679 sending pushkey command
1678 i> write(8) -> 8:
1680 i> write(8) -> 8:
1679 i> pushkey\n
1681 i> pushkey\n
1680 i> write(6) -> 6:
1682 i> write(6) -> 6:
1681 i> key 6\n
1683 i> key 6\n
1682 i> write(6) -> 6: remote
1684 i> write(6) -> 6: remote
1683 i> write(12) -> 12:
1685 i> write(12) -> 12:
1684 i> namespace 9\n
1686 i> namespace 9\n
1685 i> write(9) -> 9: bookmarks
1687 i> write(9) -> 9: bookmarks
1686 i> write(7) -> 7:
1688 i> write(7) -> 7:
1687 i> new 40\n
1689 i> new 40\n
1688 i> write(40) -> 40: 68986213bd4485ea51533535e3fc9e78007a711f
1690 i> write(40) -> 40: 68986213bd4485ea51533535e3fc9e78007a711f
1689 i> write(6) -> 6:
1691 i> write(6) -> 6:
1690 i> old 0\n
1692 i> old 0\n
1691 i> flush() -> None
1693 i> flush() -> None
1692 o> bufferedreadline() -> 2:
1694 o> bufferedreadline() -> 2:
1693 o> 2\n
1695 o> 2\n
1694 o> bufferedread(2) -> 2:
1696 o> bufferedread(2) -> 2:
1695 o> 1\n
1697 o> 1\n
1696 response: True
1698 response: True
1697
1699
1698 $ hg bookmarks
1700 $ hg bookmarks
1699 bookA 0:68986213bd44
1701 bookA 0:68986213bd44
1700 bookB 1:1880f3755e2e
1702 bookB 1:1880f3755e2e
1701 remote 0:68986213bd44
1703 remote 0:68986213bd44
1702
1704
1703 $ cd ..
1705 $ cd ..
1704
1706
1705 Test listkeys for phases
1707 Test listkeys for phases
1706
1708
1707 $ hg init phasesrepo
1709 $ hg init phasesrepo
1708 $ cd phasesrepo
1710 $ cd phasesrepo
1709
1711
1710 Phases on empty repo
1712 Phases on empty repo
1711
1713
1712 $ debugwireproto << EOF
1714 $ debugwireproto << EOF
1713 > command listkeys
1715 > command listkeys
1714 > namespace phases
1716 > namespace phases
1715 > EOF
1717 > EOF
1716 testing ssh1
1718 testing ssh1
1717 creating ssh peer from handshake results
1719 creating ssh peer from handshake results
1718 i> write(104) -> 104:
1720 i> write(104) -> 104:
1719 i> hello\n
1721 i> hello\n
1720 i> between\n
1722 i> between\n
1721 i> pairs 81\n
1723 i> pairs 81\n
1722 i> 0000000000000000000000000000000000000000-0000000000000000000000000000000000000000
1724 i> 0000000000000000000000000000000000000000-0000000000000000000000000000000000000000
1723 i> flush() -> None
1725 i> flush() -> None
1724 o> readline() -> 4:
1726 o> readline() -> 4:
1725 o> 440\n
1727 o> 440\n
1726 o> readline() -> 440:
1728 o> readline() -> 440:
1727 o> capabilities: batch branchmap $USUAL_BUNDLE2_CAPS$ changegroupsubset getbundle known lookup protocaps pushkey streamreqs=generaldelta,revlogv1,sparserevlog unbundle=HG10GZ,HG10BZ,HG10UN unbundlehash\n
1729 o> capabilities: batch branchmap $USUAL_BUNDLE2_CAPS$ changegroupsubset getbundle known lookup protocaps pushkey streamreqs=generaldelta,revlogv1,sparserevlog unbundle=HG10GZ,HG10BZ,HG10UN unbundlehash\n
1728 o> readline() -> 2:
1730 o> readline() -> 2:
1729 o> 1\n
1731 o> 1\n
1730 o> readline() -> 1:
1732 o> readline() -> 1:
1731 o> \n
1733 o> \n
1732 sending listkeys command
1734 sending listkeys command
1733 i> write(9) -> 9:
1735 i> write(9) -> 9:
1734 i> listkeys\n
1736 i> listkeys\n
1735 i> write(12) -> 12:
1737 i> write(12) -> 12:
1736 i> namespace 6\n
1738 i> namespace 6\n
1737 i> write(6) -> 6: phases
1739 i> write(6) -> 6: phases
1738 i> flush() -> None
1740 i> flush() -> None
1739 o> bufferedreadline() -> 3:
1741 o> bufferedreadline() -> 3:
1740 o> 15\n
1742 o> 15\n
1741 o> bufferedread(15) -> 15: publishing\tTrue
1743 o> bufferedread(15) -> 15: publishing\tTrue
1742 response: {
1744 response: {
1743 b'publishing': b'True'
1745 b'publishing': b'True'
1744 }
1746 }
1745
1747
1746 testing ssh2
1748 testing ssh2
1747 creating ssh peer from handshake results
1749 creating ssh peer from handshake results
1748 i> write(171) -> 171:
1750 i> write(171) -> 171:
1749 i> upgrade * proto=exp-ssh-v2-0003\n (glob)
1751 i> upgrade * proto=exp-ssh-v2-0003\n (glob)
1750 i> hello\n
1752 i> hello\n
1751 i> between\n
1753 i> between\n
1752 i> pairs 81\n
1754 i> pairs 81\n
1753 i> 0000000000000000000000000000000000000000-0000000000000000000000000000000000000000
1755 i> 0000000000000000000000000000000000000000-0000000000000000000000000000000000000000
1754 i> flush() -> None
1756 i> flush() -> None
1755 o> readline() -> 62:
1757 o> readline() -> 62:
1756 o> upgraded * exp-ssh-v2-0003\n (glob)
1758 o> upgraded * exp-ssh-v2-0003\n (glob)
1757 o> readline() -> 4:
1759 o> readline() -> 4:
1758 o> 439\n
1760 o> 439\n
1759 o> read(439) -> 439: capabilities: batch branchmap $USUAL_BUNDLE2_CAPS$ changegroupsubset getbundle known lookup protocaps pushkey streamreqs=generaldelta,revlogv1,sparserevlog unbundle=HG10GZ,HG10BZ,HG10UN unbundlehash
1761 o> read(439) -> 439: capabilities: batch branchmap $USUAL_BUNDLE2_CAPS$ changegroupsubset getbundle known lookup protocaps pushkey streamreqs=generaldelta,revlogv1,sparserevlog unbundle=HG10GZ,HG10BZ,HG10UN unbundlehash
1760 o> read(1) -> 1:
1762 o> read(1) -> 1:
1761 o> \n
1763 o> \n
1762 sending listkeys command
1764 sending listkeys command
1763 i> write(9) -> 9:
1765 i> write(9) -> 9:
1764 i> listkeys\n
1766 i> listkeys\n
1765 i> write(12) -> 12:
1767 i> write(12) -> 12:
1766 i> namespace 6\n
1768 i> namespace 6\n
1767 i> write(6) -> 6: phases
1769 i> write(6) -> 6: phases
1768 i> flush() -> None
1770 i> flush() -> None
1769 o> bufferedreadline() -> 3:
1771 o> bufferedreadline() -> 3:
1770 o> 15\n
1772 o> 15\n
1771 o> bufferedread(15) -> 15: publishing\tTrue
1773 o> bufferedread(15) -> 15: publishing\tTrue
1772 response: {
1774 response: {
1773 b'publishing': b'True'
1775 b'publishing': b'True'
1774 }
1776 }
1775
1777
1776 Create some commits
1778 Create some commits
1777
1779
1778 $ echo 0 > foo
1780 $ echo 0 > foo
1779 $ hg add foo
1781 $ hg add foo
1780 $ hg -q commit -m initial
1782 $ hg -q commit -m initial
1781 $ hg phase --public
1783 $ hg phase --public
1782 $ echo 1 > foo
1784 $ echo 1 > foo
1783 $ hg commit -m 'head 1 commit 1'
1785 $ hg commit -m 'head 1 commit 1'
1784 $ echo 2 > foo
1786 $ echo 2 > foo
1785 $ hg commit -m 'head 1 commit 2'
1787 $ hg commit -m 'head 1 commit 2'
1786 $ hg -q up 0
1788 $ hg -q up 0
1787 $ echo 1a > foo
1789 $ echo 1a > foo
1788 $ hg commit -m 'head 2 commit 1'
1790 $ hg commit -m 'head 2 commit 1'
1789 created new head
1791 created new head
1790 $ echo 2a > foo
1792 $ echo 2a > foo
1791 $ hg commit -m 'head 2 commit 2'
1793 $ hg commit -m 'head 2 commit 2'
1792
1794
1793 Two draft heads
1795 Two draft heads
1794
1796
1795 $ debugwireproto << EOF
1797 $ debugwireproto << EOF
1796 > command listkeys
1798 > command listkeys
1797 > namespace phases
1799 > namespace phases
1798 > EOF
1800 > EOF
1799 testing ssh1
1801 testing ssh1
1800 creating ssh peer from handshake results
1802 creating ssh peer from handshake results
1801 i> write(104) -> 104:
1803 i> write(104) -> 104:
1802 i> hello\n
1804 i> hello\n
1803 i> between\n
1805 i> between\n
1804 i> pairs 81\n
1806 i> pairs 81\n
1805 i> 0000000000000000000000000000000000000000-0000000000000000000000000000000000000000
1807 i> 0000000000000000000000000000000000000000-0000000000000000000000000000000000000000
1806 i> flush() -> None
1808 i> flush() -> None
1807 o> readline() -> 4:
1809 o> readline() -> 4:
1808 o> 440\n
1810 o> 440\n
1809 o> readline() -> 440:
1811 o> readline() -> 440:
1810 o> capabilities: batch branchmap $USUAL_BUNDLE2_CAPS$ changegroupsubset getbundle known lookup protocaps pushkey streamreqs=generaldelta,revlogv1,sparserevlog unbundle=HG10GZ,HG10BZ,HG10UN unbundlehash\n
1812 o> capabilities: batch branchmap $USUAL_BUNDLE2_CAPS$ changegroupsubset getbundle known lookup protocaps pushkey streamreqs=generaldelta,revlogv1,sparserevlog unbundle=HG10GZ,HG10BZ,HG10UN unbundlehash\n
1811 o> readline() -> 2:
1813 o> readline() -> 2:
1812 o> 1\n
1814 o> 1\n
1813 o> readline() -> 1:
1815 o> readline() -> 1:
1814 o> \n
1816 o> \n
1815 sending listkeys command
1817 sending listkeys command
1816 i> write(9) -> 9:
1818 i> write(9) -> 9:
1817 i> listkeys\n
1819 i> listkeys\n
1818 i> write(12) -> 12:
1820 i> write(12) -> 12:
1819 i> namespace 6\n
1821 i> namespace 6\n
1820 i> write(6) -> 6: phases
1822 i> write(6) -> 6: phases
1821 i> flush() -> None
1823 i> flush() -> None
1822 o> bufferedreadline() -> 4:
1824 o> bufferedreadline() -> 4:
1823 o> 101\n
1825 o> 101\n
1824 o> bufferedread(101) -> 101:
1826 o> bufferedread(101) -> 101:
1825 o> 20b8a89289d80036e6c4e87c2083e3bea1586637\t1\n
1827 o> 20b8a89289d80036e6c4e87c2083e3bea1586637\t1\n
1826 o> c4750011d906c18ea2f0527419cbc1a544435150\t1\n
1828 o> c4750011d906c18ea2f0527419cbc1a544435150\t1\n
1827 o> publishing\tTrue
1829 o> publishing\tTrue
1828 response: {
1830 response: {
1829 b'20b8a89289d80036e6c4e87c2083e3bea1586637': b'1',
1831 b'20b8a89289d80036e6c4e87c2083e3bea1586637': b'1',
1830 b'c4750011d906c18ea2f0527419cbc1a544435150': b'1',
1832 b'c4750011d906c18ea2f0527419cbc1a544435150': b'1',
1831 b'publishing': b'True'
1833 b'publishing': b'True'
1832 }
1834 }
1833
1835
1834 testing ssh2
1836 testing ssh2
1835 creating ssh peer from handshake results
1837 creating ssh peer from handshake results
1836 i> write(171) -> 171:
1838 i> write(171) -> 171:
1837 i> upgrade * proto=exp-ssh-v2-0003\n (glob)
1839 i> upgrade * proto=exp-ssh-v2-0003\n (glob)
1838 i> hello\n
1840 i> hello\n
1839 i> between\n
1841 i> between\n
1840 i> pairs 81\n
1842 i> pairs 81\n
1841 i> 0000000000000000000000000000000000000000-0000000000000000000000000000000000000000
1843 i> 0000000000000000000000000000000000000000-0000000000000000000000000000000000000000
1842 i> flush() -> None
1844 i> flush() -> None
1843 o> readline() -> 62:
1845 o> readline() -> 62:
1844 o> upgraded * exp-ssh-v2-0003\n (glob)
1846 o> upgraded * exp-ssh-v2-0003\n (glob)
1845 o> readline() -> 4:
1847 o> readline() -> 4:
1846 o> 439\n
1848 o> 439\n
1847 o> read(439) -> 439: capabilities: batch branchmap $USUAL_BUNDLE2_CAPS$ changegroupsubset getbundle known lookup protocaps pushkey streamreqs=generaldelta,revlogv1,sparserevlog unbundle=HG10GZ,HG10BZ,HG10UN unbundlehash
1849 o> read(439) -> 439: capabilities: batch branchmap $USUAL_BUNDLE2_CAPS$ changegroupsubset getbundle known lookup protocaps pushkey streamreqs=generaldelta,revlogv1,sparserevlog unbundle=HG10GZ,HG10BZ,HG10UN unbundlehash
1848 o> read(1) -> 1:
1850 o> read(1) -> 1:
1849 o> \n
1851 o> \n
1850 sending listkeys command
1852 sending listkeys command
1851 i> write(9) -> 9:
1853 i> write(9) -> 9:
1852 i> listkeys\n
1854 i> listkeys\n
1853 i> write(12) -> 12:
1855 i> write(12) -> 12:
1854 i> namespace 6\n
1856 i> namespace 6\n
1855 i> write(6) -> 6: phases
1857 i> write(6) -> 6: phases
1856 i> flush() -> None
1858 i> flush() -> None
1857 o> bufferedreadline() -> 4:
1859 o> bufferedreadline() -> 4:
1858 o> 101\n
1860 o> 101\n
1859 o> bufferedread(101) -> 101:
1861 o> bufferedread(101) -> 101:
1860 o> 20b8a89289d80036e6c4e87c2083e3bea1586637\t1\n
1862 o> 20b8a89289d80036e6c4e87c2083e3bea1586637\t1\n
1861 o> c4750011d906c18ea2f0527419cbc1a544435150\t1\n
1863 o> c4750011d906c18ea2f0527419cbc1a544435150\t1\n
1862 o> publishing\tTrue
1864 o> publishing\tTrue
1863 response: {
1865 response: {
1864 b'20b8a89289d80036e6c4e87c2083e3bea1586637': b'1',
1866 b'20b8a89289d80036e6c4e87c2083e3bea1586637': b'1',
1865 b'c4750011d906c18ea2f0527419cbc1a544435150': b'1',
1867 b'c4750011d906c18ea2f0527419cbc1a544435150': b'1',
1866 b'publishing': b'True'
1868 b'publishing': b'True'
1867 }
1869 }
1868
1870
1869 Single draft head
1871 Single draft head
1870
1872
1871 $ hg phase --public -r 2
1873 $ hg phase --public -r 2
1872 $ debugwireproto << EOF
1874 $ debugwireproto << EOF
1873 > command listkeys
1875 > command listkeys
1874 > namespace phases
1876 > namespace phases
1875 > EOF
1877 > EOF
1876 testing ssh1
1878 testing ssh1
1877 creating ssh peer from handshake results
1879 creating ssh peer from handshake results
1878 i> write(104) -> 104:
1880 i> write(104) -> 104:
1879 i> hello\n
1881 i> hello\n
1880 i> between\n
1882 i> between\n
1881 i> pairs 81\n
1883 i> pairs 81\n
1882 i> 0000000000000000000000000000000000000000-0000000000000000000000000000000000000000
1884 i> 0000000000000000000000000000000000000000-0000000000000000000000000000000000000000
1883 i> flush() -> None
1885 i> flush() -> None
1884 o> readline() -> 4:
1886 o> readline() -> 4:
1885 o> 440\n
1887 o> 440\n
1886 o> readline() -> 440:
1888 o> readline() -> 440:
1887 o> capabilities: batch branchmap $USUAL_BUNDLE2_CAPS$ changegroupsubset getbundle known lookup protocaps pushkey streamreqs=generaldelta,revlogv1,sparserevlog unbundle=HG10GZ,HG10BZ,HG10UN unbundlehash\n
1889 o> capabilities: batch branchmap $USUAL_BUNDLE2_CAPS$ changegroupsubset getbundle known lookup protocaps pushkey streamreqs=generaldelta,revlogv1,sparserevlog unbundle=HG10GZ,HG10BZ,HG10UN unbundlehash\n
1888 o> readline() -> 2:
1890 o> readline() -> 2:
1889 o> 1\n
1891 o> 1\n
1890 o> readline() -> 1:
1892 o> readline() -> 1:
1891 o> \n
1893 o> \n
1892 sending listkeys command
1894 sending listkeys command
1893 i> write(9) -> 9:
1895 i> write(9) -> 9:
1894 i> listkeys\n
1896 i> listkeys\n
1895 i> write(12) -> 12:
1897 i> write(12) -> 12:
1896 i> namespace 6\n
1898 i> namespace 6\n
1897 i> write(6) -> 6: phases
1899 i> write(6) -> 6: phases
1898 i> flush() -> None
1900 i> flush() -> None
1899 o> bufferedreadline() -> 3:
1901 o> bufferedreadline() -> 3:
1900 o> 58\n
1902 o> 58\n
1901 o> bufferedread(58) -> 58:
1903 o> bufferedread(58) -> 58:
1902 o> c4750011d906c18ea2f0527419cbc1a544435150\t1\n
1904 o> c4750011d906c18ea2f0527419cbc1a544435150\t1\n
1903 o> publishing\tTrue
1905 o> publishing\tTrue
1904 response: {
1906 response: {
1905 b'c4750011d906c18ea2f0527419cbc1a544435150': b'1',
1907 b'c4750011d906c18ea2f0527419cbc1a544435150': b'1',
1906 b'publishing': b'True'
1908 b'publishing': b'True'
1907 }
1909 }
1908
1910
1909 testing ssh2
1911 testing ssh2
1910 creating ssh peer from handshake results
1912 creating ssh peer from handshake results
1911 i> write(171) -> 171:
1913 i> write(171) -> 171:
1912 i> upgrade * proto=exp-ssh-v2-0003\n (glob)
1914 i> upgrade * proto=exp-ssh-v2-0003\n (glob)
1913 i> hello\n
1915 i> hello\n
1914 i> between\n
1916 i> between\n
1915 i> pairs 81\n
1917 i> pairs 81\n
1916 i> 0000000000000000000000000000000000000000-0000000000000000000000000000000000000000
1918 i> 0000000000000000000000000000000000000000-0000000000000000000000000000000000000000
1917 i> flush() -> None
1919 i> flush() -> None
1918 o> readline() -> 62:
1920 o> readline() -> 62:
1919 o> upgraded * exp-ssh-v2-0003\n (glob)
1921 o> upgraded * exp-ssh-v2-0003\n (glob)
1920 o> readline() -> 4:
1922 o> readline() -> 4:
1921 o> 439\n
1923 o> 439\n
1922 o> read(439) -> 439: capabilities: batch branchmap $USUAL_BUNDLE2_CAPS$ changegroupsubset getbundle known lookup protocaps pushkey streamreqs=generaldelta,revlogv1,sparserevlog unbundle=HG10GZ,HG10BZ,HG10UN unbundlehash
1924 o> read(439) -> 439: capabilities: batch branchmap $USUAL_BUNDLE2_CAPS$ changegroupsubset getbundle known lookup protocaps pushkey streamreqs=generaldelta,revlogv1,sparserevlog unbundle=HG10GZ,HG10BZ,HG10UN unbundlehash
1923 o> read(1) -> 1:
1925 o> read(1) -> 1:
1924 o> \n
1926 o> \n
1925 sending listkeys command
1927 sending listkeys command
1926 i> write(9) -> 9:
1928 i> write(9) -> 9:
1927 i> listkeys\n
1929 i> listkeys\n
1928 i> write(12) -> 12:
1930 i> write(12) -> 12:
1929 i> namespace 6\n
1931 i> namespace 6\n
1930 i> write(6) -> 6: phases
1932 i> write(6) -> 6: phases
1931 i> flush() -> None
1933 i> flush() -> None
1932 o> bufferedreadline() -> 3:
1934 o> bufferedreadline() -> 3:
1933 o> 58\n
1935 o> 58\n
1934 o> bufferedread(58) -> 58:
1936 o> bufferedread(58) -> 58:
1935 o> c4750011d906c18ea2f0527419cbc1a544435150\t1\n
1937 o> c4750011d906c18ea2f0527419cbc1a544435150\t1\n
1936 o> publishing\tTrue
1938 o> publishing\tTrue
1937 response: {
1939 response: {
1938 b'c4750011d906c18ea2f0527419cbc1a544435150': b'1',
1940 b'c4750011d906c18ea2f0527419cbc1a544435150': b'1',
1939 b'publishing': b'True'
1941 b'publishing': b'True'
1940 }
1942 }
1941
1943
1942 All public heads
1944 All public heads
1943
1945
1944 $ hg phase --public -r 4
1946 $ hg phase --public -r 4
1945 $ debugwireproto << EOF
1947 $ debugwireproto << EOF
1946 > command listkeys
1948 > command listkeys
1947 > namespace phases
1949 > namespace phases
1948 > EOF
1950 > EOF
1949 testing ssh1
1951 testing ssh1
1950 creating ssh peer from handshake results
1952 creating ssh peer from handshake results
1951 i> write(104) -> 104:
1953 i> write(104) -> 104:
1952 i> hello\n
1954 i> hello\n
1953 i> between\n
1955 i> between\n
1954 i> pairs 81\n
1956 i> pairs 81\n
1955 i> 0000000000000000000000000000000000000000-0000000000000000000000000000000000000000
1957 i> 0000000000000000000000000000000000000000-0000000000000000000000000000000000000000
1956 i> flush() -> None
1958 i> flush() -> None
1957 o> readline() -> 4:
1959 o> readline() -> 4:
1958 o> 440\n
1960 o> 440\n
1959 o> readline() -> 440:
1961 o> readline() -> 440:
1960 o> capabilities: batch branchmap $USUAL_BUNDLE2_CAPS$ changegroupsubset getbundle known lookup protocaps pushkey streamreqs=generaldelta,revlogv1,sparserevlog unbundle=HG10GZ,HG10BZ,HG10UN unbundlehash\n
1962 o> capabilities: batch branchmap $USUAL_BUNDLE2_CAPS$ changegroupsubset getbundle known lookup protocaps pushkey streamreqs=generaldelta,revlogv1,sparserevlog unbundle=HG10GZ,HG10BZ,HG10UN unbundlehash\n
1961 o> readline() -> 2:
1963 o> readline() -> 2:
1962 o> 1\n
1964 o> 1\n
1963 o> readline() -> 1:
1965 o> readline() -> 1:
1964 o> \n
1966 o> \n
1965 sending listkeys command
1967 sending listkeys command
1966 i> write(9) -> 9:
1968 i> write(9) -> 9:
1967 i> listkeys\n
1969 i> listkeys\n
1968 i> write(12) -> 12:
1970 i> write(12) -> 12:
1969 i> namespace 6\n
1971 i> namespace 6\n
1970 i> write(6) -> 6: phases
1972 i> write(6) -> 6: phases
1971 i> flush() -> None
1973 i> flush() -> None
1972 o> bufferedreadline() -> 3:
1974 o> bufferedreadline() -> 3:
1973 o> 15\n
1975 o> 15\n
1974 o> bufferedread(15) -> 15: publishing\tTrue
1976 o> bufferedread(15) -> 15: publishing\tTrue
1975 response: {
1977 response: {
1976 b'publishing': b'True'
1978 b'publishing': b'True'
1977 }
1979 }
1978
1980
1979 testing ssh2
1981 testing ssh2
1980 creating ssh peer from handshake results
1982 creating ssh peer from handshake results
1981 i> write(171) -> 171:
1983 i> write(171) -> 171:
1982 i> upgrade * proto=exp-ssh-v2-0003\n (glob)
1984 i> upgrade * proto=exp-ssh-v2-0003\n (glob)
1983 i> hello\n
1985 i> hello\n
1984 i> between\n
1986 i> between\n
1985 i> pairs 81\n
1987 i> pairs 81\n
1986 i> 0000000000000000000000000000000000000000-0000000000000000000000000000000000000000
1988 i> 0000000000000000000000000000000000000000-0000000000000000000000000000000000000000
1987 i> flush() -> None
1989 i> flush() -> None
1988 o> readline() -> 62:
1990 o> readline() -> 62:
1989 o> upgraded * exp-ssh-v2-0003\n (glob)
1991 o> upgraded * exp-ssh-v2-0003\n (glob)
1990 o> readline() -> 4:
1992 o> readline() -> 4:
1991 o> 439\n
1993 o> 439\n
1992 o> read(439) -> 439: capabilities: batch branchmap $USUAL_BUNDLE2_CAPS$ changegroupsubset getbundle known lookup protocaps pushkey streamreqs=generaldelta,revlogv1,sparserevlog unbundle=HG10GZ,HG10BZ,HG10UN unbundlehash
1994 o> read(439) -> 439: capabilities: batch branchmap $USUAL_BUNDLE2_CAPS$ changegroupsubset getbundle known lookup protocaps pushkey streamreqs=generaldelta,revlogv1,sparserevlog unbundle=HG10GZ,HG10BZ,HG10UN unbundlehash
1993 o> read(1) -> 1:
1995 o> read(1) -> 1:
1994 o> \n
1996 o> \n
1995 sending listkeys command
1997 sending listkeys command
1996 i> write(9) -> 9:
1998 i> write(9) -> 9:
1997 i> listkeys\n
1999 i> listkeys\n
1998 i> write(12) -> 12:
2000 i> write(12) -> 12:
1999 i> namespace 6\n
2001 i> namespace 6\n
2000 i> write(6) -> 6: phases
2002 i> write(6) -> 6: phases
2001 i> flush() -> None
2003 i> flush() -> None
2002 o> bufferedreadline() -> 3:
2004 o> bufferedreadline() -> 3:
2003 o> 15\n
2005 o> 15\n
2004 o> bufferedread(15) -> 15: publishing\tTrue
2006 o> bufferedread(15) -> 15: publishing\tTrue
2005 response: {
2007 response: {
2006 b'publishing': b'True'
2008 b'publishing': b'True'
2007 }
2009 }
2008
2010
2009 Setting public phase via pushkey
2011 Setting public phase via pushkey
2010
2012
2011 $ hg phase --draft --force -r .
2013 $ hg phase --draft --force -r .
2012
2014
2013 $ debugwireproto << EOF
2015 $ debugwireproto << EOF
2014 > command pushkey
2016 > command pushkey
2015 > namespace phases
2017 > namespace phases
2016 > key 7127240a084fd9dc86fe8d1f98e26229161ec82b
2018 > key 7127240a084fd9dc86fe8d1f98e26229161ec82b
2017 > old 1
2019 > old 1
2018 > new 0
2020 > new 0
2019 > EOF
2021 > EOF
2020 testing ssh1
2022 testing ssh1
2021 creating ssh peer from handshake results
2023 creating ssh peer from handshake results
2022 i> write(104) -> 104:
2024 i> write(104) -> 104:
2023 i> hello\n
2025 i> hello\n
2024 i> between\n
2026 i> between\n
2025 i> pairs 81\n
2027 i> pairs 81\n
2026 i> 0000000000000000000000000000000000000000-0000000000000000000000000000000000000000
2028 i> 0000000000000000000000000000000000000000-0000000000000000000000000000000000000000
2027 i> flush() -> None
2029 i> flush() -> None
2028 o> readline() -> 4:
2030 o> readline() -> 4:
2029 o> 440\n
2031 o> 440\n
2030 o> readline() -> 440:
2032 o> readline() -> 440:
2031 o> capabilities: batch branchmap $USUAL_BUNDLE2_CAPS$ changegroupsubset getbundle known lookup protocaps pushkey streamreqs=generaldelta,revlogv1,sparserevlog unbundle=HG10GZ,HG10BZ,HG10UN unbundlehash\n
2033 o> capabilities: batch branchmap $USUAL_BUNDLE2_CAPS$ changegroupsubset getbundle known lookup protocaps pushkey streamreqs=generaldelta,revlogv1,sparserevlog unbundle=HG10GZ,HG10BZ,HG10UN unbundlehash\n
2032 o> readline() -> 2:
2034 o> readline() -> 2:
2033 o> 1\n
2035 o> 1\n
2034 o> readline() -> 1:
2036 o> readline() -> 1:
2035 o> \n
2037 o> \n
2036 sending pushkey command
2038 sending pushkey command
2037 i> write(8) -> 8:
2039 i> write(8) -> 8:
2038 i> pushkey\n
2040 i> pushkey\n
2039 i> write(7) -> 7:
2041 i> write(7) -> 7:
2040 i> key 40\n
2042 i> key 40\n
2041 i> write(40) -> 40: 7127240a084fd9dc86fe8d1f98e26229161ec82b
2043 i> write(40) -> 40: 7127240a084fd9dc86fe8d1f98e26229161ec82b
2042 i> write(12) -> 12:
2044 i> write(12) -> 12:
2043 i> namespace 6\n
2045 i> namespace 6\n
2044 i> write(6) -> 6: phases
2046 i> write(6) -> 6: phases
2045 i> write(6) -> 6:
2047 i> write(6) -> 6:
2046 i> new 1\n
2048 i> new 1\n
2047 i> write(1) -> 1: 0
2049 i> write(1) -> 1: 0
2048 i> write(6) -> 6:
2050 i> write(6) -> 6:
2049 i> old 1\n
2051 i> old 1\n
2050 i> write(1) -> 1: 1
2052 i> write(1) -> 1: 1
2051 i> flush() -> None
2053 i> flush() -> None
2052 o> bufferedreadline() -> 2:
2054 o> bufferedreadline() -> 2:
2053 o> 2\n
2055 o> 2\n
2054 o> bufferedread(2) -> 2:
2056 o> bufferedread(2) -> 2:
2055 o> 1\n
2057 o> 1\n
2056 response: True
2058 response: True
2057
2059
2058 testing ssh2
2060 testing ssh2
2059 creating ssh peer from handshake results
2061 creating ssh peer from handshake results
2060 i> write(171) -> 171:
2062 i> write(171) -> 171:
2061 i> upgrade * proto=exp-ssh-v2-0003\n (glob)
2063 i> upgrade * proto=exp-ssh-v2-0003\n (glob)
2062 i> hello\n
2064 i> hello\n
2063 i> between\n
2065 i> between\n
2064 i> pairs 81\n
2066 i> pairs 81\n
2065 i> 0000000000000000000000000000000000000000-0000000000000000000000000000000000000000
2067 i> 0000000000000000000000000000000000000000-0000000000000000000000000000000000000000
2066 i> flush() -> None
2068 i> flush() -> None
2067 o> readline() -> 62:
2069 o> readline() -> 62:
2068 o> upgraded * exp-ssh-v2-0003\n (glob)
2070 o> upgraded * exp-ssh-v2-0003\n (glob)
2069 o> readline() -> 4:
2071 o> readline() -> 4:
2070 o> 439\n
2072 o> 439\n
2071 o> read(439) -> 439: capabilities: batch branchmap $USUAL_BUNDLE2_CAPS$ changegroupsubset getbundle known lookup protocaps pushkey streamreqs=generaldelta,revlogv1,sparserevlog unbundle=HG10GZ,HG10BZ,HG10UN unbundlehash
2073 o> read(439) -> 439: capabilities: batch branchmap $USUAL_BUNDLE2_CAPS$ changegroupsubset getbundle known lookup protocaps pushkey streamreqs=generaldelta,revlogv1,sparserevlog unbundle=HG10GZ,HG10BZ,HG10UN unbundlehash
2072 o> read(1) -> 1:
2074 o> read(1) -> 1:
2073 o> \n
2075 o> \n
2074 sending pushkey command
2076 sending pushkey command
2075 i> write(8) -> 8:
2077 i> write(8) -> 8:
2076 i> pushkey\n
2078 i> pushkey\n
2077 i> write(7) -> 7:
2079 i> write(7) -> 7:
2078 i> key 40\n
2080 i> key 40\n
2079 i> write(40) -> 40: 7127240a084fd9dc86fe8d1f98e26229161ec82b
2081 i> write(40) -> 40: 7127240a084fd9dc86fe8d1f98e26229161ec82b
2080 i> write(12) -> 12:
2082 i> write(12) -> 12:
2081 i> namespace 6\n
2083 i> namespace 6\n
2082 i> write(6) -> 6: phases
2084 i> write(6) -> 6: phases
2083 i> write(6) -> 6:
2085 i> write(6) -> 6:
2084 i> new 1\n
2086 i> new 1\n
2085 i> write(1) -> 1: 0
2087 i> write(1) -> 1: 0
2086 i> write(6) -> 6:
2088 i> write(6) -> 6:
2087 i> old 1\n
2089 i> old 1\n
2088 i> write(1) -> 1: 1
2090 i> write(1) -> 1: 1
2089 i> flush() -> None
2091 i> flush() -> None
2090 o> bufferedreadline() -> 2:
2092 o> bufferedreadline() -> 2:
2091 o> 2\n
2093 o> 2\n
2092 o> bufferedread(2) -> 2:
2094 o> bufferedread(2) -> 2:
2093 o> 1\n
2095 o> 1\n
2094 response: True
2096 response: True
2095
2097
2096 $ hg phase .
2098 $ hg phase .
2097 4: public
2099 4: public
2098
2100
2099 $ cd ..
2101 $ cd ..
2100
2102
2101 Test batching of requests
2103 Test batching of requests
2102
2104
2103 $ hg init batching
2105 $ hg init batching
2104 $ cd batching
2106 $ cd batching
2105 $ echo 0 > foo
2107 $ echo 0 > foo
2106 $ hg add foo
2108 $ hg add foo
2107 $ hg -q commit -m initial
2109 $ hg -q commit -m initial
2108 $ hg phase --public
2110 $ hg phase --public
2109 $ echo 1 > foo
2111 $ echo 1 > foo
2110 $ hg commit -m 'commit 1'
2112 $ hg commit -m 'commit 1'
2111 $ hg -q up 0
2113 $ hg -q up 0
2112 $ echo 2 > foo
2114 $ echo 2 > foo
2113 $ hg commit -m 'commit 2'
2115 $ hg commit -m 'commit 2'
2114 created new head
2116 created new head
2115 $ hg book -r 1 bookA
2117 $ hg book -r 1 bookA
2116 $ hg book -r 2 bookB
2118 $ hg book -r 2 bookB
2117
2119
2118 $ debugwireproto << EOF
2120 $ debugwireproto << EOF
2119 > batchbegin
2121 > batchbegin
2120 > command heads
2122 > command heads
2121 > command listkeys
2123 > command listkeys
2122 > namespace bookmarks
2124 > namespace bookmarks
2123 > command listkeys
2125 > command listkeys
2124 > namespace phases
2126 > namespace phases
2125 > batchsubmit
2127 > batchsubmit
2126 > EOF
2128 > EOF
2127 testing ssh1
2129 testing ssh1
2128 creating ssh peer from handshake results
2130 creating ssh peer from handshake results
2129 i> write(104) -> 104:
2131 i> write(104) -> 104:
2130 i> hello\n
2132 i> hello\n
2131 i> between\n
2133 i> between\n
2132 i> pairs 81\n
2134 i> pairs 81\n
2133 i> 0000000000000000000000000000000000000000-0000000000000000000000000000000000000000
2135 i> 0000000000000000000000000000000000000000-0000000000000000000000000000000000000000
2134 i> flush() -> None
2136 i> flush() -> None
2135 o> readline() -> 4:
2137 o> readline() -> 4:
2136 o> 440\n
2138 o> 440\n
2137 o> readline() -> 440:
2139 o> readline() -> 440:
2138 o> capabilities: batch branchmap $USUAL_BUNDLE2_CAPS$ changegroupsubset getbundle known lookup protocaps pushkey streamreqs=generaldelta,revlogv1,sparserevlog unbundle=HG10GZ,HG10BZ,HG10UN unbundlehash\n
2140 o> capabilities: batch branchmap $USUAL_BUNDLE2_CAPS$ changegroupsubset getbundle known lookup protocaps pushkey streamreqs=generaldelta,revlogv1,sparserevlog unbundle=HG10GZ,HG10BZ,HG10UN unbundlehash\n
2139 o> readline() -> 2:
2141 o> readline() -> 2:
2140 o> 1\n
2142 o> 1\n
2141 o> readline() -> 1:
2143 o> readline() -> 1:
2142 o> \n
2144 o> \n
2143 sending batch with 3 sub-commands
2145 sending batch with 3 sub-commands
2144 i> write(6) -> 6:
2146 i> write(6) -> 6:
2145 i> batch\n
2147 i> batch\n
2146 i> write(4) -> 4:
2148 i> write(4) -> 4:
2147 i> * 0\n
2149 i> * 0\n
2148 i> write(8) -> 8:
2150 i> write(8) -> 8:
2149 i> cmds 61\n
2151 i> cmds 61\n
2150 i> write(61) -> 61: heads ;listkeys namespace=bookmarks;listkeys namespace=phases
2152 i> write(61) -> 61: heads ;listkeys namespace=bookmarks;listkeys namespace=phases
2151 i> flush() -> None
2153 i> flush() -> None
2152 o> bufferedreadline() -> 4:
2154 o> bufferedreadline() -> 4:
2153 o> 278\n
2155 o> 278\n
2154 o> bufferedread(278) -> 278:
2156 o> bufferedread(278) -> 278:
2155 o> bfebe6bd38eebc6f8202e419c1171268987ea6a6 4ee3fcef1c800fa2bf23e20af7c83ff111d9c7ab\n
2157 o> bfebe6bd38eebc6f8202e419c1171268987ea6a6 4ee3fcef1c800fa2bf23e20af7c83ff111d9c7ab\n
2156 o> ;bookA\t4ee3fcef1c800fa2bf23e20af7c83ff111d9c7ab\n
2158 o> ;bookA\t4ee3fcef1c800fa2bf23e20af7c83ff111d9c7ab\n
2157 o> bookB\tbfebe6bd38eebc6f8202e419c1171268987ea6a6;4ee3fcef1c800fa2bf23e20af7c83ff111d9c7ab\t1\n
2159 o> bookB\tbfebe6bd38eebc6f8202e419c1171268987ea6a6;4ee3fcef1c800fa2bf23e20af7c83ff111d9c7ab\t1\n
2158 o> bfebe6bd38eebc6f8202e419c1171268987ea6a6\t1\n
2160 o> bfebe6bd38eebc6f8202e419c1171268987ea6a6\t1\n
2159 o> publishing\tTrue
2161 o> publishing\tTrue
2160 response #0: bfebe6bd38eebc6f8202e419c1171268987ea6a6 4ee3fcef1c800fa2bf23e20af7c83ff111d9c7ab\n
2162 response #0: bfebe6bd38eebc6f8202e419c1171268987ea6a6 4ee3fcef1c800fa2bf23e20af7c83ff111d9c7ab\n
2161 response #1: bookA\t4ee3fcef1c800fa2bf23e20af7c83ff111d9c7ab\nbookB\tbfebe6bd38eebc6f8202e419c1171268987ea6a6
2163 response #1: bookA\t4ee3fcef1c800fa2bf23e20af7c83ff111d9c7ab\nbookB\tbfebe6bd38eebc6f8202e419c1171268987ea6a6
2162 response #2: 4ee3fcef1c800fa2bf23e20af7c83ff111d9c7ab\t1\nbfebe6bd38eebc6f8202e419c1171268987ea6a6\t1\npublishing\tTrue
2164 response #2: 4ee3fcef1c800fa2bf23e20af7c83ff111d9c7ab\t1\nbfebe6bd38eebc6f8202e419c1171268987ea6a6\t1\npublishing\tTrue
2163
2165
2164 testing ssh2
2166 testing ssh2
2165 creating ssh peer from handshake results
2167 creating ssh peer from handshake results
2166 i> write(171) -> 171:
2168 i> write(171) -> 171:
2167 i> upgrade * proto=exp-ssh-v2-0003\n (glob)
2169 i> upgrade * proto=exp-ssh-v2-0003\n (glob)
2168 i> hello\n
2170 i> hello\n
2169 i> between\n
2171 i> between\n
2170 i> pairs 81\n
2172 i> pairs 81\n
2171 i> 0000000000000000000000000000000000000000-0000000000000000000000000000000000000000
2173 i> 0000000000000000000000000000000000000000-0000000000000000000000000000000000000000
2172 i> flush() -> None
2174 i> flush() -> None
2173 o> readline() -> 62:
2175 o> readline() -> 62:
2174 o> upgraded * exp-ssh-v2-0003\n (glob)
2176 o> upgraded * exp-ssh-v2-0003\n (glob)
2175 o> readline() -> 4:
2177 o> readline() -> 4:
2176 o> 439\n
2178 o> 439\n
2177 o> read(439) -> 439: capabilities: batch branchmap $USUAL_BUNDLE2_CAPS$ changegroupsubset getbundle known lookup protocaps pushkey streamreqs=generaldelta,revlogv1,sparserevlog unbundle=HG10GZ,HG10BZ,HG10UN unbundlehash
2179 o> read(439) -> 439: capabilities: batch branchmap $USUAL_BUNDLE2_CAPS$ changegroupsubset getbundle known lookup protocaps pushkey streamreqs=generaldelta,revlogv1,sparserevlog unbundle=HG10GZ,HG10BZ,HG10UN unbundlehash
2178 o> read(1) -> 1:
2180 o> read(1) -> 1:
2179 o> \n
2181 o> \n
2180 sending batch with 3 sub-commands
2182 sending batch with 3 sub-commands
2181 i> write(6) -> 6:
2183 i> write(6) -> 6:
2182 i> batch\n
2184 i> batch\n
2183 i> write(4) -> 4:
2185 i> write(4) -> 4:
2184 i> * 0\n
2186 i> * 0\n
2185 i> write(8) -> 8:
2187 i> write(8) -> 8:
2186 i> cmds 61\n
2188 i> cmds 61\n
2187 i> write(61) -> 61: heads ;listkeys namespace=bookmarks;listkeys namespace=phases
2189 i> write(61) -> 61: heads ;listkeys namespace=bookmarks;listkeys namespace=phases
2188 i> flush() -> None
2190 i> flush() -> None
2189 o> bufferedreadline() -> 4:
2191 o> bufferedreadline() -> 4:
2190 o> 278\n
2192 o> 278\n
2191 o> bufferedread(278) -> 278:
2193 o> bufferedread(278) -> 278:
2192 o> bfebe6bd38eebc6f8202e419c1171268987ea6a6 4ee3fcef1c800fa2bf23e20af7c83ff111d9c7ab\n
2194 o> bfebe6bd38eebc6f8202e419c1171268987ea6a6 4ee3fcef1c800fa2bf23e20af7c83ff111d9c7ab\n
2193 o> ;bookA\t4ee3fcef1c800fa2bf23e20af7c83ff111d9c7ab\n
2195 o> ;bookA\t4ee3fcef1c800fa2bf23e20af7c83ff111d9c7ab\n
2194 o> bookB\tbfebe6bd38eebc6f8202e419c1171268987ea6a6;4ee3fcef1c800fa2bf23e20af7c83ff111d9c7ab\t1\n
2196 o> bookB\tbfebe6bd38eebc6f8202e419c1171268987ea6a6;4ee3fcef1c800fa2bf23e20af7c83ff111d9c7ab\t1\n
2195 o> bfebe6bd38eebc6f8202e419c1171268987ea6a6\t1\n
2197 o> bfebe6bd38eebc6f8202e419c1171268987ea6a6\t1\n
2196 o> publishing\tTrue
2198 o> publishing\tTrue
2197 response #0: bfebe6bd38eebc6f8202e419c1171268987ea6a6 4ee3fcef1c800fa2bf23e20af7c83ff111d9c7ab\n
2199 response #0: bfebe6bd38eebc6f8202e419c1171268987ea6a6 4ee3fcef1c800fa2bf23e20af7c83ff111d9c7ab\n
2198 response #1: bookA\t4ee3fcef1c800fa2bf23e20af7c83ff111d9c7ab\nbookB\tbfebe6bd38eebc6f8202e419c1171268987ea6a6
2200 response #1: bookA\t4ee3fcef1c800fa2bf23e20af7c83ff111d9c7ab\nbookB\tbfebe6bd38eebc6f8202e419c1171268987ea6a6
2199 response #2: 4ee3fcef1c800fa2bf23e20af7c83ff111d9c7ab\t1\nbfebe6bd38eebc6f8202e419c1171268987ea6a6\t1\npublishing\tTrue
2201 response #2: 4ee3fcef1c800fa2bf23e20af7c83ff111d9c7ab\t1\nbfebe6bd38eebc6f8202e419c1171268987ea6a6\t1\npublishing\tTrue
General Comments 0
You need to be logged in to leave comments. Login now