dispatch: handle IOError when writing to stderr
Previously, attempts to write to stderr in dispatch.run() may lead to
an exception being thrown. This would likely be handled by Python's
default exception handler, which would print the exception and exit
1.
Code in this function is already catching IOError for stdout failures
and converting to exit code 255 (-1 & 255 == 255). Why we weren't
doing the same for stderr for the sake of consistency, I don't know.
I do know that chg and hg diverged in behavior here (as the changed
test-basic.t shows).
After this commit, we catch I/O failure on stderr and change the
exit code to 255. chg and hg now behave consistently. As a bonus,
Rust hg also now passes this test.
I'm skeptical at changing the exit code due to failures this late
in the process. I think we should consider preserving the current
exit code - assuming it is non-0. And, we may want to preserve the
exit code completely if the I/O error is EPIPE (and potentially
other special error classes). There's definitely room to tweak
behavior. But for now, let's at least prevent the uncaught exception.
Differential Revision: https://phab.mercurial-scm.org/D1860
{
// Enforcing
"eqeqeq" : true, // true: Require triple equals (===) for comparison
"forin" : true, // true: Require filtering for..in loops with obj.hasOwnProperty()
"freeze" : true, // true: prohibits overwriting prototypes of native objects such as Array, Date etc.
"nonbsp" : true, // true: Prohibit "non-breaking whitespace" characters.
"undef" : true, // true: Require all non-global variables to be declared (prevents global leaks)
// Environments
"browser" : true // Web Browser (window, document, etc)
}