patchbomb: normalize date format in generated mboxes
mbox format should use time.asctime(). Unfortunately, this function writes
2-characters day of week on Windows while unix one writes a single character.
Normalize to Windows version since the other one can hardly be written with
strftime().
--- a/hgext/patchbomb.py Tue Nov 10 11:57:03 2009 +0100
+++ b/hgext/patchbomb.py Sun Nov 08 18:08:24 2009 +0100
@@ -451,7 +451,10 @@
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 = time.ctime(start_time[0])
+ # Should be time.asctime(), but Windows prints 2-characters day
+ # of month instead of one. Make them print the same thing.
+ date = time.strftime('%a %b %d %H:%M:%S %Y',
+ time.localtime(start_time[0]))
fp.write('From %s %s\n' % (sender_addr, date))
generator.flatten(m, 0)
fp.write('\n\n')
--- a/tests/test-patchbomb.out Tue Nov 10 11:57:03 2009 +0100
+++ b/tests/test-patchbomb.out Sun Nov 08 18:08:24 2009 +0100
@@ -163,7 +163,7 @@
Writing [PATCH] charset=utf-8; content-transfer-encoding: base64 ...
-From quux Thu Jan 1 00:04:01 1970
+From quux Thu Jan 01 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 1 00:04:01 1970
+From quux Thu Jan 01 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
-0920ef519c29b6a1742047ad9f203fc5 mboxfix
+9ea043d8fc43a71045114508baed144b mboxfix
% test diffstat for single patch
This patch series consists of 1 patches.
@@ -1474,7 +1474,7 @@
Writing [PATCH] test ...
-From quux Tue Jan 1 00:01:01 1980
+From quux Tue Jan 01 00:01:01 1980
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit