[PATCH 2 of 2] patchbomb: mime-encode clean utf-8 patches (issue814)

Christian Ebert blacktrash at gmx.net
Mon Oct 20 03:39:03 CDT 2008


# HG changeset patch
# User Christian Ebert <blacktrash at gmx.net>
# Date 1224491726 -7200
# Node ID f2464090d51af258c5c22a35f5344c2fb1db1f3b
# Parent  951bef46c3fc972e35c169c22bb19c840d93a1a5
patchbomb: mime-encode clean utf-8 patches (issue814)

Fixes issue814, but only for utf.

diff --git a/hgext/patchbomb.py b/hgext/patchbomb.py
--- a/hgext/patchbomb.py
+++ b/hgext/patchbomb.py
@@ -62,7 +62,7 @@
 That should be all. Now your patchbomb is on its way out.'''
 
 import os, errno, socket, tempfile, cStringIO
-import email.MIMEMultipart, email.MIMEText, email.MIMEBase
+import email.MIMEMultipart, email.MIMEBase
 import email.Utils, email.Encoders, email.Generator
 from mercurial import cmdutil, commands, hg, mail, patch, util
 from mercurial.i18n import _
@@ -180,7 +180,8 @@
             if body:
                 msg.attach(mail.mimeencode(ui, body, _charsets,
                                            opts.get('test')))
-            p = email.MIMEText.MIMEText('\n'.join(patch), 'x-patch')
+            p = mail.mimetextpatch('\n'.join(patch), 'x-patch',
+                                   opts.get('test'))
             binnode = bin(node)
             # if node is mq patch, it will have patch file name as tag
             patchname = [t for t in repo.nodetags(binnode)
@@ -199,7 +200,7 @@
             msg.attach(p)
         else:
             body += '\n'.join(patch)
-            msg = email.MIMEText.MIMEText(body)
+            msg = mail.mimetextpatch(body, display=opts.get('test'))
 
         subj = desc[0].strip().rstrip('. ')
         if total == 1:


More information about the Mercurial-devel mailing list