# HG changeset patch # User Yuya Nishihara # Date 1284275441 -32400 # Node ID 1ed2dc9d4368ed9676e970d300dfb8d822ce1cab # Parent b8146231c3de5e0e2a5e59ceda76b148f4fc4f79 patchbomb: show progress when sending emails or writing mbox diff -r b8146231c3de -r 1ed2dc9d4368 hgext/patchbomb.py --- a/hgext/patchbomb.py Sat Sep 11 18:08:00 2010 +0200 +++ b/hgext/patchbomb.py Sun Sep 12 16:10:41 2010 +0900 @@ -438,7 +438,7 @@ sender_addr = email.Utils.parseaddr(sender)[1] sender = mail.addressencode(ui, sender, _charsets, opts.get('test')) sendmail = None - for m, subj, ds in msgs: + for i, (m, subj, ds) in enumerate(msgs): try: m['Message-Id'] = genmsgid(m['X-Mercurial-Node']) except TypeError: @@ -480,6 +480,7 @@ fp.close() elif mbox: ui.status(_('Writing '), subj, ' ...\n') + ui.progress(_('writing'), i, item=subj, total=len(msgs)) fp = open(mbox, 'In-Reply-To' in m and 'ab+' or 'wb+') generator = email.Generator.Generator(fp, mangle_from_=True) # Should be time.asctime(), but Windows prints 2-characters day @@ -494,6 +495,7 @@ if not sendmail: sendmail = mail.connect(ui) ui.status(_('Sending '), subj, ' ...\n') + ui.progress(_('sending'), i, item=subj, total=len(msgs)) # Exim does not remove the Bcc field del m['Bcc'] fp = cStringIO.StringIO() @@ -501,6 +503,9 @@ generator.flatten(m, 0) sendmail(sender, to + bcc + cc, fp.getvalue()) + ui.progress(_('writing'), None) + ui.progress(_('sending'), None) + emailopts = [ ('a', 'attach', None, _('send patches as attachments')), ('i', 'inline', None, _('send patches as inline attachments')),