2012-06-09 166 views
3

水银库我可以成功访问存储库通过http://使用hgweb.cgi:访问通过SSH

$ hg clone http://mydomain.com/scgi-bin/hgweb.cgi/myrepo 

我也能成功ssh到mydomain.com使用密码。

$ ssh [email protected] 
[email protected]'s password: xxxxxx 
Last login: Sat Jun 9 ..... 
[email protected] [~]# ls public_html/scgi-bin 
./ ../ hgweb.cgi*, hgweb.config 

但是,我不能推断如何通过SSH服务存储库。例如,这不起作用:

$ hg clone ssh://[email protected]/public_html/scgi-bin/hgweb.cgi/myrepo 
[email protected]'s password: xxxxx 
remote: stdin: is not a tty 
remote: bash: hg: command not found 
abort: no suitable response from remote hg! 

我得出的结论是不同的http://,SSH://不知道如何运行CGI脚本,那会是正确的吗?有针对这个的解决方法吗?

(顺便说一句:这是在共享主机,其中http的根是的public_html /,SSH的根是一个目录起来。)

+1

如果你使用'hg clone --verbose',它会告诉你类似'running ssh [email protected]“hg -R ... serve --stdio”'这是一个很大的提示,不工作。 – msw

+0

好的,这显示了很多谢谢。我可以看到'hg clone'实际上在远程服务器上调用hg,所以我不需要通过hgweb.cgi。现在看来我只需要弄清楚如何在SSH环境中为hg设置正确的PATH,因为仍然没有找到hg。 – jontyc

回答

4

HTTP是不一样的SSH。 HTTP是一种无状态的,基于请求的传输协议。 SSH是一种在两台机器之间建立永久性,有状态连接的协议。

您的HTTP URL看起来像存储库的完整路径,但它通过一个web服务器,它正在执行hgweb.cgi脚本,并将myrepo作为参数传递给它。 hgweb.cgi脚本在服务器上运行Mercurial以对抗myrepo存储库(它从服务器上的配置文件中提取实际位置)。该命令链是这样的:

Local Mercurial -> HTTP -> Web Server -> hgweb.cgi > Server Mercurial 

您使用的是第二个例子中的SSH URL告诉水银登录到mydomain.com服务器myname,它可以在/public_html/scgi-bin/hgweb.cgi/myrepo找到库。很可能,这不是你的回购所在的地方。该命令链是这样的:

Local Mercurial -> SSH -> Server file system 

您需要更改SSH URL使用绝对路径回购在服务器上:

hg clone ssh://myn[email protected]/path/to/myrepo 

它也像服务器找不到Mercurial可执行文件。

0

在使用时的汞的 'verbose' 选项,显露了两个问题:

  1. 当通过ssh调用时,hg自动尝试运行hg服务器,因此不需要通过hgweb.cgi进行操作。
  2. hg命令(在.bash_profile中设置)的路径未用于非交互式SSH命令。我不得不把路径放到某个地方,比如.bashrc。

解决所有这些问题了,下面的命令和预期一样:

hg clone ssh://[email protected]/public_html/myrepo