[PATCH] sshpeer: add the hint for "no suitable response" failure

FUJIWARA Katsunori foozy at lares.dti.ne.jp
Sat Sep 22 00:52:00 CDT 2012


# HG changeset patch
# User FUJIWARA Katsunori <foozy at lares.dti.ne.jp>
# Date 1348292900 -32400
# Node ID dcf55067535fb9f82dcfac73ef2c9654c110c94c
# Parent  331d611813eca2098fdb75c741cb7f5cc72b6567
sshpeer: add the hint for "no suitable response" failure

Mercurial earlier than 1.8 shows "there is no Mercurial
repository here (.hg not found)!", even if the truth is its old
version causes failure. And this was fixed as issue2649.

But it can't be assumed that every users can upgrade hg command
on remote hosts: some Linux distributions still consist of
earlier hg.

So, this patch adds the hint for "no suitable response" failure to
help users using earlier hg command on remote hosts.

diff -r 331d611813ec -r dcf55067535f mercurial/sshpeer.py
--- a/mercurial/sshpeer.py	Wed Sep 19 09:38:51 2012 -0700
+++ b/mercurial/sshpeer.py	Sat Sep 22 14:48:20 2012 +0900
@@ -87,8 +87,11 @@
             lines.append(l)
             max_noise -= 1
         else:
-            self._abort(error.RepoError(_('no suitable response from '
-                                          'remote hg')))
+            msg = _('no suitable response from remote hg')
+            hint = _('earlier hg command on remote may show'
+                     ' "no Mercurial repository",'
+                     ' even if the truth is its old version causes failure')
+            self._abort(error.RepoError(msg, hint=hint))
 
         self._caps = set()
         for l in reversed(lines):
diff -r 331d611813ec -r dcf55067535f tests/test-ssh.t
--- a/tests/test-ssh.t	Wed Sep 19 09:38:51 2012 -0700
+++ b/tests/test-ssh.t	Sat Sep 22 14:48:20 2012 +0900
@@ -23,6 +23,7 @@
   $ hg clone -e "python \"$TESTDIR/dummyssh\"" ssh://user@dummy/nonexistent local
   remote: abort: there is no Mercurial repository here (.hg not found)!
   abort: no suitable response from remote hg!
+  (earlier hg command on remote may show "no Mercurial repository", even if the truth is its old version causes failure)
   [255]
 
 non-existent absolute path
@@ -30,6 +31,7 @@
   $ hg clone -e "python \"$TESTDIR/dummyssh\"" ssh://user@dummy//`pwd`/nonexistent local
   remote: abort: there is no Mercurial repository here (.hg not found)!
   abort: no suitable response from remote hg!
+  (earlier hg command on remote may show "no Mercurial repository", even if the truth is its old version causes failure)
   [255]
 
 clone remote via stream
@@ -303,11 +305,13 @@
   $ hg id --ssh "sh ssh.sh" "ssh://user@dummy/a'repo"
   remote: Illegal repository "$TESTTMP/a'repo" (glob)
   abort: no suitable response from remote hg!
+  (earlier hg command on remote may show "no Mercurial repository", even if the truth is its old version causes failure)
   [255]
 
   $ hg id --ssh "sh ssh.sh" --remotecmd hacking "ssh://user@dummy/a'repo"
   remote: Illegal command "hacking -R 'a'\''repo' serve --stdio"
   abort: no suitable response from remote hg!
+  (earlier hg command on remote may show "no Mercurial repository", even if the truth is its old version causes failure)
   [255]
 
   $ SSH_ORIGINAL_COMMAND="'hg' -R 'a'repo' serve --stdio" python "$TESTDIR/../contrib/hg-ssh"
@@ -349,6 +353,18 @@
 
   $ cd ..
 
+Test access to "unknown repository format" repository via ssh:
+recent Mercurial can show 'unknown repository format' as below, but
+earlier ones show 'there is no Mercurial repository here'.
+
+  $ hg init unknown-feature
+  $ echo 'unknown-feature' >> unknown-feature/.hg/requires
+  $ hg clone -e "python \"$TESTDIR/dummyssh\"" ssh://user@dummy/unknown-feature unknown-feature.cloned
+  remote: abort: unknown repository format: requires features 'unknown-feature' (upgrade Mercurial)!
+  abort: no suitable response from remote hg!
+  (earlier hg command on remote may show "no Mercurial repository", even if the truth is its old version causes failure)
+  [255]
+
   $ cat dummylog
   Got arguments 1:user at dummy 2:hg -R nonexistent serve --stdio
   Got arguments 1:user at dummy 2:hg -R /$TESTTMP/nonexistent serve --stdio
@@ -374,3 +390,4 @@
   Got arguments 1:user at dummy 2:hg init 'a repo'
   Got arguments 1:user at dummy 2:hg -R 'a repo' serve --stdio
   Got arguments 1:user at dummy 2:hg -R 'a repo' serve --stdio
+  Got arguments 1:user at dummy 2:hg -R unknown-feature serve --stdio


More information about the Mercurial-devel mailing list