1 # Command for sending a collection of Mercurial changesets as a series |
1 '''sending Mercurial changesets as a series of patch emails |
2 # of patch emails. |
2 |
3 # |
3 The series is started off with a "[PATCH 0 of N]" introduction, |
4 # The series is started off with a "[PATCH 0 of N]" introduction, |
4 which describes the series as a whole. |
5 # which describes the series as a whole. |
5 |
6 # |
6 Each patch email has a Subject line of "[PATCH M of N] ...", using |
7 # Each patch email has a Subject line of "[PATCH M of N] ...", using |
7 the first line of the changeset description as the subject text. |
8 # the first line of the changeset description as the subject text. |
8 The message contains two or three body parts: |
9 # The message contains two or three body parts: |
9 |
10 # |
10 The remainder of the changeset description. |
11 # The remainder of the changeset description. |
11 |
12 # |
12 [Optional] If the diffstat program is installed, the result of |
13 # [Optional] If the diffstat program is installed, the result of |
13 running diffstat on the patch. |
14 # running diffstat on the patch. |
14 |
15 # |
15 The patch itself, as generated by "hg export". |
16 # The patch itself, as generated by "hg export". |
16 |
17 # |
17 Each message refers to all of its predecessors using the In-Reply-To |
18 # Each message refers to all of its predecessors using the In-Reply-To |
18 and References headers, so they will show up as a sequence in |
19 # and References headers, so they will show up as a sequence in |
19 threaded mail and news readers, and in mail archives. |
20 # threaded mail and news readers, and in mail archives. |
20 |
21 # |
21 For each changeset, you will be prompted with a diffstat summary and |
22 # For each changeset, you will be prompted with a diffstat summary and |
22 the changeset summary, so you can be sure you are sending the right changes. |
23 # the changeset summary, so you can be sure you are sending the right |
23 |
24 # changes. |
24 To enable this extension: |
25 # |
25 |
26 # To enable this extension: |
26 [extensions] |
27 # |
27 hgext.patchbomb = |
28 # [extensions] |
28 |
29 # hgext.patchbomb = |
29 To configure other defaults, add a section like this to your hgrc file: |
30 # |
30 |
31 # To configure other defaults, add a section like this to your hgrc |
31 [email] |
32 # file: |
32 from = My Name <my@email> |
33 # |
33 to = recipient1, recipient2, ... |
34 # [email] |
34 cc = cc1, cc2, ... |
35 # from = My Name <my@email> |
35 bcc = bcc1, bcc2, ... |
36 # to = recipient1, recipient2, ... |
36 |
37 # cc = cc1, cc2, ... |
37 Then you can use the "hg email" command to mail a series of changesets |
38 # bcc = bcc1, bcc2, ... |
38 as a patchbomb. |
39 # |
39 |
40 # Then you can use the "hg email" command to mail a series of changesets |
40 To avoid sending patches prematurely, it is a good idea to first run |
41 # as a patchbomb. |
41 the "email" command with the "-n" option (test only). You will be |
42 # |
42 prompted for an email recipient address, a subject an an introductory |
43 # To avoid sending patches prematurely, it is a good idea to first run |
43 message describing the patches of your patchbomb. Then when all is |
44 # the "email" command with the "-n" option (test only). You will be |
44 done, patchbomb messages are displayed. If PAGER environment variable |
45 # prompted for an email recipient address, a subject an an introductory |
45 is set, your pager will be fired up once for each patchbomb message, so |
46 # message describing the patches of your patchbomb. Then when all is |
46 you can verify everything is alright. |
47 # done, patchbomb messages are displayed. If PAGER environment variable |
47 |
48 # is set, your pager will be fired up once for each patchbomb message, so |
48 The "-m" (mbox) option is also very useful. Instead of previewing |
49 # you can verify everything is alright. |
49 each patchbomb message in a pager or sending the messages directly, |
50 # |
50 it will create a UNIX mailbox file with the patch emails. This |
51 # The "-m" (mbox) option is also very useful. Instead of previewing |
51 mailbox file can be previewed with any mail user agent which supports |
52 # each patchbomb message in a pager or sending the messages directly, |
52 UNIX mbox files, i.e. with mutt: |
53 # it will create a UNIX mailbox file with the patch emails. This |
53 |
54 # mailbox file can be previewed with any mail user agent which supports |
54 % mutt -R -f mbox |
55 # UNIX mbox files, i.e. with mutt: |
55 |
56 # |
56 When you are previewing the patchbomb messages, you can use `formail' |
57 # % mutt -R -f mbox |
57 (a utility that is commonly installed as part of the procmail package), |
58 # |
58 to send each message out: |
59 # When you are previewing the patchbomb messages, you can use `formail' |
59 |
60 # (a utility that is commonly installed as part of the procmail package), |
60 % formail -s sendmail -bm -t < mbox |
61 # to send each message out: |
61 |
62 # |
62 That should be all. Now your patchbomb is on its way out.''' |
63 # % formail -s sendmail -bm -t < mbox |
|
64 # |
|
65 # That should be all. Now your patchbomb is on its way out. |
|
66 |
63 |
67 import os, errno, socket, tempfile, cStringIO |
64 import os, errno, socket, tempfile, cStringIO |
68 import email.MIMEMultipart, email.MIMEText, email.MIMEBase |
65 import email.MIMEMultipart, email.MIMEText, email.MIMEBase |
69 import email.Utils, email.Encoders, email.Generator |
66 import email.Utils, email.Encoders, email.Generator |
70 from mercurial import cmdutil, commands, hg, mail, patch, util |
67 from mercurial import cmdutil, commands, hg, mail, patch, util |