D3444: tests: comprehensively test exit handling
yuya at tcha.org
Sat May 12 01:51:51 EDT 2018
> > I generally like the direction of this series, but I think there's no point
> > to extend Mercurial's exit code handling to support all weird Python types.
> > Only ints and (None for 0) are ever valid.
> The reason I did this is because from the context or `rhg`, we don't have CPython's default exit handling to fall back on. Our choices are:
> 1. Reimplement CPython's exit/error handling in Rust
> 2. Reimplement CPython's exit/error handling in Python in dispatch [so the end state is more well-defined]
> 3. Do something crude in `rhg` when we hit special cases that CPython would normally deal with.
> Since extensions could do weird things, I figured 2 was the best option.
I don't fully understand the situation in `rhg`, but maybe we can instead
fix `scmutil.callcatch()` to either translate non-int SystemExit to integer
or raise ProgrammingError as a bad use of sys.exit() in hg. No SystemExit
should be raised outside of the callcatch().
I'm against allowing command functions to return any objects other than
int or None because it's useless.
More information about the Mercurial-devel