[PATCH 0 of 2 V2] patchbomb: add --body flag to send patches as inline message body text

0 views
Skip to first unread message

Angel Ezquerra

unread,
Mar 21, 2012, 6:21:36 PM3/21/12
to mercuri...@selenic.com
Compared to the previous version, this series adds a test to test-patchbomb and changes the name of the new email flag to --body (as per Greg Ward's suggestion).

This is the first time I write a test. Hopefully it will work fine!
_______________________________________________
Mercurial-devel mailing list
Mercuri...@selenic.com
http://selenic.com/mailman/listinfo/mercurial-devel

Angel Ezquerra

unread,
Mar 21, 2012, 6:21:38 PM3/21/12
to mercuri...@selenic.com
# HG changeset patch
# User Angel Ezquerra <angel.e...@gmail.com>
# Date 1332343051 -3600
# Node ID 5ad3315b8606612e0eaf1591c52818ca15a6ec57
# Parent 8425d77de31797911a3b69c86c7734ec25e501e1
tests: add test for patchbomb's email --inline option

The new test is based on the "test attach for single patch" test.

diff --git a/tests/test-patchbomb.t b/tests/test-patchbomb.t
--- a/tests/test-patchbomb.t
+++ b/tests/test-patchbomb.t
@@ -979,6 +979,62 @@

--===*-- (glob)

+test attach and body for single patch:
+ $ hg email --date '1970-1-1 0:1' -n -f quux -t foo -c bar -s test -a --body -r 2
+ This patch series consists of 1 patches.
+
+
+ Displaying [PATCH] test ...
+ Content-Type: multipart/mixed; boundary="===*" (glob)
+ MIME-Version: 1.0
+ Subject: [PATCH] test
+ X-Mercurial-Node: ff2c9fa2018b15fa74b33363bda9527323e2a99f
+ Message-Id: <ff2c9fa2018b15fa74b3.60@*> (glob)
+ User-Agent: Mercurial-patchbomb/* (glob)
+ Date: Thu, 01 Jan 1970 00:01:00 +0000
+ From: quux
+ To: foo
+ Cc: bar
+
+ --===* (glob)
+ Content-Type: text/plain; charset="us-ascii"
+ MIME-Version: 1.0
+ Content-Transfer-Encoding: 7bit
+
+ # HG changeset patch
+ # User test
+ # Date 3 0
+ # Node ID ff2c9fa2018b15fa74b33363bda9527323e2a99f
+ # Parent 97d72e5f12c7e84f85064aa72e5a297142c36ed9
+ c
+
+ diff -r 97d72e5f12c7 -r ff2c9fa2018b c
+ --- /dev/null Thu Jan 01 00:00:00 1970 +0000
+ +++ b/c Thu Jan 01 00:00:03 1970 +0000
+ @@ -0,0 +1,1 @@
+ +c
+
+ --===* (glob)
+ Content-Type: text/x-patch; charset="us-ascii"
+ MIME-Version: 1.0
+ Content-Transfer-Encoding: 7bit
+ Content-Disposition: attachment; filename=t2.patch
+
+ # HG changeset patch
+ # User test
+ # Date 3 0
+ # Node ID ff2c9fa2018b15fa74b33363bda9527323e2a99f
+ # Parent 97d72e5f12c7e84f85064aa72e5a297142c36ed9
+ c
+
+ diff -r 97d72e5f12c7 -r ff2c9fa2018b c
+ --- /dev/null Thu Jan 01 00:00:00 1970 +0000
+ +++ b/c Thu Jan 01 00:00:03 1970 +0000
+ @@ -0,0 +1,1 @@
+ +c
+
+ --===*-- (glob)
+
test attach for multiple patches:
$ hg email --date '1970-1-1 0:1' -n -f quux -t foo -c bar -s test -a \
> -r 0:1 -r 4

Angel Ezquerra Moreu

unread,
Mar 21, 2012, 6:24:12 PM3/21/12
to mercuri...@selenic.com
On Wed, Mar 21, 2012 at 11:21 PM, Angel Ezquerra
<angel.e...@gmail.com> wrote:
> # HG changeset patch
> # User Angel Ezquerra <angel.e...@gmail.com>
> # Date 1332343051 -3600
> # Node ID 5ad3315b8606612e0eaf1591c52818ca15a6ec57
> # Parent  8425d77de31797911a3b69c86c7734ec25e501e1
> tests: add test for patchbomb's email --inline option
>
> The new test is based on the "test attach for single patch" test.

Unfortunately I've not been able to actually run this test, even after
following the instructions on the HackableMercurial test. The
patchbomb test is skipped:

$ ./run-tests.py -l test-patchbomb.t
s
Skipped test-patchbomb.t: missing feature: system() uses sh
# Ran 0 tests, 1 skipped, 0 failed.

Angel

Angel Ezquerra

unread,
Mar 22, 2012, 1:36:40 AM3/22/12
to Angel Ezquerra, mercuri...@selenic.com
On Thu, Mar 22, 2012 at 2:59 AM, Greg Ward <gr...@gerg.ca> wrote:
> On 21 March 2012, Angel Ezquerra said:
>> # HG changeset patch
>> # User Angel Ezquerra <angel.e...@gmail.com>
>> # Date 1332308707 -3600
>> # Node ID 8425d77de31797911a3b69c86c7734ec25e501e1
>> # Parent  63a1bed65fa32262a45136a583fb6af117215241
>> patchbomb: add --body flag to send patches as inline message body text
>
> The test and code change should be together in the same patch.
>
>> There is currently no way to make patchbombo include patches both as attachments
>
> "patchbombo" typo still there.
>
> --
> Greg Ward                                http://www.gerg.ca/
> There's nothing to see here.  Move on; go about your business.

Thank you Greg. I'll send a new patch in a minute.

Angel

Angel Ezquerra

unread,
Mar 22, 2012, 1:41:47 AM3/22/12
to mercuri...@selenic.com
# HG changeset patch
# User Angel Ezquerra <angel.e...@gmail.com>
# Date 1332308707 -3600
# Node ID 54df21ce2c2cc39481697a42f06b5f873f1cc075

# Parent 63a1bed65fa32262a45136a583fb6af117215241
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.

diff --git a/hgext/patchbomb.py b/hgext/patchbomb.py
--- a/hgext/patchbomb.py
+++ b/hgext/patchbomb.py
@@ -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', False, _('include patches as inline text in the message body (the 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

Reply all
Reply to author
Forward
0 new messages