diff --git a/mercurial/dispatch.py b/mercurial/dispatch.py --- a/mercurial/dispatch.py +++ b/mercurial/dispatch.py @@ -96,10 +96,16 @@ err = e status = -1 if util.safehasattr(req.ui, 'ferr'): - if err is not None and err.errno != errno.EPIPE: - req.ui.ferr.write('abort: %s\n' % - encoding.strtolocal(err.strerror)) - req.ui.ferr.flush() + try: + if err is not None and err.errno != errno.EPIPE: + req.ui.ferr.write('abort: %s\n' % + encoding.strtolocal(err.strerror)) + req.ui.ferr.flush() + # There's not much we can do about an I/O error here. So (possibly) + # change the status code and move on. + except IOError: + status = -1 + sys.exit(status & 255) def _initstdio(): diff --git a/tests/test-basic.t b/tests/test-basic.t --- a/tests/test-basic.t +++ b/tests/test-basic.t @@ -34,15 +34,7 @@ [255] #endif -#if devfull no-chg - $ hg status >/dev/full 2>&1 - [1] - - $ hg status ENOENT 2>/dev/full - [1] -#endif - -#if devfull chg +#if devfull $ hg status >/dev/full 2>&1 [255]