[PATCH] patchbomb: fix From_ in the message's envelope

Cédric Duval cedricduval at free.fr
Sun Jul 5 09:42:12 CDT 2009


# HG changeset patch
# User Cédric Duval <cedricduval at free.fr>
# Date 1246804930 -7200
# Node ID f115a5155195bb05b470ed1bff72339fa500f4b2
# Parent  8761863c3118bfd1627c5e66b7ea29f131188ea4
patchbomb: fix From_ in the message's envelope

Localized date in the From_ prevents MUAs like mutt from parsing mbox files
generated by patchbomb. Using a 24 characters date in asctime format instead.

diff --git a/hgext/patchbomb.py b/hgext/patchbomb.py
--- a/hgext/patchbomb.py
+++ b/hgext/patchbomb.py
@@ -70,7 +70,7 @@
 directly from the commandline. See the [email] and [smtp] sections in
 hgrc(5) for details.'''
 
-import os, errno, socket, tempfile, cStringIO
+import os, errno, socket, tempfile, cStringIO, time
 import email.MIMEMultipart, email.MIMEBase
 import email.Utils, email.Encoders, email.Generator
 from mercurial import cmdutil, commands, hg, mail, patch, util
@@ -446,7 +446,7 @@
             ui.status(_('Writing '), subj, ' ...\n')
             fp = open(opts.get('mbox'), 'In-Reply-To' in m and 'ab+' or 'wb+')
             generator = email.Generator.Generator(fp, mangle_from_=True)
-            date = util.datestr(start_time, '%a %b %d %H:%M:%S %Y')
+            date = time.ctime(start_time[0])
             fp.write('From %s %s\n' % (sender_addr, date))
             generator.flatten(m, 0)
             fp.write('\n\n')
diff --git a/tests/test-patchbomb.out b/tests/test-patchbomb.out
--- a/tests/test-patchbomb.out
+++ b/tests/test-patchbomb.out
@@ -163,7 +163,7 @@
 
 
 Writing [PATCH] charset=utf-8; content-transfer-encoding: base64 ...
-From quux Thu Jan 01 00:04:01 1970
+From quux Thu Jan  1 00:04:01 1970
 Content-Type: text/plain; charset="utf-8"
 MIME-Version: 1.0
 Content-Transfer-Encoding: base64
@@ -198,7 +198,7 @@
 
 
 Writing [PATCH] charset=utf-8; content-transfer-encoding: quoted-printable ...
-From quux Thu Jan 01 00:04:01 1970
+From quux Thu Jan  1 00:04:01 1970
 Content-Type: text/plain; charset="us-ascii"
 MIME-Version: 1.0
 Content-Transfer-Encoding: quoted-printable
@@ -249,7 +249,7 @@
 
 Writing [PATCH] charset=us-ascii; content-transfer-encoding: 8bit ...
 % md5sum of 8-bit output
-e61684fc0bcccba4204714be37951893  mboxfix
+8ce4c019c17ca51a293c055382d76d67  mboxfix
 % test diffstat for single patch
 This patch series consists of 1 patches.
 



More information about the Mercurial-devel mailing list