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

Mercurial hg clone在命令之间发送时挂起,mercurial,bitbucket,Mercurial,Bitbucket,我正在尝试从Windows命令行通过SSH克隆托管在BitBucket上的Mercurial存储库 当我添加--debug标志时,我可以看到它永远不会超过“在命令之间发送” 当我按ctrl+c时,它只显示中断!没有任何其他错误消息 我还查看了资源监视器,它在大约一分钟后没有显示任何相关的网络流量 我尝试添加--noupdate选项和--uncompressed选项,结果相同 仅使用Mercurial的Windows Server 2012-无乌龟 有什么想法吗 “在命令之间发送”是否需要一段时间

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

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

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

我还查看了资源监视器,它在大约一分钟后没有显示任何相关的网络流量

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

仅使用Mercurial的Windows Server 2012-无乌龟

有什么想法吗


“在命令之间发送”是否需要一段时间?存储库大约有150MB

我知道我来晚了,因为Bitbucket早就放弃了对Mercurial的支持,但这可能与那些在Windows上将其设置为与任何其他服务或在自托管环境中使用有关

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

>hg config --edit
[ui]
ssh="C:\programs\putty\plink.exe" -ssh -2
我花了大约两个小时来修补我的设置,然后我有了一个啊哈!请稍候,并尝试使用
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,打开它并从“视图”菜单中选择“显示流程树”(Ctrl+T),然后搜索流程
plink
。您可以看到此进程正在运行,并且是
hg
的子进程

我回答“y”,该项被缓存在

Computer\HKEY_CURRENT_USER\SOFTWARE\SimonTatham\PuTTY\SshHostKeys
新条目包含远程服务器名称和密钥本身

一旦解决了这个问题,我就可以使用
clone
push
pull
,以及其他命令,如
in
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
它看起来像是
hg
弄乱了SSH客户机的输入和输出,您永远无法看到那里发生了什么,也无法与之交互。并且指定
--debug
选项没有任何区别

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

[ui]
ssh="C:\programs\putty\plink.exe" -ssh -2 -sshlog plink.log
以下是日志的一部分,其中指出客户端不知道主机密钥:

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
它被卡在那个地方等待用户输入

出于好奇,我下载了Mercurial源代码并跟踪调试消息,直到
hg/Mercurial/sshpeer.py
中的方法
\u performhandshake

$ 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')

您可以在调用堆栈中看到,
实例中有一个对
\u makeconnection
的调用,它依次调用
procutil.popen4
,然后使用
子进程.Popen
类构造函数生成一个新进程,
子进程.PIPE
用作
stdin
的值,
stdout
stderr
参数

从图中可以看出:

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

因此,这很好地解释了为什么您不能与SSH客户机交互,因为它的所有标准输入、标准输出和标准错误都被Mercurial吃掉了


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

请显示
hg clone
的完整输出。您是否在mercurial.ini中定义了ssh程序?您是否找到了解决方案?处理同样的问题。。。“hg clone”的输出:“hg clone:无效参数hg clone[OPTION]…SOURCE[DEST]复制现有存储库选项([+]可以重复):”等。。。同样在.hgrce:ssh=“/mnt/c/Program Files/PuTTY/plink.exe”-ssh-c-i“####”中也有与Gabe和Justin相同的问题,有任何更新吗?从2018年起,Windows内置了OpenSSH客户端,因此不再需要PuTTY/plink。只需启用Windows功能,将配置和密钥添加到C:\\Users\Me\.ssh,您就可以开始了。哇,我不知道。谢谢分享,史蒂夫!