Checking hg exit code in Windows batch

Jan Vrany jan.vrany at fit.cvut.cz
Mon Jul 7 16:24:09 UTC 2014


Hi there,

I'm struggling to check exit code og hg command on Windows.
I have a .bat file doing something like

hg --cwd %PKGDIR% update -r %REVISION%
IF [%ERRORLEVEL%] NEQ [0] (
    ECHO Cannot update working copy in %PKGDIR%
    GOTO error
)

but it seems that %ERRORLEVEL% is always 0, even if revision is
completely bogus. I tried following in Windows 'Command Prompt':

H:\Projects\someproject>hg update -r bogus
abort: unknown revision 'bogus'!

H:\Projects\someproject>>echo %errorlevel%
0

i.e., same result, I got 0. On Linux it works as I would expect (getting 
255). The system is Win 7 64 bit box with Mercurial 2.9.2 installed from 
.msi package downloaded from selenic.

Any idea what I'm doing wrong?
Thanks a lot.

Best, Jan



More information about the Mercurial mailing list