# HG changeset patch
# User Benoit Boissinot <benoit.boissinot@ens-lyon.org>
# Date 2006-03-23 22:16:41
# Node ID 0541768fa558bed3a5df26aedb4fca44b5ee84bf
# Parent  18a3e63696004ac7ba8f916349d11986a893a5f5

ignore EPIPE in ui.err_write

It avoids not being able to abort a transaction when a push via ssh fails.
Maybe some other place should ignore EPIPE too.


diff --git a/mercurial/ui.py b/mercurial/ui.py
--- a/mercurial/ui.py
+++ b/mercurial/ui.py
@@ -8,7 +8,7 @@
 import ConfigParser
 from i18n import gettext as _
 from demandload import *
-demandload(globals(), "os re socket sys util tempfile")
+demandload(globals(), "errno os re socket sys tempfile util")
 
 class ui(object):
     def __init__(self, verbose=False, debug=False, quiet=False,
@@ -179,9 +179,13 @@ class ui(object):
             sys.stdout.write(str(a))
 
     def write_err(self, *args):
-        if not sys.stdout.closed: sys.stdout.flush()
-        for a in args:
-            sys.stderr.write(str(a))
+        try:
+            if not sys.stdout.closed: sys.stdout.flush()
+            for a in args:
+                sys.stderr.write(str(a))
+        except IOError, inst:
+            if inst.errno != errno.EPIPE:
+                raise
 
     def flush(self):
         try: