[PATCH 1 of 1] patchbomb: show progress when sending emails or writing mbox

Yuya Nishihara yuya at tcha.org
Sun Sep 12 02:19:51 CDT 2010


# HG changeset patch
# User Yuya Nishihara <yuya at tcha.org>
# Date 1284275441 -32400
# Node ID a334d22de21f251f331c812678bd4107b529e8a7
# Parent  bd98796c0b6f46efc2d88630f0ef5fa707feb0f5
patchbomb: show progress when sending emails or writing mbox

diff --git a/hgext/patchbomb.py b/hgext/patchbomb.py
--- a/hgext/patchbomb.py
+++ b/hgext/patchbomb.py
@@ -441,7 +441,7 @@ def patchbomb(ui, repo, *revs, **opts):
     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:
@@ -483,6 +483,7 @@ def patchbomb(ui, repo, *revs, **opts):
                 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
@@ -497,6 +498,7 @@ def patchbomb(ui, repo, *revs, **opts):
             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()
@@ -504,6 +506,9 @@ def patchbomb(ui, repo, *revs, **opts):
             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')),


More information about the Mercurial-devel mailing list