在Windows上的Mercurial中,如何正确设置(任何)编辑器? (不能提交)

时间:2013-05-18 02:23:05

标签: configuration mercurial editor tortoisehg

我在Windows XP上安装了TortoiseHg。虽然我通常可以从命令行使用大多数hg命令,但我无法使用hg commit(没有-m选项),因为它无法启动我的编辑器。这就是:

> hg commit
/c: /c: is a directory
abort: edit failed: notepad.exe exited with status 126
在mercurial.ini中的

我将编辑器设置为:     [UI]     editor = notepad.exe

如果我自己从命令行键入notepad.exe或甚至只是notepad,那么记事本工作正常。将编辑器变量更改为其他内容(例如foobar),确认Mercurial正在读取变量并尝试以相同的结果foobar运行foobar exited with status 126

使用TortoiseHg GUI的部分内容时也遇到问题。单击时,“查看修订版”等上下文菜单选项不起作用。据推测,他们正试图启动编辑器但是失败了。

这个问题在使用Mercurial的过程中持续了大约2年半,我已经尝试了所有我能想到的以另一种方式设置编辑器变量或将其设置为另一个程序。目前正在使用TortoiseHg 2.8版(“使用Mercurial-2.6,Python-2.7.3,PyQt-4.9.6,Qt-4.8.4”)。

相关问题:
Using other editor with TortoiseHg
How do I specify a different editor for Mercurial on Windows?
Mercurial Editor: "abort: The system cannot find the file specified"

1 个答案:

答案 0 :(得分:0)

在最终意识到问题之前,我问了这个问题。 Mercurial和TortoiseHg将Editor变量的值运行到命令解释器中,此解释器由COMSPEC环境变量指定。

显然,在我的生命中,我将此变量设置为msys shell C:\msys\bin\sh.exe(可能徒劳地尝试修复问题,这与我在这里提出的问题不同)。导致有趣的错误是因为msys shell被发送类似/c notepad.exe的参数。

如果Mercurial也决定也使用COMSPEC,我不知道为什么要传递额外的/c开关(具体是cmd.exe)。此外,当从TortoiseHg编辑设置时,我有点误导性地告诉我,如果我的mercurial配置文件中的Shell值未指定,那么它将默认为Windows上的cmd.exeShell的值可能用于其他内容,例如“Open Terminal”上下文菜单。