D1431: sshpeer: making the ssh error message configurable

zuza (Zuzanna Mroczek) phabricator at mercurial-scm.org
Wed Nov 15 20:52:35 EST 2017


zuza updated this revision to Diff 3542.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D1431?vs=3541&id=3542

REVISION DETAIL
  https://phab.mercurial-scm.org/D1431

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
@@ -30,7 +30,6 @@
   $ cat <<EOF > .hg/hgrc
   > [server]
   > uncompressed = True
-  > 
   > [hooks]
   > changegroup = sh -c "printenv.py changegroup-in-remote 0 ../dummylog"
   > EOF
@@ -155,6 +154,7 @@
   summary:     add
   
 
+
 find incoming on the remote side
 
   $ hg incoming -R ../remote -e "\"$PYTHON\" \"$TESTDIR/dummyssh\"" ssh://user@dummy/local
@@ -168,6 +168,7 @@
   summary:     add
   
 
+
 find incoming on the remote side (using absolute path)
 
   $ hg incoming -R ../remote -e "\"$PYTHON\" \"$TESTDIR/dummyssh\"" "ssh://user@dummy/`pwd`"
@@ -181,6 +182,7 @@
   summary:     add
   
 
+
 push
 
   $ hg push
@@ -202,6 +204,7 @@
   date:        Thu Jan 01 00:00:00 1970 +0000
   summary:     add
   
+
   $ hg verify
   checking changesets
   checking manifests
@@ -307,6 +310,8 @@
   summary:     z
   
 
+
+
 clone bookmarks
 
   $ hg -R ../remote bookmark test
@@ -444,12 +449,10 @@
   $ cd stderr-ordering
   $ cat >> localwrite.py << EOF
   > from mercurial import exchange, extensions
-  > 
   > def wrappedpush(orig, repo, *args, **kwargs):
   >     res = orig(repo, *args, **kwargs)
   >     repo.ui.write('local stdout\n')
   >     return res
-  > 
   > def extsetup(ui):
   >     extensions.wrapfunction(exchange, 'push', wrappedpush)
   > EOF
@@ -578,3 +581,19 @@
   remote: abort: this is an exercise
   abort: pull failed on remote
   [255]
+
+abort with default error message when there is a ssh problem when pulling
+
+  $ hg pull ssh://brokenrepository
+  pulling from ssh://brokenrepository/
+  remote: ssh: Could not resolve hostname brokenrepository: Name or service not known
+  abort: no suitable response from remote hg!
+  [255]
+
+abort with configured error message when there is a ssh problem when pulling
+
+  $ hg pull ssh://brokenrepository --config ssh.errormessage="SSH error"
+  pulling from ssh://brokenrepository/
+  remote: ssh: Could not resolve hostname brokenrepository: Name or service not known
+  abort: SSH error!
+  [255]
diff --git a/mercurial/sshpeer.py b/mercurial/sshpeer.py
--- a/mercurial/sshpeer.py
+++ b/mercurial/sshpeer.py
@@ -204,8 +204,10 @@
         self._pipeo = doublepipe(self.ui, self._pipeo, self._pipee)
 
         def badresponse():
-            self._abort(error.RepoError(_('no suitable response from '
-                                          'remote hg')))
+            self._abort(error.RepoError(self.ui.config(
+                "ssh",
+                "errormessage",
+                _("no suitable response from remote hg"))))
 
         try:
             # skip any noise generated by remote shell



To: zuza, #hg-reviewers, durham, mitrandir
Cc: mercurial-devel


More information about the Mercurial-devel mailing list