[PATCH] patchbomb: Allow editing the email before sending
David Soria Parra
sn_ at gmx.net
Sun Aug 9 07:52:59 CDT 2009
Another resend of a patch send 2 weeks ago.
# HG changeset patch
# User David Soria Parra <dsp at php.net>
# Date 1249822367 -7200
# Node ID e65afc442aa31261ae823fe81ca481fcbb029873
# Parent 81397535e5cba9f07fa97889c9388bfe2cbd1490
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
@@ -442,24 +442,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')),
@@ -471,6 +480,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