comparison hgext/patchbomb.py @ 9046:1547126630e9

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.
author Cédric Duval <cedricduval@free.fr>
date Sun, 05 Jul 2009 16:42:10 +0200
parents f4f0e902b750
children 8263d98ffb1c
comparison
equal deleted inserted replaced
9045:500013d3b6a9 9046:1547126630e9
68 to be a sendmail compatible mailer or fill out the [smtp] section so 68 to be a sendmail compatible mailer or fill out the [smtp] section so
69 that the patchbomb extension can automatically send patchbombs 69 that the patchbomb extension can automatically send patchbombs
70 directly from the commandline. See the [email] and [smtp] sections in 70 directly from the commandline. See the [email] and [smtp] sections in
71 hgrc(5) for details.''' 71 hgrc(5) for details.'''
72 72
73 import os, errno, socket, tempfile, cStringIO 73 import os, errno, socket, tempfile, cStringIO, time
74 import email.MIMEMultipart, email.MIMEBase 74 import email.MIMEMultipart, email.MIMEBase
75 import email.Utils, email.Encoders, email.Generator 75 import email.Utils, email.Encoders, email.Generator
76 from mercurial import cmdutil, commands, hg, mail, patch, util 76 from mercurial import cmdutil, commands, hg, mail, patch, util
77 from mercurial.i18n import _ 77 from mercurial.i18n import _
78 from mercurial.node import bin 78 from mercurial.node import bin
444 fp.close() 444 fp.close()
445 elif opts.get('mbox'): 445 elif opts.get('mbox'):
446 ui.status(_('Writing '), subj, ' ...\n') 446 ui.status(_('Writing '), subj, ' ...\n')
447 fp = open(opts.get('mbox'), 'In-Reply-To' in m and 'ab+' or 'wb+') 447 fp = open(opts.get('mbox'), 'In-Reply-To' in m and 'ab+' or 'wb+')
448 generator = email.Generator.Generator(fp, mangle_from_=True) 448 generator = email.Generator.Generator(fp, mangle_from_=True)
449 date = util.datestr(start_time, '%a %b %d %H:%M:%S %Y') 449 date = time.ctime(start_time[0])
450 fp.write('From %s %s\n' % (sender_addr, date)) 450 fp.write('From %s %s\n' % (sender_addr, date))
451 generator.flatten(m, 0) 451 generator.flatten(m, 0)
452 fp.write('\n\n') 452 fp.write('\n\n')
453 fp.close() 453 fp.close()
454 else: 454 else: