Mercurial > hg-stable
diff hgext/patchbomb.py @ 16307:17a9a1f5cee2
patchbomb: add --body flag to send patches as inline message body text
There is currently no way to make patchbomb include patches both as attachments
and as inline text. This would be quite convenient when sending patches to
people who use web email clients (e.g. gmail) which often mangle the patches,
making them hard to apply.
The default behavior of the email command is unchanged. However it is now
possible to use the --body flag _in addition_ to the -i or -a flags, in which
case the patchbomb emails will contain the patch as inline body text and as an
attachment.
A new test has been added to test-patchbomb.t ("test attach for single
patch"), based on the existing test called "test attach for single patch" test.
author | Angel Ezquerra <angel.ezquerra@gmail.com> |
---|---|
date | Wed, 21 Mar 2012 06:45:07 +0100 |
parents | 3f79b110c4f0 |
children | 525fdb738975 |
line wrap: on
line diff
--- a/hgext/patchbomb.py Wed Mar 28 15:25:20 2012 -0400 +++ b/hgext/patchbomb.py Wed Mar 21 06:45:07 2012 +0100 @@ -84,7 +84,7 @@ if not patchname and not node: raise ValueError - if opts.get('attach'): + if opts.get('attach') and not opts.get('body'): body = ('\n'.join(desc[1:]).strip() or 'Patch subject is complete summary.') body += '\n\n\n' @@ -101,7 +101,11 @@ if opts.get('diffstat'): body += ds + '\n\n' - if opts.get('attach') or opts.get('inline'): + addattachment = opts.get('attach') or opts.get('inline') + if not addattachment or opts.get('body'): + body += '\n'.join(patchlines) + + if addattachment: msg = email.MIMEMultipart.MIMEMultipart() if body: msg.attach(mail.mimeencode(ui, body, _charsets, opts.get('test'))) @@ -124,7 +128,6 @@ p['Content-Disposition'] = disposition + '; filename=' + patchname msg.attach(p) else: - body += '\n'.join(patchlines) msg = mail.mimetextpatch(body, display=opts.get('test')) flag = ' '.join(opts.get('flag')) @@ -142,6 +145,7 @@ return msg, subj, ds emailopts = [ + ('', 'body', None, _('send patches as inline message text (default)')), ('a', 'attach', None, _('send patches as attachments')), ('i', 'inline', None, _('send patches as inline attachments')), ('', 'bcc', [], _('email addresses of blind carbon copy recipients')), @@ -199,7 +203,9 @@ By default the patch is included as text in the email body for easy reviewing. Using the -a/--attach option will instead create an attachment for the patch. With -i/--inline an inline attachment - will be created. + will be created. You can include a patch both as text in the email + body and as a regular or an inline attachment by combining the + -a/--attach or -i/--inline with the --body option. With -o/--outgoing, emails will be generated for patches not found in the destination repository (or only those which are ancestors