patchbomb: ignore exception if pager quits.
authorVadim Gelfer <vadim.gelfer@gmail.com>
Thu, 09 Mar 2006 16:26:49 -0800
changeset 1871 258e3a7955b8
parent 1868 6a3d5a56f19c
child 1872 d8a03e9b3776
patchbomb: ignore exception if pager quits.
hgext/patchbomb.py
--- a/hgext/patchbomb.py	Wed Mar 08 18:48:40 2006 -0800
+++ b/hgext/patchbomb.py	Thu Mar 09 16:26:49 2006 -0800
@@ -52,7 +52,7 @@
 from mercurial.demandload import *
 demandload(globals(), '''email.MIMEMultipart email.MIMEText email.Utils
                          mercurial:commands,hg,ui
-                         os popen2 smtplib socket sys tempfile time''')
+                         os errno popen2 smtplib socket sys tempfile time''')
 from mercurial.i18n import gettext as _
 
 try:
@@ -254,8 +254,12 @@
         if opts['test']:
             ui.status('Displaying ', m['Subject'], ' ...\n')
             fp = os.popen(os.getenv('PAGER', 'more'), 'w')
-            fp.write(m.as_string(0))
-            fp.write('\n')
+            try:
+                fp.write(m.as_string(0))
+                fp.write('\n')
+            except IOError, inst:
+                if inst.errno != errno.EPIPE:
+                    raise
             fp.close()
         elif opts['mbox']:
             ui.status('Writing ', m['Subject'], ' ...\n')