[PATCH 2 of 2] sshpeer: show the hint to recovery from "no suitable response" failure

FUJIWARA Katsunori foozy at lares.dti.ne.jp
Thu Aug 30 04:31:52 CDT 2012


At Wed, 29 Aug 2012 14:06:56 +0200,
Mads Kiilerich wrote:
> 
> On 08/29/2012 10:17 AM, FUJIWARA Katsunori wrote:
> > # HG changeset patch
> > # User FUJIWARA Katsunori <foozy at lares.dti.ne.jp>
> > # Date 1346227034 -32400
> > # Node ID ec61bbfe9644c76f02f46753b7f5ec62589910ad
> > # Parent  da5222276e629c7280d94972d55a8140e83117f4
> > sshpeer: show the hint to recovery from "no suitable response" failure
> >
> > This patch adds the hint, which suggests checking not only repository
> > location but also version of remote "hg" command, for "no suitable
> > response" failure of ssh peer, because mismatching of required and
> > supported features may cause failure of the sshpeer initialization.
> >
> > This hint may be redundant, if remote "hg" command is recent enough to
> > show the hint for mismatching of required and supported features.
> 
> Which hint? That the remote abort includes a better message for 
> RequirementError? If some other hint: When was that introduced?

Thank you for your comments, Mads.

This patch just focuses on the case using old (earlier than
931a72e00efa or 1.8) "hg" command on remote side.

In this case, remote "hg" command show NOT "requirement 'xxxx' not
supported", BUT just "no repository found in xxxx (.hg not found)".

Of course, users should update not only client side "hg" command but
also remote side one. But server side "hg" commands seem to be
updated not so frequently.

In addition to it, for many of users, a first sighting of "no
repository found in xxxx (.hg not found)" seems not to trigger
updating remote "hg" command.

So, IMHO, "check (version of) remote hg command" other than repository
location should be displayed at least as a hint for this case.


BTW, "hg" command invoked from interactive ssh session and one invoked
from non-interactive one may be different, because many sshd are
configured not to use login configuration of users in non-interactive
session for security reason recently.

  - OLD "hg" is in "/usr/bin" (or "/bin") on remote

  - PATH has the specific path to NEW "hg" in login shell on remote:
    for example, under ${HOME}/hg and so on

  - creating repo on remote interactively from login shell in
    interactive ssh session uses NEW "hg"

  - push/pull... on client invokes "hg" on remote from non-interactive
    ssh session

  - accessing target repository on remote in non-interactive ssh
    session uses OLD "hg", so

  - OLD "hg" may cause "requirement 'xxxx' not supported" error

Of course, this is not a problem of Mercurial. But it is useful, if we
can show any information to make users aware about old-ness of "hg" on
remote.


> Besides that: AFAIK we usually don't refer to the version of the hg 
> command. It might be better to be more explicit and refer to 
> 'requirements'. But the fact that we can't say anything for sure might 
> be a hint that we shouldn't try to say anything that could be guiding in 
> the wrong direction.

"format" section of "hg help config" has information about relation
between "format(= requirement)" and "version". Is it useful to refer
it for guiding users ?


> It also seems like we don't have any test coverage of the real case you 
> are trying to improve here.

I didn't add additional tests in this patch, because there is no way
on client side to distinguish RequirementError from other RepoError on
remote side.

And in next posting, I'll add additional tests in the case on which
this patch focuses.


> /Mads
> 
> > But users can't see such hint, if remote "hg" command is not so
> > recent, even though local "hg" command is recent enough.
> >
> > diff -r da5222276e62 -r ec61bbfe9644 mercurial/sshpeer.py
> > --- a/mercurial/sshpeer.py	Wed Aug 29 16:53:06 2012 +0900
> > +++ b/mercurial/sshpeer.py	Wed Aug 29 16:57:14 2012 +0900
> > @@ -87,8 +87,10 @@
> >               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 = _('check repository location and/or'
> > +                     ' (version of) remote hg command')
> > +            self._abort(error.RepoError(msg, hint=hint))
> >   
> >           self._caps = set()
> >           for l in reversed(lines):
> > diff -r da5222276e62 -r ec61bbfe9644 tests/test-ssh.t
> > --- a/tests/test-ssh.t	Wed Aug 29 16:53:06 2012 +0900
> > +++ b/tests/test-ssh.t	Wed Aug 29 16:57:14 2012 +0900
> > @@ -24,6 +24,7 @@
> >     remote: abort: there is no available Mercurial repository here!
> >     remote: (.hg not found, or hg command can't support features required in it)
> >     abort: no suitable response from remote hg!
> > +  (check repository location and/or (version of) remote hg command)
> >     [255]
> >   
> >   non-existent absolute path
> > @@ -32,6 +33,7 @@
> >     remote: abort: there is no available Mercurial repository here!
> >     remote: (.hg not found, or hg command can't support features required in it)
> >     abort: no suitable response from remote hg!
> > +  (check repository location and/or (version of) remote hg command)
> >     [255]
> >   
> >   clone remote via stream
> > @@ -305,11 +307,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!
> > +  (check repository location and/or (version of) remote hg command)
> >     [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!
> > +  (check repository location and/or (version of) remote hg command)
> >     [255]
> >   
> >     $ SSH_ORIGINAL_COMMAND="'hg' -R 'a'repo' serve --stdio" python "$TESTDIR/../contrib/hg-ssh"
> > _______________________________________________
> > Mercurial-devel mailing list
> > Mercurial-devel at selenic.com
> > http://selenic.com/mailman/listinfo/mercurial-devel
> 
> 


----------------------------------------------------------------------
[FUJIWARA Katsunori]                             foozy at lares.dti.ne.jp


More information about the Mercurial-devel mailing list