[PATCH] patchbomb: Allow editing the email before sending

Christian Ebert blacktrash at gmx.net
Sun Aug 9 13:12:50 UTC 2009


* David Soria Parra on Sunday, August 09, 2009 at 14:52:59 +0200
> 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)

Hm. The charset might change, e.g. from ascii to utf-8; at a
first glance it seems to me the body/attachments must be passed
through mail.mimetextpatch (and for multipart mail.mimeencode)
again. I'll test when I find time.

And if someone starts to edit From: or recipients ...

c
-- 
\black\trash movie    _C O W B O Y_  _C A N O E_  _C O M A_
                     Ein deutscher Western/A German Western

         --->> http://www.blacktrash.org/underdogma/ccc.php



More information about the Mercurial-devel mailing list