Mercurial > hg
changeset 7194:040e325e4f69
merge with crew
author | Thomas Arendsen Hein <thomas@intevation.de> |
---|---|
date | Mon, 20 Oct 2008 18:29:44 +0200 |
parents | 12fc42c78598 (diff) aecea6934fdd (current diff) |
children | 9fabcb1fe68d |
files | |
diffstat | 4 files changed, 82 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/hgext/patchbomb.py Mon Oct 20 15:19:05 2008 +0200 +++ b/hgext/patchbomb.py Mon Oct 20 18:29:44 2008 +0200 @@ -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:
--- a/mercurial/mail.py Mon Oct 20 15:19:05 2008 +0200 +++ b/mercurial/mail.py Mon Oct 20 18:29:44 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')]
--- a/tests/test-patchbomb Mon Oct 20 15:19:05 2008 +0200 +++ b/tests/test-patchbomb Mon Oct 20 18:29:44 2008 +0200 @@ -44,3 +44,27 @@ -c bar -s test -r tip -b --desc description | \ fixheaders +echo % utf-8 patch +python -c 'fp = open("utf", "w"); fp.write("h\xC3\xB6mma!\n"); fp.close();' +hg commit -A -d '4 0' -m 'charset=utf-8; content-transfer-encoding: base64' + +echo % no mime encoding for email --test +hg email --date '1970-1-1 0:4' -f quux -t foo -r tip -n | fixheaders > mailtest +echo % md5sum of 8-bit output +$TESTDIR/md5sum.py mailtest +rm mailtest + +echo % mime encoded mbox +hg email --date '1970-1-1 0:4' -f quux -t foo -r tip -m mbox +cat mbox | fixheaders +rm mbox + +echo % iso-8859-1 patch +python -c 'fp = open("isolatin", "w"); fp.write("h\xF6mma!\n"); fp.close();' +hg commit -A -d '5 0' -m 'charset=us-ascii; content-transfer-encoding: 8bit' + +echo % fake ascii mbox +hg email --date '1970-1-1 0:5' -f quux -t foo -r tip -m mbox +fixheaders < mbox > mboxfix +echo % md5sum of 8-bit output +$TESTDIR/md5sum.py mboxfix
--- a/tests/test-patchbomb.out Mon Oct 20 15:19:05 2008 +0200 +++ b/tests/test-patchbomb.out Mon Oct 20 18:29:44 2008 +0200 @@ -145,3 +145,46 @@ sgVa2F19D1tx9+hgbAygLgQwaIqcDdgA4BjQgIiz/AEP72++llgDKhKducqodGE4B0ETqF3JFOFC Q70eyNw= --=== +% utf-8 patch +adding description +adding utf +% no mime encoding for email --test +% md5sum of 8-bit output +a6a3c6b9b6009cea23871a7727a282ab mailtest +% mime encoded mbox +This patch series consists of 1 patches. + + +Writing [PATCH] charset=utf-8; content-transfer-encoding: base64 ... +From quux Thu Jan 01 00:04:01 1970 +Content-Type: text/plain; charset="utf-8" +MIME-Version: 1.0 +Content-Transfer-Encoding: base64 +Subject: [PATCH] charset=utf-8; content-transfer-encoding: base64 +X-Mercurial-Node: c3c9e37db9f4fe4882cda39baf42fed6bad8b15a +Message-Id: <c3c9e37db9f4fe4882cd.240@ +Date: Thu, 01 Jan 1970 00:04:00 +0000 +From: quux +To: foo + +IyBIRyBjaGFuZ2VzZXQgcGF0Y2gKIyBVc2VyIHRlc3QKIyBEYXRlIDQgMAojIE5vZGUgSUQgYzNj +OWUzN2RiOWY0ZmU0ODgyY2RhMzliYWY0MmZlZDZiYWQ4YjE1YQojIFBhcmVudCAgZmYyYzlmYTIw +MThiMTVmYTc0YjMzMzYzYmRhOTUyNzMyM2UyYTk5ZgpjaGFyc2V0PXV0Zi04OyBjb250ZW50LXRy +YW5zZmVyLWVuY29kaW5nOiBiYXNlNjQKCmRpZmYgLXIgZmYyYzlmYTIwMThiIC1yIGMzYzllMzdk +YjlmNCBkZXNjcmlwdGlvbgotLS0gL2Rldi9udWxsCVRodSBKYW4gMDEgMDA6MDA6MDAgMTk3MCAr +MDAwMAorKysgYi9kZXNjcmlwdGlvbglUaHUgSmFuIDAxIDAwOjAwOjA0IDE5NzAgKzAwMDAKQEAg +LTAsMCArMSwzIEBACithIG11bHRpbGluZQorCitkZXNjcmlwdGlvbgpkaWZmIC1yIGZmMmM5ZmEy +MDE4YiAtciBjM2M5ZTM3ZGI5ZjQgdXRmCi0tLSAvZGV2L251bGwJVGh1IEphbiAwMSAwMDowMDow +MCAxOTcwICswMDAwCisrKyBiL3V0ZglUaHUgSmFuIDAxIDAwOjAwOjA0IDE5NzAgKzAwMDAKQEAg +LTAsMCArMSwxIEBACitow7ZtbWEhCg== + + +% iso-8859-1 patch +adding isolatin +% fake ascii mbox +This patch series consists of 1 patches. + + +Writing [PATCH] charset=us-ascii; content-transfer-encoding: 8bit ... +% md5sum of 8-bit output +45cb4b77e02f39eb91955f5c95913d66 mboxfix