mail: mime-encode patches that are utf-8
utf-8 can be safely detected without making assumptions on the
encoding/locale used by the recipient.
Content-Transfer-Encoding for utf-8 patches is base64 (default of
python's email module).
--- a/mercurial/mail.py Mon Oct 20 14:13:37 2008 +0200
+++ b/mercurial/mail.py Mon Oct 20 17:40:29 2008 +0200
@@ -86,6 +86,17 @@
raise util.Abort(_('%r specified as email transport, '
'but not in PATH') % method)
+def mimetextpatch(s, subtype='plain', display=False):
+ '''If patch in utf-8 transfer-encode it.'''
+ if not display:
+ for cs in ('us-ascii', 'utf-8'):
+ try:
+ s.decode(cs)
+ return email.MIMEText.MIMEText(s, subtype, cs)
+ except UnicodeDecodeError:
+ pass
+ return email.MIMEText.MIMEText(s, subtype)
+
def _charsets(ui):
'''Obtains charsets to send mail parts not containing patches.'''
charsets = [cs.lower() for cs in ui.configlist('email', 'charsets')]