[PATCH] patchbomb: Allow editing the email before sending
David Soria Parra
sn_ at gmx.net
Wed Jul 29 01:10:00 CDT 2009
# HG changeset patch
# User David Soria Parra <dsp at php.net>
# Date 1248847750 -7200
# Node ID f6869c95f8089e09aa4dd20007b1e950c46dd1e0
# Parent da7b64fb7ab6507703b591e1feb156d6a327ae8e
patchbomb: Allow editing the email before sending
Add --edit flag to patchbomb which allows to edit every
message befor it's send. This can be used to add comment to the mail.
diff --git a/hgext/patchbomb.py b/hgext/patchbomb.py
--- a/hgext/patchbomb.py
+++ b/hgext/patchbomb.py
@@ -444,24 +444,33 @@
if fp is not ui:
fp.close()
elif opts.get('mbox'):
+ sp = cStringIO.StringIO()
+ generator = email.Generator.Generator(sp, mangle_from_=True)
+ generator.flatten(m, 0)
+ mailmsg = sp.getvalue()
+ if opts.get('edit'):
+ mailmsg = ui.edit(mailmsg, sender)
+
ui.status(_('Writing '), subj, ' ...\n')
fp = open(opts.get('mbox'), 'In-Reply-To' in m and 'ab+' or 'wb+')
- generator = email.Generator.Generator(fp, mangle_from_=True)
date = time.ctime(start_time[0])
fp.write('From %s %s\n' % (sender_addr, date))
- generator.flatten(m, 0)
+ fp.write(mailmsg)
fp.write('\n\n')
fp.close()
else:
+ del m['Bcc']
+ fp = cStringIO.StringIO()
+ generator = email.Generator.Generator(fp, mangle_from_=False)
+ generator.flatten(m, 0)
+ mailmsg = fp.getvalue()
+ if opts.get('edit'):
+ mailmsg = ui.edit(mailmsg, sender)
if not sendmail:
sendmail = mail.connect(ui)
ui.status(_('Sending '), subj, ' ...\n')
# Exim does not remove the Bcc field
- del m['Bcc']
- fp = cStringIO.StringIO()
- generator = email.Generator.Generator(fp, mangle_from_=False)
- generator.flatten(m, 0)
- sendmail(sender, to + bcc + cc, fp.getvalue())
+ sendmail(sender, to + bcc + cc, mailmsg)
emailopts = [
('a', 'attach', None, _('send patches as attachments')),
@@ -473,6 +482,7 @@
('', 'desc', '', _('use the given file as the series description')),
('f', 'from', '', _('email address of sender')),
('n', 'test', None, _('print messages that would be sent')),
+ ('', 'edit', None, _('edit messages before sending')),
('m', 'mbox', '',
_('write messages to mbox file instead of sending them')),
('s', 'subject', '',
More information about the Mercurial-devel
mailing list