##// END OF EJS Templates
patchbomb: fix timezone offset in message date header...
Christian Ebert -
r4027:2601ac9c default
parent child Browse files
Show More
@@ -65,8 +65,8 b''
65 65
66 66 from mercurial.demandload import *
67 67 demandload(globals(), '''email.MIMEMultipart email.MIMEText email.Utils
68 mercurial:cmdutil,commands,hg,mail,ui,patch
69 os errno popen2 socket sys tempfile time''')
68 mercurial:cmdutil,commands,hg,mail,ui,patch,util
69 os errno popen2 socket sys tempfile''')
70 70 from mercurial.i18n import gettext as _
71 71 from mercurial.node import *
72 72
@@ -165,10 +165,10 b' def patchbomb(ui, repo, *revs, **opts):'
165 165 msg['X-Mercurial-Node'] = node
166 166 return msg
167 167
168 start_time = int(time.time())
168 start_time = util.makedate()
169 169
170 170 def genmsgid(id):
171 return '<%s.%s@%s>' % (id[:20], start_time, socket.getfqdn())
171 return '<%s.%s@%s>' % (id[:20], int(start_time[0]), socket.getfqdn())
172 172
173 173 patches = []
174 174
@@ -254,13 +254,6 b' def patchbomb(ui, repo, *revs, **opts):'
254 254 mailer = mail.connect(ui)
255 255 parent = None
256 256
257 # Calculate UTC offset
258 if time.daylight: offset = time.altzone
259 else: offset = time.timezone
260 if offset <= 0: sign, offset = '+', -offset
261 else: sign = '-'
262 offset = '%s%02d%02d' % (sign, offset / 3600, (offset % 3600) / 60)
263
264 257 sender_addr = email.Utils.parseaddr(sender)[1]
265 258 for m in msgs:
266 259 try:
@@ -271,9 +264,10 b' def patchbomb(ui, repo, *revs, **opts):'
271 264 m['In-Reply-To'] = parent
272 265 else:
273 266 parent = m['Message-Id']
274 m['Date'] = time.strftime("%a, %d %b %Y %H:%M:%S", time.localtime(start_time)) + ' ' + offset
267 m['Date'] = util.datestr(date=start_time,
268 format="%a, %d %b %Y %H:%M:%S", timezone=True)
275 269
276 start_time += 1
270 start_time = (start_time[0] + 1, start_time[1])
277 271 m['From'] = sender
278 272 m['To'] = ', '.join(to)
279 273 if cc: m['Cc'] = ', '.join(cc)
@@ -291,7 +285,8 b' def patchbomb(ui, repo, *revs, **opts):'
291 285 elif opts['mbox']:
292 286 ui.status('Writing ', m['Subject'], ' ...\n')
293 287 fp = open(opts['mbox'], m.has_key('In-Reply-To') and 'ab+' or 'wb+')
294 date = time.asctime(time.localtime(start_time))
288 date = util.datestr(date=start_time,
289 format='%a %b %d %H:%M:%S %Y', timezone=False)
295 290 fp.write('From %s %s\n' % (sender_addr, date))
296 291 fp.write(m.as_string(0))
297 292 fp.write('\n\n')
General Comments 0
You need to be logged in to leave comments. Login now