Mercurial > hg
comparison hgext/notify.py @ 9325:74e717a21779
Merge with mpm
author | Bryan O'Sullivan <bos@serpentine.com> |
---|---|
date | Thu, 06 Aug 2009 18:48:00 -0700 |
parents | 8736b1c853ff 9261667e9b82 |
children | 9a69ab6d7cf7 |
comparison
equal
deleted
inserted
replaced
9315:fb66a7d3f28f | 9325:74e717a21779 |
---|---|
5 # This software may be used and distributed according to the terms of the | 5 # This software may be used and distributed according to the terms of the |
6 # GNU General Public License version 2, incorporated herein by reference. | 6 # GNU General Public License version 2, incorporated herein by reference. |
7 | 7 |
8 '''hooks for sending email notifications at commit/push time | 8 '''hooks for sending email notifications at commit/push time |
9 | 9 |
10 Subscriptions can be managed through hgrc. Default mode is to print | 10 Subscriptions can be managed through a hgrc file. Default mode is to print |
11 messages to stdout, for testing and configuring. | 11 messages to stdout, for testing and configuring. |
12 | 12 |
13 To use, configure notify extension and enable in hgrc like this: | 13 To use, configure the notify extension and enable it in hgrc like this:: |
14 | 14 |
15 [extensions] | 15 [extensions] |
16 hgext.notify = | 16 hgext.notify = |
17 | 17 |
18 [hooks] | 18 [hooks] |
19 # one email for each incoming changeset | 19 # one email for each incoming changeset |
20 incoming.notify = python:hgext.notify.hook | 20 incoming.notify = python:hgext.notify.hook |
21 # batch emails when many changesets incoming at one time | 21 # batch emails when many changesets incoming at one time |
22 changegroup.notify = python:hgext.notify.hook | 22 changegroup.notify = python:hgext.notify.hook |
23 | 23 |
24 [notify] | 24 [notify] |
25 # config items go in here | 25 # config items go here |
26 | 26 |
27 config items: | 27 Required configuration items:: |
28 | 28 |
29 REQUIRED: | 29 config = /path/to/file # file containing subscriptions |
30 config = /path/to/file # file containing subscriptions | 30 |
31 | 31 Optional configuration items:: |
32 OPTIONAL: | 32 |
33 test = True # print messages to stdout for testing | 33 test = True # print messages to stdout for testing |
34 strip = 3 # number of slashes to strip for url paths | 34 strip = 3 # number of slashes to strip for url paths |
35 domain = example.com # domain to use if committer missing domain | 35 domain = example.com # domain to use if committer missing domain |
36 style = ... # style file to use when formatting email | 36 style = ... # style file to use when formatting email |
37 template = ... # template to use when formatting email | 37 template = ... # template to use when formatting email |
38 incoming = ... # template to use when run as incoming hook | 38 incoming = ... # template to use when run as incoming hook |
39 changegroup = ... # template when run as changegroup hook | 39 changegroup = ... # template when run as changegroup hook |
40 maxdiff = 300 # max lines of diffs to include (0=none, -1=all) | 40 maxdiff = 300 # max lines of diffs to include (0=none, -1=all) |
41 maxsubject = 67 # truncate subject line longer than this | 41 maxsubject = 67 # truncate subject line longer than this |
42 diffstat = True # add a diffstat before the diff content | 42 diffstat = True # add a diffstat before the diff content |
43 sources = serve # notify if source of incoming changes in this list | 43 sources = serve # notify if source of incoming changes in this list |
44 # (serve == ssh or http, push, pull, bundle) | 44 # (serve == ssh or http, push, pull, bundle) |
45 [email] | 45 [email] |
46 from = user@host.com # email address to send as if none given | 46 from = user@host.com # email address to send as if none given |
47 [web] | 47 [web] |
48 baseurl = http://hgserver/... # root of hg web site for browsing commits | 48 baseurl = http://hgserver/... # root of hg web site for browsing commits |
49 | 49 |
50 notify config file has same format as regular hgrc. it has two | 50 The notify config file has same format as a regular hgrc file. It has two |
51 sections so you can express subscriptions in whatever way is handier | 51 sections so you can express subscriptions in whatever way is handier for you. |
52 for you. | 52 |
53 | 53 :: |
54 [usersubs] | 54 |
55 # key is subscriber email, value is ","-separated list of glob patterns | 55 [usersubs] |
56 user@host = pattern | 56 # key is subscriber email, value is ","-separated list of glob patterns |
57 | 57 user@host = pattern |
58 [reposubs] | 58 |
59 # key is glob pattern, value is ","-separated list of subscriber emails | 59 [reposubs] |
60 pattern = user@host | 60 # key is glob pattern, value is ","-separated list of subscriber emails |
61 | 61 pattern = user@host |
62 glob patterns are matched against path to repository root. | 62 |
63 | 63 Glob patterns are matched against path to repository root. |
64 if you like, you can put notify config file in repository that users | 64 |
65 can push changes to, they can manage their own subscriptions.''' | 65 If you like, you can put notify config file in repository that users can push |
66 changes to, they can manage their own subscriptions. | |
67 ''' | |
66 | 68 |
67 from mercurial.i18n import _ | 69 from mercurial.i18n import _ |
68 from mercurial import patch, cmdutil, templater, util, mail | 70 from mercurial import patch, cmdutil, templater, util, mail |
69 import email.Parser, email.Errors, fnmatch, socket, time | 71 import email.Parser, email.Errors, fnmatch, socket, time |
70 | 72 |
224 msg['Message-Id'] = ('<hg.%s.%s.%s@%s>' % | 226 msg['Message-Id'] = ('<hg.%s.%s.%s@%s>' % |
225 (ctx, int(time.time()), | 227 (ctx, int(time.time()), |
226 hash(self.repo.root), socket.getfqdn())) | 228 hash(self.repo.root), socket.getfqdn())) |
227 msg['To'] = ', '.join(self.subs) | 229 msg['To'] = ', '.join(self.subs) |
228 | 230 |
229 msgtext = msg.as_string(0) | 231 msgtext = msg.as_string() |
230 if self.test: | 232 if self.test: |
231 self.ui.write(msgtext) | 233 self.ui.write(msgtext) |
232 if not msgtext.endswith('\n'): | 234 if not msgtext.endswith('\n'): |
233 self.ui.write('\n') | 235 self.ui.write('\n') |
234 else: | 236 else: |