Checking hg exit code in Windows batch
Jérôme Godbout
jerome at bodycad.com
Tue Jul 8 15:37:21 UTC 2014
Just some info that may help, since %ERRORLEVEL% is a pseudo variable,
maybe you can try to use the errorlevel directly. %ERRORLEVEL% is an
equivalent to do the following:
*if errorlevel 1 echo Error*
maybe you can try to test errorlevel instead, maybe %ERRORLEVEL% was
modified into your setup.
You may also tryt o reset the error level before doing the operation you
want to check:
*set errorlevel=0*
*... operation here ...*
*if errorlevel 1 ...*
Maybe that can help find the problem,
Jerome Godbout
On Tue, Jul 8, 2014 at 4:48 AM, Jan Vrany <jan.vrany at fit.cvut.cz> wrote:
> Hi,
>
> I tried with 3.0.1 and same result.
> Funny enough, I tried on another Win 7 machine (almost the same setup)
> and there it works.
>
> I don't really understand why is that. But apparently the problem is not
> only in mercurial but rather some combination of OS, DLLs, hell knows what.
>
> Sorry, I should have tried that before posting here.
>
> Jan
>
> On 07/07/14 19:42, Jérôme Godbout wrote:
>
>> 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
>> <mailto: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 <mailto:Mercurial at selenic.com>
>> http://selenic.com/mailman/__listinfo/mercurial
>> <http://selenic.com/mailman/listinfo/mercurial>
>>
>>
>>
> _______________________________________________
> 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/20140708/46ef9d0b/attachment-0002.html>
More information about the Mercurial
mailing list