Mercurial > hg
annotate tests/test-notify.t @ 12607:1393a81b3bdc
merge with stable
author | Martin Geisler <mg@aragost.com> |
---|---|
date | Fri, 01 Oct 2010 16:43:03 +0200 |
parents | 52aac5c5c2a6 |
children | 6cc4b14fb76b |
rev | line source |
---|---|
3740
aef384dbc731
add test for the notify extension
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
1 |
12473 | 2 $ cat <<EOF >> $HGRCPATH |
3 > [extensions] | |
4 > notify= | |
5 > | |
6 > [hooks] | |
7 > incoming.notify = python:hgext.notify.hook | |
8 > | |
9 > [notify] | |
10 > sources = pull | |
11 > diffstat = False | |
12 > | |
13 > [usersubs] | |
14 > foo@bar = * | |
15 > | |
16 > [reposubs] | |
17 > * = baz | |
18 > EOF | |
19 $ hg help notify | |
20 notify extension - hooks for sending email notifications at commit/push time | |
21 | |
22 Subscriptions can be managed through a hgrc file. Default mode is to print | |
23 messages to stdout, for testing and configuring. | |
24 | |
25 To use, configure the notify extension and enable it in hgrc like this: | |
26 | |
27 [extensions] | |
28 notify = | |
29 | |
30 [hooks] | |
31 # one email for each incoming changeset | |
32 incoming.notify = python:hgext.notify.hook | |
33 # batch emails when many changesets incoming at one time | |
34 changegroup.notify = python:hgext.notify.hook | |
35 | |
36 [notify] | |
37 # config items go here | |
38 | |
39 Required configuration items: | |
40 | |
41 config = /path/to/file # file containing subscriptions | |
42 | |
43 Optional configuration items: | |
44 | |
45 test = True # print messages to stdout for testing | |
46 strip = 3 # number of slashes to strip for url paths | |
47 domain = example.com # domain to use if committer missing domain | |
48 style = ... # style file to use when formatting email | |
49 template = ... # template to use when formatting email | |
50 incoming = ... # template to use when run as incoming hook | |
51 changegroup = ... # template when run as changegroup hook | |
52 maxdiff = 300 # max lines of diffs to include (0=none, -1=all) | |
53 maxsubject = 67 # truncate subject line longer than this | |
54 diffstat = True # add a diffstat before the diff content | |
55 sources = serve # notify if source of incoming changes in this list | |
56 # (serve == ssh or http, push, pull, bundle) | |
57 merge = False # send notification for merges (default True) | |
58 [email] | |
59 from = user@host.com # email address to send as if none given | |
60 [web] | |
61 baseurl = http://hgserver/... # root of hg web site for browsing commits | |
62 | |
63 The notify config file has same format as a regular hgrc file. It has two | |
64 sections so you can express subscriptions in whatever way is handier for you. | |
65 | |
66 [usersubs] | |
67 # key is subscriber email, value is ","-separated list of glob patterns | |
68 user@host = pattern | |
69 | |
70 [reposubs] | |
71 # key is glob pattern, value is ","-separated list of subscriber emails | |
72 pattern = user@host | |
73 | |
74 Glob patterns are matched against path to repository root. | |
75 | |
76 If you like, you can put notify config file in repository that users can push | |
77 changes to, they can manage their own subscriptions. | |
78 | |
79 no commands defined | |
80 $ hg init a | |
81 $ echo a > a/a | |
3740
aef384dbc731
add test for the notify extension
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
82 |
12473 | 83 commit |
84 | |
85 $ hg --cwd a commit -Ama -d '0 0' | |
86 adding a | |
87 | |
88 | |
89 clone | |
90 | |
91 $ hg --traceback clone a b | |
92 updating to branch default | |
93 1 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
94 $ echo a >> a/a | |
95 | |
96 commit | |
97 | |
98 $ hg --traceback --cwd a commit -Amb -d '1 0' | |
99 | |
100 on Mac OS X 10.5 the tmp path is very long so would get stripped in the subject line | |
101 | |
102 $ cat <<EOF >> $HGRCPATH | |
103 > [notify] | |
104 > maxsubject = 200 | |
105 > EOF | |
106 | |
107 the python call below wraps continuation lines, which appear on Mac OS X 10.5 because | |
108 of the very long subject line | |
109 pull (minimal config) | |
6359
25e74cd3f023
test-notify: make it pass on Mac OS X 10.5
Florent Guillaume <fg@nuxeo.com>
parents:
4517
diff
changeset
|
110 |
12473 | 111 $ hg --traceback --cwd b pull ../a | \ |
112 > python -c 'import sys,re; print re.sub("\n\t", " ", sys.stdin.read()),' | |
113 pulling from ../a | |
114 searching for changes | |
115 adding changesets | |
116 adding manifests | |
117 adding file changes | |
118 added 1 changesets with 1 changes to 1 files | |
119 Content-Type: text/plain; charset="us-ascii" | |
120 MIME-Version: 1.0 | |
121 Content-Transfer-Encoding: 7bit | |
122 Date: * (glob) | |
123 Subject: changeset in */b: b (glob) | |
124 From: test | |
125 X-Hg-Notification: changeset 0647d048b600 | |
126 Message-Id: <*> (glob) | |
127 To: baz, foo@bar | |
128 | |
129 changeset 0647d048b600 in */b (glob) | |
130 details: *?cmd=changeset;node=0647d048b600 (glob) | |
131 description: b | |
132 | |
133 diffs (6 lines): | |
134 | |
135 diff -r cb9a9f314b8b -r 0647d048b600 a | |
136 --- a/a Thu Jan 01 00:00:00 1970 +0000 | |
137 +++ b/a Thu Jan 01 00:00:01 1970 +0000 | |
138 @@ -1,1 +1,2 @@ | |
139 a | |
140 +a | |
141 (run 'hg update' to get a working copy) | |
142 $ cat <<EOF >> $HGRCPATH | |
143 > [notify] | |
144 > config = $HGTMP/.notify.conf | |
145 > domain = test.com | |
146 > strip = 3 | |
147 > template = Subject: {desc|firstline|strip}\nFrom: {author}\nX-Test: foo\n\nchangeset {node|short} in {webroot}\ndescription:\n\t{desc|tabindent|strip} | |
148 > | |
149 > [web] | |
150 > baseurl = http://test/ | |
151 > EOF | |
4094
fbf0e9acfd83
notify: don't try to fix addresses if notify.domain is not set
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
4009
diff
changeset
|
152 |
12473 | 153 fail for config file is missing |
4094
fbf0e9acfd83
notify: don't try to fix addresses if notify.domain is not set
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
4009
diff
changeset
|
154 |
12473 | 155 $ hg --cwd b rollback |
156 rolling back to revision 0 (undo pull) | |
157 $ hg --cwd b pull ../a 2>&1 | grep 'error.*\.notify\.conf' > /dev/null && echo pull failed | |
158 pull failed | |
159 $ touch "$HGTMP/.notify.conf" | |
160 | |
161 pull | |
4094
fbf0e9acfd83
notify: don't try to fix addresses if notify.domain is not set
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
4009
diff
changeset
|
162 |
12473 | 163 $ hg --cwd b rollback |
164 rolling back to revision 0 (undo pull) | |
165 $ hg --traceback --cwd b pull ../a | \ | |
166 > python -c 'import sys,re; print re.sub("\n\t", " ", sys.stdin.read()),' | |
167 pulling from ../a | |
168 searching for changes | |
169 adding changesets | |
170 adding manifests | |
171 adding file changes | |
172 added 1 changesets with 1 changes to 1 files | |
173 Content-Type: text/plain; charset="us-ascii" | |
174 MIME-Version: 1.0 | |
175 Content-Transfer-Encoding: 7bit | |
176 X-Test: foo | |
177 Date: * (glob) | |
178 Subject: b | |
179 From: test@test.com | |
180 X-Hg-Notification: changeset 0647d048b600 | |
181 Message-Id: <*> (glob) | |
182 To: baz@test.com, foo@bar | |
183 | |
184 changeset 0647d048b600 in */b (glob) | |
185 description: b | |
186 diffs (6 lines): | |
187 | |
188 diff -r cb9a9f314b8b -r 0647d048b600 a | |
189 --- a/a Thu Jan 01 00:00:00 1970 +0000 | |
190 +++ b/a Thu Jan 01 00:00:01 1970 +0000 | |
191 @@ -1,1 +1,2 @@ | |
192 a | |
193 +a | |
194 (run 'hg update' to get a working copy) | |
4517
5371a213b0f4
ui: make readsections() abort when configuration cannot be read.
Patrick Mezard <pmezard@gmail.com>
parents:
4479
diff
changeset
|
195 |
12473 | 196 $ cat << EOF >> $HGRCPATH |
197 > [hooks] | |
198 > incoming.notify = python:hgext.notify.hook | |
199 > | |
200 > [notify] | |
201 > sources = pull | |
202 > diffstat = True | |
203 > EOF | |
204 | |
205 pull | |
4094
fbf0e9acfd83
notify: don't try to fix addresses if notify.domain is not set
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
4009
diff
changeset
|
206 |
12473 | 207 $ hg --cwd b rollback |
208 rolling back to revision 0 (undo pull) | |
209 $ hg --traceback --cwd b pull ../a | \ | |
210 > python -c 'import sys,re; print re.sub("\n\t", " ", sys.stdin.read()),' | |
211 pulling from ../a | |
212 searching for changes | |
213 adding changesets | |
214 adding manifests | |
215 adding file changes | |
216 added 1 changesets with 1 changes to 1 files | |
217 Content-Type: text/plain; charset="us-ascii" | |
218 MIME-Version: 1.0 | |
219 Content-Transfer-Encoding: 7bit | |
220 X-Test: foo | |
221 Date: * (glob) | |
222 Subject: b | |
223 From: test@test.com | |
224 X-Hg-Notification: changeset 0647d048b600 | |
225 Message-Id: <*> (glob) | |
226 To: baz@test.com, foo@bar | |
227 | |
228 changeset 0647d048b600 in */b (glob) | |
229 description: b | |
230 diffstat: | |
231 | |
232 a | 1 + | |
233 1 files changed, 1 insertions(+), 0 deletions(-) | |
234 | |
235 diffs (6 lines): | |
236 | |
237 diff -r cb9a9f314b8b -r 0647d048b600 a | |
238 --- a/a Thu Jan 01 00:00:00 1970 +0000 | |
239 +++ b/a Thu Jan 01 00:00:01 1970 +0000 | |
240 @@ -1,1 +1,2 @@ | |
241 a | |
242 +a | |
243 (run 'hg update' to get a working copy) | |
7105
31837416ef4d
tests: add some testing for patch.diffstat()
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6359
diff
changeset
|
244 |
12473 | 245 test merge |
7105
31837416ef4d
tests: add some testing for patch.diffstat()
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6359
diff
changeset
|
246 |
12473 | 247 $ cd a |
248 $ hg up -C 0 | |
249 1 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
250 $ echo a >> a | |
251 $ hg ci -Am adda2 -d '2 0' | |
252 created new head | |
253 $ hg merge | |
254 0 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
255 (branch merge, don't forget to commit) | |
256 $ hg ci -m merge -d '3 0' | |
257 $ cd .. | |
258 $ hg --traceback --cwd b pull ../a | \ | |
259 > python -c 'import sys,re; print re.sub("\n\t", " ", sys.stdin.read()),' | |
260 pulling from ../a | |
261 searching for changes | |
262 adding changesets | |
263 adding manifests | |
264 adding file changes | |
265 added 2 changesets with 0 changes to 0 files | |
266 Content-Type: text/plain; charset="us-ascii" | |
267 MIME-Version: 1.0 | |
268 Content-Transfer-Encoding: 7bit | |
269 X-Test: foo | |
270 Date: * (glob) | |
271 Subject: adda2 | |
272 From: test@test.com | |
273 X-Hg-Notification: changeset 0a184ce6067f | |
274 Message-Id: <*> (glob) | |
275 To: baz@test.com, foo@bar | |
276 | |
277 changeset 0a184ce6067f in */b (glob) | |
278 description: adda2 | |
279 diffstat: | |
280 | |
281 a | 1 + | |
282 1 files changed, 1 insertions(+), 0 deletions(-) | |
283 | |
284 diffs (6 lines): | |
285 | |
286 diff -r cb9a9f314b8b -r 0a184ce6067f a | |
287 --- a/a Thu Jan 01 00:00:00 1970 +0000 | |
288 +++ b/a Thu Jan 01 00:00:02 1970 +0000 | |
289 @@ -1,1 +1,2 @@ | |
290 a | |
291 +a | |
292 Content-Type: text/plain; charset="us-ascii" | |
293 MIME-Version: 1.0 | |
294 Content-Transfer-Encoding: 7bit | |
295 X-Test: foo | |
296 Date: * (glob) | |
297 Subject: merge | |
298 From: test@test.com | |
299 X-Hg-Notification: changeset 22c88b85aa27 | |
300 Message-Id: <*> (glob) | |
301 To: baz@test.com, foo@bar | |
302 | |
303 changeset 22c88b85aa27 in */b (glob) | |
304 description: merge | |
305 (run 'hg update' to get a working copy) |