Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

windows batch file exits when running mercurial commands

For daily backup of my mercurial repositories on Windows XP I used a simple batch file hg_backup.bat which just did some directory changes and mercurial calls with a pause command in the end like this:

@Z:
@cd \hg_backup\drawings
hg pull -v
@cd \hg_backup\src\scripts
hg pull -v
@cd \hg_backup\eagle4\lbr
hg pull -v
@pause

This worked fine with mercurial up to 1.7 (installed with TortoiseHg). However since mercurial 1.8 it starts the very first mercurial command and then exits abruptly without reaching the following commands or even the end of the script. The command window just disappears.

I had the same problem some time before, when I tried the same thing with git, but didn't investigate further, because I use git for one repository only. It seems to me, there's some return code of the hg command line call involved which causes the script to end instead of executing the other command but I couldn't verify this yet.

Has anyone an idea why this happens or maybe even how to fix it?

like image 567
LeSpocky Avatar asked Mar 07 '11 08:03

LeSpocky


1 Answers

If your hg is a hg.bat or hg.cmd, use call hg and see if it starts working.

The command.com shell executes batch files replacing the old script (to save memory), and requires using call to start a batch script and continue execution later. This behavior remains in Windows cmd.exe for compatibility.

like image 64
user1686 Avatar answered Nov 07 '22 07:11

user1686