hgext/patchbomb.py
changeset 12265 1ed2dc9d4368
parent 12264 b8146231c3de
child 12749 338b4b615d33
equal deleted inserted replaced
12264:b8146231c3de 12265:1ed2dc9d4368
   436     first = True
   436     first = True
   437 
   437 
   438     sender_addr = email.Utils.parseaddr(sender)[1]
   438     sender_addr = email.Utils.parseaddr(sender)[1]
   439     sender = mail.addressencode(ui, sender, _charsets, opts.get('test'))
   439     sender = mail.addressencode(ui, sender, _charsets, opts.get('test'))
   440     sendmail = None
   440     sendmail = None
   441     for m, subj, ds in msgs:
   441     for i, (m, subj, ds) in enumerate(msgs):
   442         try:
   442         try:
   443             m['Message-Id'] = genmsgid(m['X-Mercurial-Node'])
   443             m['Message-Id'] = genmsgid(m['X-Mercurial-Node'])
   444         except TypeError:
   444         except TypeError:
   445             m['Message-Id'] = genmsgid('patchbomb')
   445             m['Message-Id'] = genmsgid('patchbomb')
   446         if parent:
   446         if parent:
   478                     raise
   478                     raise
   479             if fp is not ui:
   479             if fp is not ui:
   480                 fp.close()
   480                 fp.close()
   481         elif mbox:
   481         elif mbox:
   482             ui.status(_('Writing '), subj, ' ...\n')
   482             ui.status(_('Writing '), subj, ' ...\n')
       
   483             ui.progress(_('writing'), i, item=subj, total=len(msgs))
   483             fp = open(mbox, 'In-Reply-To' in m and 'ab+' or 'wb+')
   484             fp = open(mbox, 'In-Reply-To' in m and 'ab+' or 'wb+')
   484             generator = email.Generator.Generator(fp, mangle_from_=True)
   485             generator = email.Generator.Generator(fp, mangle_from_=True)
   485             # Should be time.asctime(), but Windows prints 2-characters day
   486             # Should be time.asctime(), but Windows prints 2-characters day
   486             # of month instead of one. Make them print the same thing.
   487             # of month instead of one. Make them print the same thing.
   487             date = time.strftime('%a %b %d %H:%M:%S %Y',
   488             date = time.strftime('%a %b %d %H:%M:%S %Y',
   492             fp.close()
   493             fp.close()
   493         else:
   494         else:
   494             if not sendmail:
   495             if not sendmail:
   495                 sendmail = mail.connect(ui)
   496                 sendmail = mail.connect(ui)
   496             ui.status(_('Sending '), subj, ' ...\n')
   497             ui.status(_('Sending '), subj, ' ...\n')
       
   498             ui.progress(_('sending'), i, item=subj, total=len(msgs))
   497             # Exim does not remove the Bcc field
   499             # Exim does not remove the Bcc field
   498             del m['Bcc']
   500             del m['Bcc']
   499             fp = cStringIO.StringIO()
   501             fp = cStringIO.StringIO()
   500             generator = email.Generator.Generator(fp, mangle_from_=False)
   502             generator = email.Generator.Generator(fp, mangle_from_=False)
   501             generator.flatten(m, 0)
   503             generator.flatten(m, 0)
   502             sendmail(sender, to + bcc + cc, fp.getvalue())
   504             sendmail(sender, to + bcc + cc, fp.getvalue())
       
   505 
       
   506     ui.progress(_('writing'), None)
       
   507     ui.progress(_('sending'), None)
   503 
   508 
   504 emailopts = [
   509 emailopts = [
   505           ('a', 'attach', None, _('send patches as attachments')),
   510           ('a', 'attach', None, _('send patches as attachments')),
   506           ('i', 'inline', None, _('send patches as inline attachments')),
   511           ('i', 'inline', None, _('send patches as inline attachments')),
   507           ('', 'bcc', [], _('email addresses of blind carbon copy recipients')),
   512           ('', 'bcc', [], _('email addresses of blind carbon copy recipients')),