Mercurial > hg > mercurial-crew-with-dirclash
diff hgext/patchbomb.py @ 4033:84e469ce6408
merge with jsmith
author | Benoit Boissinot <benoit.boissinot@ens-lyon.org> |
---|---|
date | Mon, 15 Jan 2007 22:46:03 +0100 |
parents | 9210fba03d16 |
children | 03e9c22a6489 |
line wrap: on
line diff
--- a/hgext/patchbomb.py +++ b/hgext/patchbomb.py @@ -63,9 +63,9 @@ # # That should be all. Now your patchbomb is on its way out. -import os, errno, socket, time +import os, errno, socket import email.MIMEMultipart, email.MIMEText, email.Utils -from mercurial import cmdutil, commands, hg, mail, ui, patch +from mercurial import cmdutil, commands, hg, mail, ui, patch, util from mercurial.i18n import _ from mercurial.node import * @@ -164,10 +164,10 @@ def patchbomb(ui, repo, *revs, **opts): msg['X-Mercurial-Node'] = node return msg - start_time = int(time.time()) + start_time = util.makedate() def genmsgid(id): - return '<%s.%s@%s>' % (id[:20], start_time, socket.getfqdn()) + return '<%s.%s@%s>' % (id[:20], int(start_time[0]), socket.getfqdn()) patches = [] @@ -243,13 +243,6 @@ def patchbomb(ui, repo, *revs, **opts): mailer = mail.connect(ui) parent = None - # Calculate UTC offset - if time.daylight: offset = time.altzone - else: offset = time.timezone - if offset <= 0: sign, offset = '+', -offset - else: sign = '-' - offset = '%s%02d%02d' % (sign, offset / 3600, (offset % 3600) / 60) - sender_addr = email.Utils.parseaddr(sender)[1] for m in msgs: try: @@ -260,9 +253,10 @@ def patchbomb(ui, repo, *revs, **opts): m['In-Reply-To'] = parent else: parent = m['Message-Id'] - m['Date'] = time.strftime("%a, %d %b %Y %H:%M:%S", time.localtime(start_time)) + ' ' + offset + m['Date'] = util.datestr(date=start_time, + format="%a, %d %b %Y %H:%M:%S", timezone=True) - start_time += 1 + start_time = (start_time[0] + 1, start_time[1]) m['From'] = sender m['To'] = ', '.join(to) if cc: m['Cc'] = ', '.join(cc) @@ -280,7 +274,8 @@ def patchbomb(ui, repo, *revs, **opts): elif opts['mbox']: ui.status('Writing ', m['Subject'], ' ...\n') fp = open(opts['mbox'], m.has_key('In-Reply-To') and 'ab+' or 'wb+') - date = time.asctime(time.localtime(start_time)) + date = util.datestr(date=start_time, + format='%a %b %d %H:%M:%S %Y', timezone=False) fp.write('From %s %s\n' % (sender_addr, date)) fp.write(m.as_string(0)) fp.write('\n\n')