Commit Graph

3 Commits

Author SHA1 Message Date
Jun Wu
56246aa66c dispatch: add a config option to control exit code
Summary:
Previously, hg returns -1 (255) on "unknown errors". That could conflict with
other things. For example, http://tldp.org/LDP/abs/html/exitcodes.html suggests
1, 2, 126 ... 255 have special meanings defined by a common shell.  Namely,
`ssh` also returns 255.

Another long complaints about hg exit code is the use of 1 to indicate
"no changes". Although that's explained at [1], a lot of scripts still find it
surprising.

This diff adds a `ui.exitcodemask` config option, which makes it to alter the
exit code. Set it to 254 will change 1 to 0 for some script use-cases. Set it
to 63 or so will avoid conflicts with software like `ssh`.

Many existing scripts still expect 255 to be the return code. So we cannot
change the default value that easily. To avoid surprises (like, put the config
option in `/etc/mercurial/hgrc.d/exitcode.rc`), the config set by config
files is ignored if `HGPLAIN` is set and `HGPLAINEXCEPT` does not contain
`exitcode`.

[1]: https://www.mercurial-scm.org/pipermail/mercurial-devel/2012-January/037711.html

Reviewed By: DurhamG

Differential Revision: D7921817

fbshipit-source-id: 764b0de030fc727aa5df7305c2b8bc92f576cd33
2018-06-13 16:14:01 -07:00
Patrick Mezard
fd1268357e commands: add exits(1) if a specified file cannot be added (issue 891) 2007-12-24 12:14:43 +01:00
Thomas Arendsen Hein
9c6e25abcf Added test for commands.dispatch (especially 88803a69b24) 2007-08-11 13:34:19 +02:00