hg return codes?

BuraphaLinux Server buraphalinuxserver at gmail.com
Wed Feb 20 09:11:29 CST 2008


Hello Mercurial List,

When I do this:

bash-3.2$ mkdir a
bash-3.2$ cd a
bash-3.2$ hg init
bash-3.2$ hg add bogus
bogus: No such file or directory
bash-3.2$ echo $?
0

I expect some non-zero return code so I can script it, but it seems
everything returns 0.  Continuing on to show what I mean:
bash-3.2$ echo 'strange' >a
bash-3.2$ hg commit -m"bogus"
nothing changed
bash-3.2$ echo $?
0

Since everything else seems so nice (I'm a former RCS person, and I
use mercurial for my private work) I'm wondering if there is some
switch or configuration file I have set wrong that is preventing
reasonable return codes from hg.

Obviously you never type the wrong thing, but I generate scripts that
have hg commands in them, and when there is a script error (my fault)
I'd like to be able to do the normal sequence like this:

...
# some bad stuff here where my other stuff failed,
# resulting in no changed files for instance
...
hg commit -m"bogus"
nothing changed
if ((${?}!=0))
then
   # handle the error where commit didn't work
   exit 1
fi

What do you do to script it so you can detect errors?  I'm using 0.9.5
in bash 3.2.33 on linux.  I did read the man page, but I couldn't find
anything about return codes in it.  Even if you just have 0 for good
and 1 for trouble that's enough for me.


More information about the Mercurial mailing list