equal
deleted
inserted
replaced
34 if re.match(b'[a-zA-Z0-9@%_+=:,./-]*$', s): |
34 if re.match(b'[a-zA-Z0-9@%_+=:,./-]*$', s): |
35 return s |
35 return s |
36 return b"'%s'" % s.replace(b"'", b"'\\''") |
36 return b"'%s'" % s.replace(b"'", b"'\\''") |
37 |
37 |
38 |
38 |
39 def _forwardoutput(ui, pipe): |
39 def _forwardoutput(ui, pipe, warn=False): |
40 """display all data currently available on pipe as remote output. |
40 """display all data currently available on pipe as remote output. |
41 |
41 |
42 This is non blocking.""" |
42 This is non blocking.""" |
43 if pipe: |
43 if pipe: |
44 s = procutil.readpipe(pipe) |
44 s = procutil.readpipe(pipe) |
45 if s: |
45 if s: |
|
46 display = ui.warn if warn else ui.status |
46 for l in s.splitlines(): |
47 for l in s.splitlines(): |
47 ui.status(_(b"remote: "), l, b'\n') |
48 display(_(b"remote: "), l, b'\n') |
48 |
49 |
49 |
50 |
50 class doublepipe(object): |
51 class doublepipe(object): |
51 """Operate a side-channel pipe in addition of a main one |
52 """Operate a side-channel pipe in addition of a main one |
52 |
53 |
202 return protoparams |
203 return protoparams |
203 |
204 |
204 |
205 |
205 def _performhandshake(ui, stdin, stdout, stderr): |
206 def _performhandshake(ui, stdin, stdout, stderr): |
206 def badresponse(): |
207 def badresponse(): |
207 # Flush any output on stderr. |
208 # Flush any output on stderr. In general, the stderr contains errors |
208 _forwardoutput(ui, stderr) |
209 # from the remote (ssh errors, some hg errors), and status indications |
|
210 # (like "adding changes"), with no current way to tell them apart. |
|
211 # Here we failed so early that it's almost certainly only errors, so |
|
212 # use warn=True so -q doesn't hide them. |
|
213 _forwardoutput(ui, stderr, warn=True) |
209 |
214 |
210 msg = _(b'no suitable response from remote hg') |
215 msg = _(b'no suitable response from remote hg') |
211 hint = ui.config(b'ui', b'ssherrorhint') |
216 hint = ui.config(b'ui', b'ssherrorhint') |
212 raise error.RepoError(msg, hint=hint) |
217 raise error.RepoError(msg, hint=hint) |
213 |
218 |
305 lines = [b'', b'dummy'] |
310 lines = [b'', b'dummy'] |
306 max_noise = 500 |
311 max_noise = 500 |
307 while lines[-1] and max_noise: |
312 while lines[-1] and max_noise: |
308 try: |
313 try: |
309 l = stdout.readline() |
314 l = stdout.readline() |
310 _forwardoutput(ui, stderr) |
315 _forwardoutput(ui, stderr, warn=True) |
311 |
316 |
312 # Look for reply to protocol upgrade request. It has a token |
317 # Look for reply to protocol upgrade request. It has a token |
313 # in it, so there should be no false positives. |
318 # in it, so there should be no false positives. |
314 m = reupgraded.match(l) |
319 m = reupgraded.match(l) |
315 if m: |
320 if m: |
372 # and other attempted handshake mechanisms. |
377 # and other attempted handshake mechanisms. |
373 if not caps: |
378 if not caps: |
374 badresponse() |
379 badresponse() |
375 |
380 |
376 # Flush any output on stderr before proceeding. |
381 # Flush any output on stderr before proceeding. |
377 _forwardoutput(ui, stderr) |
382 _forwardoutput(ui, stderr, warn=True) |
378 |
383 |
379 return protoname, caps |
384 return protoname, caps |
380 |
385 |
381 |
386 |
382 class sshv1peer(wireprotov1peer.wirepeer): |
387 class sshv1peer(wireprotov1peer.wirepeer): |