mirror of
https://github.com/facebook/sapling.git
synced 2024-10-12 01:39:21 +03:00
56246aa66c
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
27 lines
671 B
Perl
27 lines
671 B
Perl
Command line flag is effective:
|
|
|
|
$ hg add a --config ui.exitcodemask=63
|
|
abort: no repository found in '$TESTTMP' (.hg not found)!
|
|
[63]
|
|
|
|
$ HGPLAIN=1 hg add a --config ui.exitcodemask=63
|
|
abort: no repository found in '$TESTTMP' (.hg not found)!
|
|
[63]
|
|
|
|
Config files are ignored if HGPLAIN is set:
|
|
|
|
$ setconfig ui.exitcodemask=31
|
|
$ hg add a
|
|
abort: no repository found in '$TESTTMP' (.hg not found)!
|
|
[31]
|
|
|
|
$ HGPLAIN=1 hg add a
|
|
abort: no repository found in '$TESTTMP' (.hg not found)!
|
|
[255]
|
|
|
|
But HGPLAINEXCEPT can override the behavior:
|
|
|
|
$ HGPLAIN=1 HGPLAINEXCEPT=exitcode hg add a
|
|
abort: no repository found in '$TESTTMP' (.hg not found)!
|
|
[31]
|