[PATCH] Patchbomb: option --text allows to send patches as plain text

Benoit Boissinot bboissin at gmail.com
Sun Sep 21 12:10:17 CDT 2008


On Sat, Sep 20, 2008 at 1:03 PM, Simon Heimberg <simohe at besonet.ch> wrote:
> # HG changeset patch
> # User Simon Heimberg <simohe at besonet.ch>
> # Date 1221908363 -7200
> # Node ID c3a022ce4ecedee201e4d9d579b42970cc30dd5a
> # Parent  1a6213062a2d8e1f9c3df5b87f9e90d802928a73
> Patchbomb: option --text allows to send patches as plain text
>

The patch looks good. Some remarks below.

Why do you need this patch ? are there some clients who don't want
to show text/x-patch as text ?

We probably need a better help message,
saying that it only applies if you send with -a or -i, and that it is
the mimetype of the patch that is changed.

Maybe:
"send attachment as text/plain instead of text/x-patch"

regards,

Benoit

> diff -r 1a6213062a2d -r c3a022ce4ece hgext/patchbomb.py
> --- a/hgext/patchbomb.py        Tue Sep 09 19:45:46 2008 +0200
> +++ b/hgext/patchbomb.py        Sat Sep 20 12:59:23 2008 +0200
> @@ -177,18 +177,24 @@
>             msg = email.MIMEMultipart.MIMEMultipart()
>             if body:
>                 msg.attach(email.MIMEText.MIMEText(body, 'plain'))
> -            p = email.MIMEText.MIMEText('\n'.join(patch), 'x-patch')
> +            p = email.MIMEText.MIMEText('\n'.join(patch),
> +                opts.get('text') and 'plain' or 'x-patch')
>             binnode = bin(node)
>             # if node is mq patch, it will have patch file name as tag
>             patchname = [t for t in repo.nodetags(binnode)
>                          if t.endswith('.patch') or t.endswith('.diff')]
> +            ending = '.patch'
> +            if opts.get('text'):
> +                ending = '.txt'
>             if patchname:
>                 patchname = patchname[0]
> +                if opts.get('text'):
> +                    patchname[:patchname.rindex('.')] + ending

just use .patch.txt, ie:

            optext = opts.get() and '.txt' or ''
            if patchname:
                patchname = patchname[0] + optext
            elif total > 1:
                patchname = cmdutil.make_filename(repo, '%b-%n.patch' + optext,
                                                  binnode, idx, total)
            else:
                patchname = cmdutil.make_filename(repo, '%b.patch' + optext,
                                                  binnode)


More information about the Mercurial-devel mailing list