hg return codes?

Greg Lindahl lindahl at pbm.com
Wed Feb 20 15:42:02 CST 2008


> 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

I don't think this is a bug. Lots of people write scripts that do a
periodic checkin over files without knowing (or caring) if there is an
actual change in them. Adding a return code for this case would mean
those scripts would have to check for and ignore "nothing changed", so
that real errors would not be ignored.

Now, if you want to know if there are any uncommitted changes, a flag
to "hg diff" that exits with a return code and doesn't show the actual
diff would do what you want. Alternately, this return code could become
the default... Unix diff returns 1 if there are differences.

-- greg




More information about the Mercurial mailing list