patchbomb: use progress helper
authorMartin von Zweigbergk <martinvonz@google.com>
Mon, 18 Jun 2018 14:34:07 -0700
changeset 38409 8ce3f91d5f6f
parent 38408 457fa4056286
child 38410 398716063c2d
patchbomb: use progress helper Differential Revision: https://phab.mercurial-scm.org/D3804
hgext/patchbomb.py
--- a/hgext/patchbomb.py	Mon Jun 18 14:32:12 2018 -0700
+++ b/hgext/patchbomb.py	Mon Jun 18 14:34:07 2018 -0700
@@ -751,6 +751,7 @@
     sender = mail.addressencode(ui, sender, _charsets, opts.get('test'))
     sendmail = None
     firstpatch = None
+    progress = ui.makeprogress(_('sending'), unit=_('emails'), total=len(msgs))
     for i, (m, subj, ds) in enumerate(msgs):
         try:
             m['Message-Id'] = genmsgid(m['X-Mercurial-Node'])
@@ -791,8 +792,7 @@
             if not sendmail:
                 sendmail = mail.connect(ui, mbox=mbox)
             ui.status(_('sending '), subj, ' ...\n')
-            ui.progress(_('sending'), i, item=subj, total=len(msgs),
-                        unit=_('emails'))
+            progress.update(i, item=subj)
             if not mbox:
                 # Exim does not remove the Bcc field
                 del m['Bcc']
@@ -801,4 +801,4 @@
             generator.flatten(m, 0)
             sendmail(sender_addr, to + bcc + cc, fp.getvalue())
 
-    ui.progress(_('sending'), None)
+    progress.complete()