changeset 12265:1ed2dc9d4368

patchbomb: show progress when sending emails or writing mbox
author Yuya Nishihara <yuya@tcha.org>
date Sun, 12 Sep 2010 16:10:41 +0900
parents b8146231c3de
children 00658492e2aa
files hgext/patchbomb.py
diffstat 1 files changed, 6 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- 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')),