I have TortoiseHg installed on Windows XP. Although I can use most hg
commands normally from the command line, I cannot use hg commit
(without the -m
option) because it fails to launch my editor. This is what happens:
> hg commit
/c: /c: is a directory
abort: edit failed: notepad.exe exited with status 126
in mercurial.ini I have the editor set as: [ui] editor = notepad.exe
If I myself type notepad.exe
or even just notepad
from the command line then notepad works fine. Changing the editor variable to something else (like to foobar
) confirms that Mercurial is reading the variable and trying to run foobar
with the same result (foobar exited with status 126
).
I also have a problem using parts of the TortoiseHg GUI. Context menu options like "View at revision" don't work when clicked. Presumably they are trying to launch the editor but are failing.
This problem has persisted for about 2 1/2 years of using Mercurial, and I've tried everything I can think of to set the editor variable in another way or set it to another program. Currently using TortoiseHg version 2.8 ("with Mercurial-2.6, Python-2.7.3, PyQt-4.9.6, Qt-4.8.4").
related questions:
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"
Not long did I ask this question before finally realizing the problem. Mercurial and TortoiseHg are running the value of my Editor
variable into a command interpreter, and this interpreter is whichever is specified by the COMSPEC enviroment variable.
Apparently once in my life I set this variable to the msys shell C:\msys\bin\sh.exe
(probably in a vain attempt at trying to fix a problem not unlike the one I was asking here). The funny errors were caused because the msys shell being sent something like /c notepad.exe
as an argument.
I have no idea why the extra /c
switch is being passed (which is cmd.exe
specific) if Mercurial is also deciding to also use COMSPEC. Also, when editing the settings from TortoiseHg, I am somewhat misleadingly told that if the Shell
value in my mercurial config file is left unspecified, then it will default to cmd.exe
on windows. This value of Shell
is probably used for something else though, like the 'Open Terminal' context menu.