hgext/patchbomb.py
changeset 38409 8ce3f91d5f6f
parent 38408 457fa4056286
child 38475 91228d9ae7c8
equal deleted inserted replaced
38408:457fa4056286 38409:8ce3f91d5f6f
   749 
   749 
   750     sender_addr = eutil.parseaddr(encoding.strfromlocal(sender))[1]
   750     sender_addr = eutil.parseaddr(encoding.strfromlocal(sender))[1]
   751     sender = mail.addressencode(ui, sender, _charsets, opts.get('test'))
   751     sender = mail.addressencode(ui, sender, _charsets, opts.get('test'))
   752     sendmail = None
   752     sendmail = None
   753     firstpatch = None
   753     firstpatch = None
       
   754     progress = ui.makeprogress(_('sending'), unit=_('emails'), total=len(msgs))
   754     for i, (m, subj, ds) in enumerate(msgs):
   755     for i, (m, subj, ds) in enumerate(msgs):
   755         try:
   756         try:
   756             m['Message-Id'] = genmsgid(m['X-Mercurial-Node'])
   757             m['Message-Id'] = genmsgid(m['X-Mercurial-Node'])
   757             if not firstpatch:
   758             if not firstpatch:
   758                 firstpatch = m['Message-Id']
   759                 firstpatch = m['Message-Id']
   789                     raise
   790                     raise
   790         else:
   791         else:
   791             if not sendmail:
   792             if not sendmail:
   792                 sendmail = mail.connect(ui, mbox=mbox)
   793                 sendmail = mail.connect(ui, mbox=mbox)
   793             ui.status(_('sending '), subj, ' ...\n')
   794             ui.status(_('sending '), subj, ' ...\n')
   794             ui.progress(_('sending'), i, item=subj, total=len(msgs),
   795             progress.update(i, item=subj)
   795                         unit=_('emails'))
       
   796             if not mbox:
   796             if not mbox:
   797                 # Exim does not remove the Bcc field
   797                 # Exim does not remove the Bcc field
   798                 del m['Bcc']
   798                 del m['Bcc']
   799             fp = stringio()
   799             fp = stringio()
   800             generator = emailgen.Generator(fp, mangle_from_=False)
   800             generator = emailgen.Generator(fp, mangle_from_=False)
   801             generator.flatten(m, 0)
   801             generator.flatten(m, 0)
   802             sendmail(sender_addr, to + bcc + cc, fp.getvalue())
   802             sendmail(sender_addr, to + bcc + cc, fp.getvalue())
   803 
   803 
   804     ui.progress(_('sending'), None)
   804     progress.complete()