sapling/tests/test-dispatch.py.out
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

24 lines
466 B
Plaintext

running: init test1
result: 0
running: add foo
result: 0
running: commit -m commit1 -d 2000-01-01 foo
result: 0
running: commit -m commit2 -d 2000-01-02 foo
result: 0
running: log -r 0
changeset: 0:0e4634943879
user: test
date: Sat Jan 01 00:00:00 2000 +0000
summary: commit1
result: 0
running: log -r tip
changeset: 1:45589e459b2e
tag: tip
user: test
date: Sun Jan 02 00:00:00 2000 +0000
summary: commit2
result: 0