From patchwork Mon Jan 15 13:25:40 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: D1860: dispatch: handle IOError when writing to stderr From: phabricator X-Patchwork-Id: 26761 Message-Id: To: mercurial-devel@mercurial-scm.org Date: Mon, 15 Jan 2018 13:25:40 +0000 This revision was automatically updated to reflect the committed changes. Closed by commit rHG48fe4f56a3b4: dispatch: handle IOError when writing to stderr (authored by indygreg, committed by ). REPOSITORY rHG Mercurial CHANGES SINCE LAST UPDATE https://phab.mercurial-scm.org/D1860?vs=4828&id=4831 REVISION DETAIL https://phab.mercurial-scm.org/D1860 AFFECTED FILES mercurial/dispatch.py tests/test-basic.t CHANGE DETAILS To: indygreg, #hg-reviewers, yuja Cc: mercurial-devel 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] 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():