[Request] [+ ] D8584: sshpeer: make client print (likely) server errors on stderr
valentin.gatienbaron (Valentin Gatien-Baron)
phabricator at mercurial-scm.org
Tue May 26 10:42:53 UTC 2020
valentin.gatienbaron created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.
REVISION SUMMARY
so `hg clone -q` or `hg pull -q` don't print `abort: no suitable
response from remote hg!` with no indication of what went wrong.
There are other errors still silenced by -q (like failing to push due
to a server hook), but the current change covers a good fraction of
the problem (all errors setting up the ssh connection, no such remote
repository, no access to the repository).
REPOSITORY
rHG Mercurial
BRANCH
default
REVISION DETAIL
https://phab.mercurial-scm.org/D8584
AFFECTED FILES
mercurial/sshpeer.py
tests/test-ssh.t
CHANGE DETAILS
diff --git a/tests/test-ssh.t b/tests/test-ssh.t
--- a/tests/test-ssh.t
+++ b/tests/test-ssh.t
@@ -47,6 +47,7 @@
abort: no suitable response from remote hg!
[255]
$ hg clone -q -e "\"$PYTHON\" \"$TESTDIR/dummyssh\"" ssh://user@dummy/nonexistent local
+ remote: abort: repository nonexistent not found!
abort: no suitable response from remote hg!
[255]
diff --git a/mercurial/sshpeer.py b/mercurial/sshpeer.py
--- a/mercurial/sshpeer.py
+++ b/mercurial/sshpeer.py
@@ -36,15 +36,16 @@
return b"'%s'" % s.replace(b"'", b"'\\''")
-def _forwardoutput(ui, pipe):
+def _forwardoutput(ui, pipe, warn=False):
"""display all data currently available on pipe as remote output.
This is non blocking."""
if pipe:
s = procutil.readpipe(pipe)
if s:
+ display = ui.warn if warn else ui.status
for l in s.splitlines():
- ui.status(_(b"remote: "), l, b'\n')
+ display(_(b"remote: "), l, b'\n')
class doublepipe(object):
@@ -204,8 +205,12 @@
def _performhandshake(ui, stdin, stdout, stderr):
def badresponse():
- # Flush any output on stderr.
- _forwardoutput(ui, stderr)
+ # Flush any output on stderr. In general, the stderr contains errors
+ # from the remote (ssh errors, some hg errors), and status indications
+ # (like "adding changes"), with no current way to tell them apart.
+ # Here we failed so early that it's almost certainly only errors, so
+ # use warn=True so -q doesn't hide them.
+ _forwardoutput(ui, stderr, warn=True)
msg = _(b'no suitable response from remote hg')
hint = ui.config(b'ui', b'ssherrorhint')
@@ -307,7 +312,7 @@
while lines[-1] and max_noise:
try:
l = stdout.readline()
- _forwardoutput(ui, stderr)
+ _forwardoutput(ui, stderr, warn=True)
# Look for reply to protocol upgrade request. It has a token
# in it, so there should be no false positives.
@@ -374,7 +379,7 @@
badresponse()
# Flush any output on stderr before proceeding.
- _forwardoutput(ui, stderr)
+ _forwardoutput(ui, stderr, warn=True)
return protoname, caps
To: valentin.gatienbaron, #hg-reviewers
Cc: mercurial-patches, mercurial-devel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mercurial-scm.org/pipermail/mercurial-patches/attachments/20200526/fce8a2da/attachment-0001.html>
More information about the Mercurial-patches
mailing list