changeset 15559:1830d0cc4bc1

patchbomb: minor refactoring of mbox functionality, preparing for move This allows reuse of the mbox functionality but causes minor changes in the patchbomb console output when writing to a mbox.
author Mads Kiilerich <mads@kiilerich.com>
date Wed, 23 Nov 2011 02:09:38 +0100
parents c6b600d2348c
children cc58c228503e
files hgext/patchbomb.py tests/test-patchbomb.t
diffstat 2 files changed, 26 insertions(+), 27 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/patchbomb.py	Wed Nov 23 03:14:24 2011 +0100
+++ b/hgext/patchbomb.py	Wed Nov 23 02:09:38 2011 +0100
@@ -533,14 +533,13 @@
             if fp is not ui:
                 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+')
+            ui.status(_('Sending '), subj, ' ...\n')
+            ui.progress(_('sending'), i, item=subj, total=len(msgs))
+            fp = open(mbox, i > 0 and 'ab+' or 'wb+')
             generator = email.Generator.Generator(fp, mangle_from_=True)
             # Should be time.asctime(), but Windows prints 2-characters day
             # of month instead of one. Make them print the same thing.
-            date = time.strftime('%a %b %d %H:%M:%S %Y',
-                                 time.localtime(start_time[0]))
+            date = time.strftime('%a %b %d %H:%M:%S %Y', time.localtime())
             fp.write('From %s %s\n' % (sender_addr, date))
             generator.flatten(m, 0)
             fp.write('\n\n')
@@ -555,7 +554,7 @@
             fp = cStringIO.StringIO()
             generator = email.Generator.Generator(fp, mangle_from_=False)
             generator.flatten(m, 0)
-            sendmail(sender, to + bcc + cc, fp.getvalue())
+            sendmail(sender_addr, to + bcc + cc, fp.getvalue())
 
     ui.progress(_('writing'), None)
     ui.progress(_('sending'), None)
--- a/tests/test-patchbomb.t	Wed Nov 23 03:14:24 2011 +0100
+++ b/tests/test-patchbomb.t	Wed Nov 23 02:09:38 2011 +0100
@@ -161,20 +161,20 @@
   Write the introductory message for the patch series.
   
   
-  writing [                                             ] 0/3
-  writing [                                             ] 0/3
+  sending [                                             ] 0/3
+  sending [                                             ] 0/3
                                                               
                                                               
-  writing [==============>                              ] 1/3
-  writing [==============>                              ] 1/3
+  sending [==============>                              ] 1/3
+  sending [==============>                              ] 1/3
                                                               
                                                               
-  writing [=============================>               ] 2/3
-  writing [=============================>               ] 2/3
+  sending [=============================>               ] 2/3
+  sending [=============================>               ] 2/3
                                                               \r (esc)
-  Writing [PATCH 0 of 2] test ...
-  Writing [PATCH 1 of 2] a ...
-  Writing [PATCH 2 of 2] b ...
+  Sending [PATCH 0 of 2] test ...
+  Sending [PATCH 1 of 2] a ...
+  Sending [PATCH 2 of 2] b ...
   
 
   $ cd ..
@@ -279,14 +279,14 @@
   
 
 mime encoded mbox (base64):
-  $ hg email --date '1970-1-1 0:4' -f quux -t foo -c bar -r tip -m mbox
+  $ hg email --date '1970-1-1 0:4' -f 'Q <quux>' -t foo -c bar -r tip -m mbox
   This patch series consists of 1 patches.
   
   
-  Writing [PATCH] utf-8 content ...
+  Sending [PATCH] utf-8 content ...
 
   $ cat mbox
-  From quux Thu Jan 01 00:04:01 1970
+  From quux ... ... .. ..:..:.. .... (re)
   Content-Type: text/plain; charset="utf-8"
   MIME-Version: 1.0
   Content-Transfer-Encoding: base64
@@ -295,7 +295,7 @@
   Message-Id: <909a00e13e9d78b575ae.240@*> (glob)
   User-Agent: Mercurial-patchbomb/* (glob)
   Date: Thu, 01 Jan 1970 00:04:00 +0000
-  From: quux
+  From: Q <quux>
   To: foo
   Cc: bar
   
@@ -391,9 +391,9 @@
   This patch series consists of 1 patches.
   
   
-  Writing [PATCH] long line ...
+  Sending [PATCH] long line ...
   $ cat mbox
-  From quux Thu Jan 01 00:04:01 1970
+  From quux ... ... .. ..:..:.. .... (re)
   Content-Type: text/plain; charset="us-ascii"
   MIME-Version: 1.0
   Content-Transfer-Encoding: quoted-printable
@@ -449,9 +449,9 @@
   This patch series consists of 1 patches.
   
   
-  Writing [PATCH] isolatin 8-bit encoding ...
+  Sending [PATCH] isolatin 8-bit encoding ...
   $ cat mbox
-  From quux Thu Jan 01 00:05:01 1970
+  From quux ... ... .. ..:..:.. .... (re)
   Content-Type: text/plain; charset="us-ascii"
   MIME-Version: 1.0
   Content-Transfer-Encoding: 8bit
@@ -1944,9 +1944,9 @@
   This patch series consists of 1 patches.
   
   
-  Writing [PATCH] test ...
+  Sending [PATCH] test ...
   $ cat < tmp.mbox
-  From quux Tue Jan 01 00:01:01 1980
+  From quux ... ... .. ..:..:.. .... (re)
   Content-Type: text/plain; charset="us-ascii"
   MIME-Version: 1.0
   Content-Transfer-Encoding: 7bit
@@ -1984,10 +1984,10 @@
   
   Cc: 
   
-  Writing [PATCH] test ...
+  Sending [PATCH] test ...
 
   $ cat tmp.mbox
-  From quux Tue Jan 01 00:01:01 1980
+  From quux ... ... .. ..:..:.. .... (re)
   Content-Type: text/plain; charset="us-ascii"
   MIME-Version: 1.0
   Content-Transfer-Encoding: 7bit