mercurial/dispatch.py
changeset 35653 48fe4f56a3b4
parent 35470 7906354cbc68
child 35938 a2b3b5c5a25a
--- a/mercurial/dispatch.py	Sun Jan 14 19:30:48 2018 -0800
+++ b/mercurial/dispatch.py	Sun Jan 14 20:06:56 2018 -0800
@@ -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():