[Python-checkins] hooks: Properly format e-mails when the subject line is non-ASCII
local-hg
python-checkins at python.org
Thu May 19 23:36:13 CEST 2011
http://hg.python.org/hooks/rev/aebbd6f606f3
changeset: 72:aebbd6f606f3
user: Antoine Pitrou <solipsis at pitrou.net>
date: Thu May 19 23:36:13 2011 +0200
summary:
Properly format e-mails when the subject line is non-ASCII
files:
mail.py | 16 +++++++++++++---
1 files changed, 13 insertions(+), 3 deletions(-)
diff --git a/mail.py b/mail.py
--- a/mail.py
+++ b/mail.py
@@ -4,6 +4,7 @@
For use as an "incoming" hook.
"""
+from email.header import Header
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
from mercurial import cmdutil, patch
@@ -13,22 +14,23 @@
import smtplib
import os
import sys
+import traceback
BASE = 'http://hg.python.org/'
CSET_URL = BASE + '%s/rev/%s'
def send(sub, sender, to, body):
msg = MIMEMultipart()
- msg['Subject'] = sub
+ msg['Subject'] = Header(sub, 'utf8')
msg['To'] = to
msg['From'] = sender
msg.attach(MIMEText(body, _subtype='plain', _charset='utf8'))
smtp = smtplib.SMTP()
smtp.connect()
- smtp.sendmail(sender, msg['To'], msg.as_string())
+ smtp.sendmail(sender, to, msg.as_string())
smtp.close()
-def incoming(ui, repo, **kwargs):
+def _incoming(ui, repo, **kwargs):
# Ensure that no fancying of output is enabled (e.g. coloring)
os.environ['TERM'] = 'dumb'
ui.setconfig('ui', 'interactive', 'False')
@@ -109,3 +111,11 @@
print 'notified %s of incoming changeset %s' % (to, ctx)
return False
+def incoming(ui, repo, **kwargs):
+ # Make error reporting easier
+ try:
+ return _incoming(ui, repo, **kwargs)
+ except:
+ traceback.print_exc()
+ raise
+
--
Repository URL: http://hg.python.org/hooks
More information about the Python-checkins
mailing list