hg clone在命令之间发送时挂起

时间:2015-05-28 21:15:13

标签: mercurial bitbucket

我试图通过SSH从Windows命令行克隆在BitBucket上托管的Mercurial存储库

当我添加--debug标志时,我可以看到它永远不会超过'发送命令'

当我按住ctrl + c时,它只显示中断!没有任何其他错误消息。

我也在查看资源监视器,并且在第一分钟左右之后它没有显示任何相关的网络流量。

我尝试添加--noupdate选项和--uncompressed选项,结果相同。

仅使用Mercurial的Windows Server 2012 - No TortoiseHg

有什么想法吗?

是否有理由在命令之间发送'需要一段时间吗?存储库大约150MB

1 个答案:

答案 0 :(得分:0)

我知道我参加聚会很晚,因为Bitbucket早已放弃了对Mercurial的支持,但这可能与在Windows上将其设置为与任何其他服务或在自托管环境中使用的支持有关。 >

我假设您已将plink设置为SSH客户端。如果没有,可以通过在您的Mercurial配置中添加ssh参数来轻松完成。我的mercurial.ini文件的内容如下:

>hg config --edit
[ui]
ssh="C:\programs\putty\plink.exe" -ssh -2

在我获得Aha之前,我花了大约两个小时来修改自己的设置!并尝试使用plink连接到服务器,看看问题是否出在这里:

>plink.exe hg-ssh@hg.example.com -noagent id
The server's host key is not cached in the registry. You
have no guarantee that the server is the computer you
think it is.
The server's ssh-ed25519 key fingerprint is:
ssh-ed25519 255 90:8d:b0:26:c5:6e:74:2a:6c:3d:80:42:54:9e:15:47
If you trust this host, enter "y" to add the key to
PuTTY's cache and carry on connecting.
If you want to carry on connecting just once, without
adding the key to the cache, enter "n".
If you do not trust this host, press Return to abandon the
connection.
Store key in cache? (y/n)

宾果!

如您在此处看到的,plink提示输入,我们必须提供输入才能继续进行。因此,这就是hg无限期挂起的原因。

您还可以下载Process Explorer,将其打开,然后从View菜单中选择Show Process Tree( Ctrl + T ),然后搜索进程plink。您可以看到此进程正在运行,并且是hg的子进程。

我回答“ y”,并且密钥被缓存在

下的注册表项中
Computer\HKEY_CURRENT_USER\SOFTWARE\SimonTatham\PuTTY\SshHostKeys

新条目包含远程服务器名称和密钥本身。

一旦出现问题,我可以使用clonepushpull以及其他命令,例如in和{ {1}}:

out

好像>hg clone ssh://hg-ssh@hg.example.com/review destination directory: review requesting all changes adding changesets adding manifests adding file changes added 2 changesets with 4 changes to 4 files new changesets f82779871203:e9b1a2b79f98 (1 drafts) updating to branch default 4 files updated, 0 files merged, 0 files removed, 0 files unresolved 弄乱了SSH客户端的输入和输出,您永远也看不到那里发生了什么,也无法与之交互。并且指定hg选项没有区别。

您还可以向--debug提供-sshlog选项,以将会话的日志协议详细信息保存到文件中:

plink

这是日志的一部分,它表示客户端不知道主机密钥:

[ui]
ssh="C:\programs\putty\plink.exe" -ssh -2 -sshlog plink.log

它被卡在该位置附近,等待用户输入。

出于好奇,我下载了Mercurial源代码,并在Incoming packet #0x2, type 21 / 0x15 (SSH2_MSG_NEWKEYS) Event Log: Server also has ecdsa-sha2-nistp256/ssh-rsa host keys, but we don't know any of them Event Log: Host key fingerprint is: Event Log: ssh-ed25519 255 90:8d:b0:26:c5:6e:74:2a:6c:3d:80:42:54:9e:15:47 中跟踪了调试消息,直到方法_performhandshake

hg/mercurial/sshpeer.py

Full sshpeer.py source code

您可以看到调用堆栈,在$ hg clone https://www.mercurial-scm.org/repo/hg $ grep -R 'sending between command' hg $ less hg/mercurial/sshpeer.py ui.debug(b'sending hello command\n') ui.debug(b'sending between command\n') 内有一个对instance的调用,依次调用了_makeconnection,然后使用procutil.popen4类构造函数产生一个新进程,并且subprocess.Popen用作subprocess.PIPEstdinstdout自变量的值。

subprocess manual中,您可以看到:

stderr表示应创建到子级的新管道。

因此,这足以解释为什么您无法与SSH客户端进行交互,因为它的所有标准输入,标准输出和标准错误都被Mercurial吞噬了。

任何阅读此答案的人,请尝试一下此解决方案,并让我们知道它是否有帮助!

相关问题