Skip to content
Snippets Groups Projects
Commit 975c4fc4a512 authored by Katsunori FUJIWARA's avatar Katsunori FUJIWARA
Browse files

hg.bat: return exit code explicitly for indirect invocation

When "hg.bat" is invoked via interactive shell "cmd.exe" on Windows,
it can store own exit code into ERRORLEVEL correctly, regardless of
explicit "exit" statement in it: "cmd.exe" seems to hold ERRORLEVEL
updated by the last command in the batch file (= "python hg", in
"hg.bat" case).

On the other hand, "hg.bat" is invoked indirectly via
"subprocess.Popen" (e.g. shell alias, hooks, hgclient and so on), the
parent process always receives exit code 0 from spawned "hg.bat":
batch files on Windows seem not to be really spawned like as shell
scripts on UNIX, but to be executed in the "cmd.exe" process.

This patch returns exit code explicitly for indirect invocation.

"/b" should be specified for "exit" to prevent "cmd.exe" from being
terminated when "hg.bat" is invoked interactively from it.
parent 769027075e21
No related branches found
No related tags found
No related merge requests found
......@@ -15,3 +15,5 @@
python "%~dp0hg" %*
)
endlocal
exit /b %ERRORLEVEL%
......@@ -525,3 +525,12 @@
[1]
$ hg exit1
[1]
#if no-outer-repo
$ hg root
abort: no repository found in '$TESTTMP' (.hg not found)!
[255]
$ hg --config alias.hgroot='!hg root' hgroot
abort: no repository found in '$TESTTMP' (.hg not found)!
[255]
#endif
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment