8 '''command to send changesets as (a series of) patch emails |
8 '''command to send changesets as (a series of) patch emails |
9 |
9 |
10 The series is started off with a "[PATCH 0 of N]" introduction, which |
10 The series is started off with a "[PATCH 0 of N]" introduction, which |
11 describes the series as a whole. |
11 describes the series as a whole. |
12 |
12 |
13 Each patch email has a Subject line of "[PATCH M of N] ...", using the first |
13 Each patch email has a Subject line of "[PATCH M of N] ...", using the |
14 line of the changeset description as the subject text. The message contains |
14 first line of the changeset description as the subject text. The |
15 two or three body parts: |
15 message contains two or three body parts: |
16 |
16 |
17 The changeset description. |
17 The changeset description. |
18 |
18 |
19 [Optional] The result of running diffstat on the patch. |
19 [Optional] The result of running diffstat on the patch. |
20 |
20 |
21 The patch itself, as generated by "hg export". |
21 The patch itself, as generated by "hg export". |
22 |
22 |
23 Each message refers to the first in the series using the In-Reply-To and |
23 Each message refers to the first in the series using the In-Reply-To |
24 References headers, so they will show up as a sequence in threaded mail and |
24 and References headers, so they will show up as a sequence in threaded |
25 news readers, and in mail archives. |
25 mail and news readers, and in mail archives. |
26 |
26 |
27 With the -d/--diffstat option, you will be prompted for each changeset with a |
27 With the -d/--diffstat option, you will be prompted for each changeset |
28 diffstat summary and the changeset summary, so you can be sure you are sending |
28 with a diffstat summary and the changeset summary, so you can be sure |
29 the right changes. |
29 you are sending the right changes. |
30 |
30 |
31 To configure other defaults, add a section like this to your hgrc file:: |
31 To configure other defaults, add a section like this to your hgrc |
|
32 file:: |
32 |
33 |
33 [email] |
34 [email] |
34 from = My Name <my@email> |
35 from = My Name <my@email> |
35 to = recipient1, recipient2, ... |
36 to = recipient1, recipient2, ... |
36 cc = cc1, cc2, ... |
37 cc = cc1, cc2, ... |
37 bcc = bcc1, bcc2, ... |
38 bcc = bcc1, bcc2, ... |
38 |
39 |
39 Then you can use the "hg email" command to mail a series of changesets as a |
40 Then you can use the "hg email" command to mail a series of changesets |
40 patchbomb. |
41 as a patchbomb. |
41 |
42 |
42 To avoid sending patches prematurely, it is a good idea to first run the |
43 To avoid sending patches prematurely, it is a good idea to first run |
43 "email" command with the "-n" option (test only). You will be prompted for an |
44 the "email" command with the "-n" option (test only). You will be |
44 email recipient address, a subject and an introductory message describing the |
45 prompted for an email recipient address, a subject and an introductory |
45 patches of your patchbomb. Then when all is done, patchbomb messages are |
46 message describing the patches of your patchbomb. Then when all is |
46 displayed. If the PAGER environment variable is set, your pager will be fired |
47 done, patchbomb messages are displayed. If the PAGER environment |
47 up once for each patchbomb message, so you can verify everything is alright. |
48 variable is set, your pager will be fired up once for each patchbomb |
48 |
49 message, so you can verify everything is alright. |
49 The -m/--mbox option is also very useful. Instead of previewing each patchbomb |
50 |
50 message in a pager or sending the messages directly, it will create a UNIX |
51 The -m/--mbox option is also very useful. Instead of previewing each |
51 mailbox file with the patch emails. This mailbox file can be previewed with |
52 patchbomb message in a pager or sending the messages directly, it will |
52 any mail user agent which supports UNIX mbox files, e.g. with mutt:: |
53 create a UNIX mailbox file with the patch emails. This mailbox file |
|
54 can be previewed with any mail user agent which supports UNIX mbox |
|
55 files, e.g. with mutt:: |
53 |
56 |
54 % mutt -R -f mbox |
57 % mutt -R -f mbox |
55 |
58 |
56 When you are previewing the patchbomb messages, you can use `formail' (a |
59 When you are previewing the patchbomb messages, you can use `formail' |
57 utility that is commonly installed as part of the procmail package), to send |
60 (a utility that is commonly installed as part of the procmail |
58 each message out:: |
61 package), to send each message out:: |
59 |
62 |
60 % formail -s sendmail -bm -t < mbox |
63 % formail -s sendmail -bm -t < mbox |
61 |
64 |
62 That should be all. Now your patchbomb is on its way out. |
65 That should be all. Now your patchbomb is on its way out. |
63 |
66 |
64 You can also either configure the method option in the email section to be a |
67 You can also either configure the method option in the email section |
65 sendmail compatible mailer or fill out the [smtp] section so that the |
68 to be a sendmail compatible mailer or fill out the [smtp] section so |
66 patchbomb extension can automatically send patchbombs directly from the |
69 that the patchbomb extension can automatically send patchbombs |
67 commandline. See the [email] and [smtp] sections in hgrc(5) for details. |
70 directly from the commandline. See the [email] and [smtp] sections in |
|
71 hgrc(5) for details. |
68 ''' |
72 ''' |
69 |
73 |
70 import os, errno, socket, tempfile, cStringIO, time |
74 import os, errno, socket, tempfile, cStringIO, time |
71 import email.MIMEMultipart, email.MIMEBase |
75 import email.MIMEMultipart, email.MIMEBase |
72 import email.Utils, email.Encoders, email.Generator |
76 import email.Utils, email.Encoders, email.Generator |
171 return msg, subj |
175 return msg, subj |
172 |
176 |
173 def patchbomb(ui, repo, *revs, **opts): |
177 def patchbomb(ui, repo, *revs, **opts): |
174 '''send changesets by email |
178 '''send changesets by email |
175 |
179 |
176 By default, diffs are sent in the format generated by hg export, one per |
180 By default, diffs are sent in the format generated by hg export, |
177 message. The series starts with a "[PATCH 0 of N]" introduction, which |
181 one per message. The series starts with a "[PATCH 0 of N]" |
178 describes the series as a whole. |
182 introduction, which describes the series as a whole. |
179 |
183 |
180 Each patch email has a Subject line of "[PATCH M of N] ...", using the |
184 Each patch email has a Subject line of "[PATCH M of N] ...", using |
181 first line of the changeset description as the subject text. The message |
185 the first line of the changeset description as the subject text. |
182 contains two or three parts. First, the changeset description. Next, |
186 The message contains two or three parts. First, the changeset |
183 (optionally) if the diffstat program is installed and -d/--diffstat is |
187 description. Next, (optionally) if the diffstat program is |
184 used, the result of running diffstat on the patch. Finally, the patch |
188 installed and -d/--diffstat is used, the result of running |
185 itself, as generated by "hg export". |
189 diffstat on the patch. Finally, the patch itself, as generated by |
186 |
190 "hg export". |
187 By default the patch is included as text in the email body for easy |
191 |
188 reviewing. Using the -a/--attach option will instead create an attachment |
192 By default the patch is included as text in the email body for |
189 for the patch. With -i/--inline an inline attachment will be created. |
193 easy reviewing. Using the -a/--attach option will instead create |
190 |
194 an attachment for the patch. With -i/--inline an inline attachment |
191 With -o/--outgoing, emails will be generated for patches not found in the |
195 will be created. |
192 destination repository (or only those which are ancestors of the specified |
196 |
193 revisions if any are provided) |
197 With -o/--outgoing, emails will be generated for patches not found |
194 |
198 in the destination repository (or only those which are ancestors |
195 With -b/--bundle, changesets are selected as for --outgoing, but a single |
199 of the specified revisions if any are provided) |
196 email containing a binary Mercurial bundle as an attachment will be sent. |
200 |
|
201 With -b/--bundle, changesets are selected as for --outgoing, but a |
|
202 single email containing a binary Mercurial bundle as an attachment |
|
203 will be sent. |
197 |
204 |
198 Examples: |
205 Examples: |
199 |
206 |
200 hg email -r 3000 # send patch 3000 only |
207 hg email -r 3000 # send patch 3000 only |
201 hg email -r 3000 -r 3001 # send patches 3000 and 3001 |
208 hg email -r 3000 -r 3001 # send patches 3000 and 3001 |