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