Checking hg exit code in Windows batch

Jérôme Godbout jerome at bodycad.com
Mon Jul 7 18:42:25 UTC 2014


Hi, I tried with mercurial 3.0.1, it worked for me
c:\MyProject> hg update
0 files updated, 0 files merged, 0 files removed, 0 files unresolved

c:\MyProject> echo %ERRORLEVEL%
0

c:\MyProject> hg update -r toto123
abort: unknown revision 'toto123'!

c:\MyProject> echo %ERRORLEVEL%
255

You may want to update to 3.0.1 or above to solve your problem. Haven't try
into a batch.
Jerome Godbout



On Mon, Jul 7, 2014 at 12:24 PM, Jan Vrany <jan.vrany at fit.cvut.cz> wrote:

> 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
> _______________________________________________
> Mercurial mailing list
> Mercurial at selenic.com
> http://selenic.com/mailman/listinfo/mercurial
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mercurial-scm.org/pipermail/mercurial/attachments/20140707/b32b82c8/attachment-0002.html>


More information about the Mercurial mailing list