##// END OF EJS Templates
patchbomb: add --body flag to send patches as inline message body text...
Angel Ezquerra -
r16307:17a9a1f5 default
parent child Browse files
Show More
@@ -84,7 +84,7 b' def makepatch(ui, repo, patchlines, opts'
84 if not patchname and not node:
84 if not patchname and not node:
85 raise ValueError
85 raise ValueError
86
86
87 if opts.get('attach'):
87 if opts.get('attach') and not opts.get('body'):
88 body = ('\n'.join(desc[1:]).strip() or
88 body = ('\n'.join(desc[1:]).strip() or
89 'Patch subject is complete summary.')
89 'Patch subject is complete summary.')
90 body += '\n\n\n'
90 body += '\n\n\n'
@@ -101,7 +101,11 b' def makepatch(ui, repo, patchlines, opts'
101 if opts.get('diffstat'):
101 if opts.get('diffstat'):
102 body += ds + '\n\n'
102 body += ds + '\n\n'
103
103
104 if opts.get('attach') or opts.get('inline'):
104 addattachment = opts.get('attach') or opts.get('inline')
105 if not addattachment or opts.get('body'):
106 body += '\n'.join(patchlines)
107
108 if addattachment:
105 msg = email.MIMEMultipart.MIMEMultipart()
109 msg = email.MIMEMultipart.MIMEMultipart()
106 if body:
110 if body:
107 msg.attach(mail.mimeencode(ui, body, _charsets, opts.get('test')))
111 msg.attach(mail.mimeencode(ui, body, _charsets, opts.get('test')))
@@ -124,7 +128,6 b' def makepatch(ui, repo, patchlines, opts'
124 p['Content-Disposition'] = disposition + '; filename=' + patchname
128 p['Content-Disposition'] = disposition + '; filename=' + patchname
125 msg.attach(p)
129 msg.attach(p)
126 else:
130 else:
127 body += '\n'.join(patchlines)
128 msg = mail.mimetextpatch(body, display=opts.get('test'))
131 msg = mail.mimetextpatch(body, display=opts.get('test'))
129
132
130 flag = ' '.join(opts.get('flag'))
133 flag = ' '.join(opts.get('flag'))
@@ -142,6 +145,7 b' def makepatch(ui, repo, patchlines, opts'
142 return msg, subj, ds
145 return msg, subj, ds
143
146
144 emailopts = [
147 emailopts = [
148 ('', 'body', None, _('send patches as inline message text (default)')),
145 ('a', 'attach', None, _('send patches as attachments')),
149 ('a', 'attach', None, _('send patches as attachments')),
146 ('i', 'inline', None, _('send patches as inline attachments')),
150 ('i', 'inline', None, _('send patches as inline attachments')),
147 ('', 'bcc', [], _('email addresses of blind carbon copy recipients')),
151 ('', 'bcc', [], _('email addresses of blind carbon copy recipients')),
@@ -199,7 +203,9 b' def patchbomb(ui, repo, *revs, **opts):'
199 By default the patch is included as text in the email body for
203 By default the patch is included as text in the email body for
200 easy reviewing. Using the -a/--attach option will instead create
204 easy reviewing. Using the -a/--attach option will instead create
201 an attachment for the patch. With -i/--inline an inline attachment
205 an attachment for the patch. With -i/--inline an inline attachment
202 will be created.
206 will be created. You can include a patch both as text in the email
207 body and as a regular or an inline attachment by combining the
208 -a/--attach or -i/--inline with the --body option.
203
209
204 With -o/--outgoing, emails will be generated for patches not found
210 With -o/--outgoing, emails will be generated for patches not found
205 in the destination repository (or only those which are ancestors
211 in the destination repository (or only those which are ancestors
@@ -979,6 +979,62 b' test attach for single patch (quoted-pri'
979
979
980 --===*-- (glob)
980 --===*-- (glob)
981
981
982 test attach and body for single patch:
983 $ hg email --date '1970-1-1 0:1' -n -f quux -t foo -c bar -s test -a --body -r 2
984 This patch series consists of 1 patches.
985
986
987 Displaying [PATCH] test ...
988 Content-Type: multipart/mixed; boundary="===*" (glob)
989 MIME-Version: 1.0
990 Subject: [PATCH] test
991 X-Mercurial-Node: ff2c9fa2018b15fa74b33363bda9527323e2a99f
992 Message-Id: <ff2c9fa2018b15fa74b3.60@*> (glob)
993 User-Agent: Mercurial-patchbomb/* (glob)
994 Date: Thu, 01 Jan 1970 00:01:00 +0000
995 From: quux
996 To: foo
997 Cc: bar
998
999 --===* (glob)
1000 Content-Type: text/plain; charset="us-ascii"
1001 MIME-Version: 1.0
1002 Content-Transfer-Encoding: 7bit
1003
1004 # HG changeset patch
1005 # User test
1006 # Date 3 0
1007 # Node ID ff2c9fa2018b15fa74b33363bda9527323e2a99f
1008 # Parent 97d72e5f12c7e84f85064aa72e5a297142c36ed9
1009 c
1010
1011 diff -r 97d72e5f12c7 -r ff2c9fa2018b c
1012 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1013 +++ b/c Thu Jan 01 00:00:03 1970 +0000
1014 @@ -0,0 +1,1 @@
1015 +c
1016
1017 --===* (glob)
1018 Content-Type: text/x-patch; charset="us-ascii"
1019 MIME-Version: 1.0
1020 Content-Transfer-Encoding: 7bit
1021 Content-Disposition: attachment; filename=t2.patch
1022
1023 # HG changeset patch
1024 # User test
1025 # Date 3 0
1026 # Node ID ff2c9fa2018b15fa74b33363bda9527323e2a99f
1027 # Parent 97d72e5f12c7e84f85064aa72e5a297142c36ed9
1028 c
1029
1030 diff -r 97d72e5f12c7 -r ff2c9fa2018b c
1031 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1032 +++ b/c Thu Jan 01 00:00:03 1970 +0000
1033 @@ -0,0 +1,1 @@
1034 +c
1035
1036 --===*-- (glob)
1037
982 test attach for multiple patches:
1038 test attach for multiple patches:
983 $ hg email --date '1970-1-1 0:1' -n -f quux -t foo -c bar -s test -a \
1039 $ hg email --date '1970-1-1 0:1' -n -f quux -t foo -c bar -s test -a \
984 > -r 0:1 -r 4
1040 > -r 0:1 -r 4
General Comments 0
You need to be logged in to leave comments. Login now