Show More
@@ -1,481 +1,488 | |||
|
1 | 1 | setup |
|
2 | 2 | |
|
3 | 3 | $ cat > myextension.py <<EOF |
|
4 | 4 | > from mercurial import error, registrar |
|
5 | 5 | > cmdtable = {} |
|
6 | 6 | > command = registrar.command(cmdtable) |
|
7 | 7 | > @command(b'crash', [], b'hg crash') |
|
8 | 8 | > def crash(ui, *args, **kwargs): |
|
9 | 9 | > raise Exception("oops") |
|
10 | 10 | > @command(b'abortcmd', [], b'hg abortcmd') |
|
11 | 11 | > def abort(ui, *args, **kwargs): |
|
12 | 12 | > raise error.Abort(b"oops") |
|
13 | 13 | > EOF |
|
14 | 14 | $ abspath=`pwd`/myextension.py |
|
15 | 15 | |
|
16 | 16 | $ cat >> $HGRCPATH <<EOF |
|
17 | 17 | > [extensions] |
|
18 | 18 | > blackbox= |
|
19 | 19 | > mock=$TESTDIR/mockblackbox.py |
|
20 | 20 | > mq= |
|
21 | 21 | > myextension=$TESTTMP/myextension.py |
|
22 | 22 | > [alias] |
|
23 | 23 | > confuse = log --limit 3 |
|
24 | 24 | > so-confusing = confuse --style compact |
|
25 | 25 | > EOF |
|
26 | 26 | |
|
27 | 27 | $ hg init blackboxtest |
|
28 | 28 | $ cd blackboxtest |
|
29 | 29 | |
|
30 | 30 | command, exit codes, and duration |
|
31 | 31 | |
|
32 | 32 | $ echo a > a |
|
33 | 33 | $ hg add a |
|
34 | 34 | $ hg blackbox --config blackbox.dirty=True |
|
35 | 35 | 1970/01/01 00:00:00 bob @0000000000000000000000000000000000000000 (5000)> init blackboxtest exited 0 after * seconds (glob) |
|
36 | 36 | 1970/01/01 00:00:00 bob @0000000000000000000000000000000000000000 (5000)> add a |
|
37 | 37 | 1970/01/01 00:00:00 bob @0000000000000000000000000000000000000000 (5000)> add a exited 0 after * seconds (glob) |
|
38 | 38 | 1970/01/01 00:00:00 bob @0000000000000000000000000000000000000000+ (5000)> blackbox --config *blackbox.dirty=True* (glob) |
|
39 | 39 | |
|
40 | 40 | failure exit code |
|
41 | 41 | $ rm ./.hg/blackbox.log |
|
42 | 42 | $ hg add non-existent |
|
43 | 43 | non-existent: $ENOENT$ |
|
44 | 44 | [1] |
|
45 | 45 | $ hg blackbox |
|
46 | 46 | 1970/01/01 00:00:00 bob @0000000000000000000000000000000000000000 (5000)> add non-existent |
|
47 | 47 | 1970/01/01 00:00:00 bob @0000000000000000000000000000000000000000 (5000)> add non-existent exited 1 after * seconds (glob) |
|
48 | 48 | 1970/01/01 00:00:00 bob @0000000000000000000000000000000000000000 (5000)> blackbox |
|
49 | 49 | |
|
50 | 50 | abort exit code |
|
51 | 51 | $ rm ./.hg/blackbox.log |
|
52 | 52 | $ hg abortcmd 2> /dev/null |
|
53 | 53 | [255] |
|
54 | 54 | $ hg blackbox -l 2 |
|
55 | 55 | 1970/01/01 00:00:00 bob @0000000000000000000000000000000000000000 (5000)> abortcmd exited 255 after * seconds (glob) |
|
56 | 56 | 1970/01/01 00:00:00 bob @0000000000000000000000000000000000000000 (5000)> blackbox -l 2 |
|
57 | 57 | |
|
58 | 58 | unhandled exception |
|
59 | 59 | $ rm ./.hg/blackbox.log |
|
60 | $ hg crash 2> /dev/null | |
|
60 | #if chg | |
|
61 | (chg exits 255 because it fails to receive an exit code) | |
|
62 | $ hg crash 2>/dev/null | |
|
63 | [255] | |
|
64 | #else | |
|
65 | (hg exits 1 because Python default exit code for uncaught exception is 1) | |
|
66 | $ hg crash 2>/dev/null | |
|
61 | 67 | [1] |
|
68 | #endif | |
|
62 | 69 |
$ |
|
63 | 70 | 1970/01/01 00:00:00 bob @0000000000000000000000000000000000000000 (5000)> crash exited 1 after * seconds (glob) |
|
64 | 71 | 1970/01/01 00:00:00 bob @0000000000000000000000000000000000000000 (5000)> blackbox -l 2 |
|
65 | 72 | |
|
66 | 73 | alias expansion is logged |
|
67 | 74 | $ rm ./.hg/blackbox.log |
|
68 | 75 | $ hg confuse |
|
69 | 76 | $ hg blackbox |
|
70 | 77 | 1970/01/01 00:00:00 bob @0000000000000000000000000000000000000000 (5000)> confuse |
|
71 | 78 | 1970/01/01 00:00:00 bob @0000000000000000000000000000000000000000 (5000)> alias 'confuse' expands to 'log --limit 3' |
|
72 | 79 | 1970/01/01 00:00:00 bob @0000000000000000000000000000000000000000 (5000)> confuse exited 0 after * seconds (glob) |
|
73 | 80 | 1970/01/01 00:00:00 bob @0000000000000000000000000000000000000000 (5000)> blackbox |
|
74 | 81 | |
|
75 | 82 | recursive aliases work correctly |
|
76 | 83 | $ rm ./.hg/blackbox.log |
|
77 | 84 | $ hg so-confusing |
|
78 | 85 | $ hg blackbox |
|
79 | 86 | 1970/01/01 00:00:00 bob @0000000000000000000000000000000000000000 (5000)> so-confusing |
|
80 | 87 | 1970/01/01 00:00:00 bob @0000000000000000000000000000000000000000 (5000)> alias 'so-confusing' expands to 'confuse --style compact' |
|
81 | 88 | 1970/01/01 00:00:00 bob @0000000000000000000000000000000000000000 (5000)> alias 'confuse' expands to 'log --limit 3' |
|
82 | 89 | 1970/01/01 00:00:00 bob @0000000000000000000000000000000000000000 (5000)> so-confusing exited 0 after * seconds (glob) |
|
83 | 90 | 1970/01/01 00:00:00 bob @0000000000000000000000000000000000000000 (5000)> blackbox |
|
84 | 91 | |
|
85 | 92 | custom date format |
|
86 | 93 | $ rm ./.hg/blackbox.log |
|
87 | 94 | $ hg --config blackbox.date-format='%Y-%m-%d @ %H:%M:%S' \ |
|
88 | 95 | > --config devel.default-date='1334347993 0' --traceback status |
|
89 | 96 | A a |
|
90 | 97 | $ hg blackbox |
|
91 | 98 | 2012-04-13 @ 20:13:13 bob @0000000000000000000000000000000000000000 (5000)> --config *blackbox.date-format=%Y-%m-%d @ %H:%M:%S* --config *devel.default-date=1334347993 0* --traceback status (glob) |
|
92 | 99 | 2012-04-13 @ 20:13:13 bob @0000000000000000000000000000000000000000 (5000)> --config *blackbox.date-format=%Y-%m-%d @ %H:%M:%S* --config *devel.default-date=1334347993 0* --traceback status exited 0 after * seconds (glob) |
|
93 | 100 | 1970/01/01 00:00:00 bob @0000000000000000000000000000000000000000 (5000)> blackbox |
|
94 | 101 | |
|
95 | 102 | incoming change tracking |
|
96 | 103 | |
|
97 | 104 | create two heads to verify that we only see one change in the log later |
|
98 | 105 | $ hg commit -ma |
|
99 | 106 | $ hg up null |
|
100 | 107 | 0 files updated, 0 files merged, 1 files removed, 0 files unresolved |
|
101 | 108 | $ echo b > b |
|
102 | 109 | $ hg commit -Amb |
|
103 | 110 | adding b |
|
104 | 111 | created new head |
|
105 | 112 | |
|
106 | 113 | clone, commit, pull |
|
107 | 114 | $ hg clone . ../blackboxtest2 |
|
108 | 115 | updating to branch default |
|
109 | 116 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
110 | 117 | $ echo c > c |
|
111 | 118 | $ hg commit -Amc |
|
112 | 119 | adding c |
|
113 | 120 | $ cd ../blackboxtest2 |
|
114 | 121 | $ hg pull |
|
115 | 122 | pulling from $TESTTMP/blackboxtest |
|
116 | 123 | searching for changes |
|
117 | 124 | adding changesets |
|
118 | 125 | adding manifests |
|
119 | 126 | adding file changes |
|
120 | 127 | added 1 changesets with 1 changes to 1 files |
|
121 | 128 | new changesets d02f48003e62 |
|
122 | 129 | (run 'hg update' to get a working copy) |
|
123 | 130 | $ hg blackbox -l 6 |
|
124 | 131 | 1970/01/01 00:00:00 bob @6563da9dcf87b1949716e38ff3e3dfaa3198eb06 (5000)> pull |
|
125 | 132 | 1970/01/01 00:00:00 bob @6563da9dcf87b1949716e38ff3e3dfaa3198eb06 (5000)> updated branch cache (served) in * seconds (glob) |
|
126 | 133 | 1970/01/01 00:00:00 bob @6563da9dcf87b1949716e38ff3e3dfaa3198eb06 (5000)> wrote branch cache (served) with 1 labels and 2 nodes |
|
127 | 134 | 1970/01/01 00:00:00 bob @6563da9dcf87b1949716e38ff3e3dfaa3198eb06 (5000)> 1 incoming changes - new heads: d02f48003e62 |
|
128 | 135 | 1970/01/01 00:00:00 bob @6563da9dcf87b1949716e38ff3e3dfaa3198eb06 (5000)> pull exited 0 after * seconds (glob) |
|
129 | 136 | 1970/01/01 00:00:00 bob @6563da9dcf87b1949716e38ff3e3dfaa3198eb06 (5000)> blackbox -l 6 |
|
130 | 137 | |
|
131 | 138 | we must not cause a failure if we cannot write to the log |
|
132 | 139 | |
|
133 | 140 | $ hg rollback |
|
134 | 141 | repository tip rolled back to revision 1 (undo pull) |
|
135 | 142 | |
|
136 | 143 | $ mv .hg/blackbox.log .hg/blackbox.log- |
|
137 | 144 | $ mkdir .hg/blackbox.log |
|
138 | 145 | $ hg --debug incoming |
|
139 | 146 | warning: cannot write to blackbox.log: * (glob) |
|
140 | 147 | comparing with $TESTTMP/blackboxtest |
|
141 | 148 | query 1; heads |
|
142 | 149 | searching for changes |
|
143 | 150 | all local changesets known remotely |
|
144 | 151 | changeset: 2:d02f48003e62c24e2659d97d30f2a83abe5d5d51 |
|
145 | 152 | tag: tip |
|
146 | 153 | phase: draft |
|
147 | 154 | parent: 1:6563da9dcf87b1949716e38ff3e3dfaa3198eb06 |
|
148 | 155 | parent: -1:0000000000000000000000000000000000000000 |
|
149 | 156 | manifest: 2:ab9d46b053ebf45b7996f2922b9893ff4b63d892 |
|
150 | 157 | user: test |
|
151 | 158 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
152 | 159 | files+: c |
|
153 | 160 | extra: branch=default |
|
154 | 161 | description: |
|
155 | 162 | c |
|
156 | 163 | |
|
157 | 164 | |
|
158 | 165 | $ hg pull |
|
159 | 166 | pulling from $TESTTMP/blackboxtest |
|
160 | 167 | searching for changes |
|
161 | 168 | adding changesets |
|
162 | 169 | adding manifests |
|
163 | 170 | adding file changes |
|
164 | 171 | added 1 changesets with 1 changes to 1 files |
|
165 | 172 | new changesets d02f48003e62 |
|
166 | 173 | (run 'hg update' to get a working copy) |
|
167 | 174 | |
|
168 | 175 | a failure reading from the log is fatal |
|
169 | 176 | |
|
170 | 177 | $ hg blackbox -l 3 |
|
171 | 178 | abort: *$TESTTMP/blackboxtest2/.hg/blackbox.log* (glob) |
|
172 | 179 | [255] |
|
173 | 180 | |
|
174 | 181 | $ rmdir .hg/blackbox.log |
|
175 | 182 | $ mv .hg/blackbox.log- .hg/blackbox.log |
|
176 | 183 | |
|
177 | 184 | backup bundles get logged |
|
178 | 185 | |
|
179 | 186 | $ touch d |
|
180 | 187 | $ hg commit -Amd |
|
181 | 188 | adding d |
|
182 | 189 | created new head |
|
183 | 190 | $ hg strip tip |
|
184 | 191 | 0 files updated, 0 files merged, 1 files removed, 0 files unresolved |
|
185 | 192 | saved backup bundle to $TESTTMP/blackboxtest2/.hg/strip-backup/*-backup.hg (glob) |
|
186 | 193 | $ hg blackbox -l 6 |
|
187 | 194 | 1970/01/01 00:00:00 bob @73f6ee326b27d820b0472f1a825e3a50f3dc489b (5000)> strip tip |
|
188 | 195 | 1970/01/01 00:00:00 bob @6563da9dcf87b1949716e38ff3e3dfaa3198eb06 (5000)> saved backup bundle to $TESTTMP/blackboxtest2/.hg/strip-backup/73f6ee326b27-7612e004-backup.hg |
|
189 | 196 | 1970/01/01 00:00:00 bob @6563da9dcf87b1949716e38ff3e3dfaa3198eb06 (5000)> updated branch cache (base) in * seconds (glob) |
|
190 | 197 | 1970/01/01 00:00:00 bob @6563da9dcf87b1949716e38ff3e3dfaa3198eb06 (5000)> wrote branch cache (base) with 1 labels and 2 nodes |
|
191 | 198 | 1970/01/01 00:00:00 bob @6563da9dcf87b1949716e38ff3e3dfaa3198eb06 (5000)> strip tip exited 0 after * seconds (glob) |
|
192 | 199 | 1970/01/01 00:00:00 bob @6563da9dcf87b1949716e38ff3e3dfaa3198eb06 (5000)> blackbox -l 6 |
|
193 | 200 | |
|
194 | 201 | extension and python hooks - use the eol extension for a pythonhook |
|
195 | 202 | |
|
196 | 203 | $ echo '[extensions]' >> .hg/hgrc |
|
197 | 204 | $ echo 'eol=' >> .hg/hgrc |
|
198 | 205 | $ echo '[hooks]' >> .hg/hgrc |
|
199 | 206 | $ echo 'update = echo hooked' >> .hg/hgrc |
|
200 | 207 | $ hg update |
|
201 | 208 | The fsmonitor extension is incompatible with the eol extension and has been disabled. (fsmonitor !) |
|
202 | 209 | hooked |
|
203 | 210 | 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
204 | 211 | updated to "d02f48003e62: c" |
|
205 | 212 | 1 other heads for branch "default" |
|
206 | 213 | $ cat >> .hg/hgrc <<EOF |
|
207 | 214 | > [extensions] |
|
208 | 215 | > # disable eol, because it is not needed for subsequent tests |
|
209 | 216 | > # (in addition, keeping it requires extra care for fsmonitor) |
|
210 | 217 | > eol=! |
|
211 | 218 | > EOF |
|
212 | 219 | $ hg blackbox -l 5 |
|
213 | 220 | 1970/01/01 00:00:00 bob @6563da9dcf87b1949716e38ff3e3dfaa3198eb06 (5000)> update (no-chg !) |
|
214 | 221 | 1970/01/01 00:00:00 bob @6563da9dcf87b1949716e38ff3e3dfaa3198eb06 (5000)> pythonhook-preupdate: hgext.eol.preupdate finished in * seconds (glob) |
|
215 | 222 | 1970/01/01 00:00:00 bob @d02f48003e62c24e2659d97d30f2a83abe5d5d51 (5000)> exthook-update: echo hooked finished in * seconds (glob) |
|
216 | 223 | 1970/01/01 00:00:00 bob @d02f48003e62c24e2659d97d30f2a83abe5d5d51 (5000)> update exited 0 after * seconds (glob) |
|
217 | 224 | 1970/01/01 00:00:00 bob @d02f48003e62c24e2659d97d30f2a83abe5d5d51 (5000)> serve --cmdserver chgunix --address $TESTTMP.chgsock/server.* --daemon-postexec 'chdir:/' (glob) (chg !) |
|
218 | 225 | 1970/01/01 00:00:00 bob @d02f48003e62c24e2659d97d30f2a83abe5d5d51 (5000)> blackbox -l 5 |
|
219 | 226 | |
|
220 | 227 | log rotation |
|
221 | 228 | |
|
222 | 229 | $ echo '[blackbox]' >> .hg/hgrc |
|
223 | 230 | $ echo 'maxsize = 20 b' >> .hg/hgrc |
|
224 | 231 | $ echo 'maxfiles = 3' >> .hg/hgrc |
|
225 | 232 | $ hg status |
|
226 | 233 | $ hg status |
|
227 | 234 | $ hg status |
|
228 | 235 | $ hg tip -q |
|
229 | 236 | 2:d02f48003e62 |
|
230 | 237 | $ ls .hg/blackbox.log* |
|
231 | 238 | .hg/blackbox.log |
|
232 | 239 | .hg/blackbox.log.1 |
|
233 | 240 | .hg/blackbox.log.2 |
|
234 | 241 | $ cd .. |
|
235 | 242 | |
|
236 | 243 | $ hg init blackboxtest3 |
|
237 | 244 | $ cd blackboxtest3 |
|
238 | 245 | $ hg blackbox |
|
239 | 246 | 1970/01/01 00:00:00 bob @0000000000000000000000000000000000000000 (5000)> init blackboxtest3 exited 0 after * seconds (glob) |
|
240 | 247 | 1970/01/01 00:00:00 bob @0000000000000000000000000000000000000000 (5000)> blackbox |
|
241 | 248 | $ mv .hg/blackbox.log .hg/blackbox.log- |
|
242 | 249 | $ mkdir .hg/blackbox.log |
|
243 | 250 | $ sed -e 's/\(.*test1.*\)/#\1/; s#\(.*commit2.*\)#os.rmdir(".hg/blackbox.log")\ |
|
244 | 251 | > os.rename(".hg/blackbox.log-", ".hg/blackbox.log")\ |
|
245 | 252 | > \1#' $TESTDIR/test-dispatch.py > ../test-dispatch.py |
|
246 | 253 | $ "$PYTHON" $TESTDIR/blackbox-readonly-dispatch.py |
|
247 | 254 | running: --debug add foo |
|
248 | 255 | warning: cannot write to blackbox.log: Is a directory (no-windows !) |
|
249 | 256 | warning: cannot write to blackbox.log: $TESTTMP/blackboxtest3/.hg/blackbox.log: Access is denied (windows !) |
|
250 | 257 | adding foo |
|
251 | 258 | result: 0 |
|
252 | 259 | running: --debug commit -m commit1 -d 2000-01-01 foo |
|
253 | 260 | warning: cannot write to blackbox.log: Is a directory (no-windows !) |
|
254 | 261 | warning: cannot write to blackbox.log: $TESTTMP/blackboxtest3/.hg/blackbox.log: Access is denied (windows !) |
|
255 | 262 | committing files: |
|
256 | 263 | foo |
|
257 | 264 | committing manifest |
|
258 | 265 | committing changelog |
|
259 | 266 | updating the branch cache |
|
260 | 267 | committed changeset 0:0e46349438790c460c5c9f7546bfcd39b267bbd2 |
|
261 | 268 | result: 0 |
|
262 | 269 | running: --debug commit -m commit2 -d 2000-01-02 foo |
|
263 | 270 | committing files: |
|
264 | 271 | foo |
|
265 | 272 | committing manifest |
|
266 | 273 | committing changelog |
|
267 | 274 | updating the branch cache |
|
268 | 275 | committed changeset 1:45589e459b2edfbf3dbde7e01f611d2c1e7453d7 |
|
269 | 276 | result: 0 |
|
270 | 277 | running: --debug log -r 0 |
|
271 | 278 | changeset: 0:0e46349438790c460c5c9f7546bfcd39b267bbd2 |
|
272 | 279 | phase: draft |
|
273 | 280 | parent: -1:0000000000000000000000000000000000000000 |
|
274 | 281 | parent: -1:0000000000000000000000000000000000000000 |
|
275 | 282 | manifest: 0:9091aa5df980aea60860a2e39c95182e68d1ddec |
|
276 | 283 | user: test |
|
277 | 284 | date: Sat Jan 01 00:00:00 2000 +0000 |
|
278 | 285 | files+: foo |
|
279 | 286 | extra: branch=default |
|
280 | 287 | description: |
|
281 | 288 | commit1 |
|
282 | 289 | |
|
283 | 290 | |
|
284 | 291 | result: 0 |
|
285 | 292 | running: --debug log -r tip |
|
286 | 293 | changeset: 1:45589e459b2edfbf3dbde7e01f611d2c1e7453d7 |
|
287 | 294 | tag: tip |
|
288 | 295 | phase: draft |
|
289 | 296 | parent: 0:0e46349438790c460c5c9f7546bfcd39b267bbd2 |
|
290 | 297 | parent: -1:0000000000000000000000000000000000000000 |
|
291 | 298 | manifest: 1:895aa9b7886f89dd017a6d62524e1f9180b04df9 |
|
292 | 299 | user: test |
|
293 | 300 | date: Sun Jan 02 00:00:00 2000 +0000 |
|
294 | 301 | files: foo |
|
295 | 302 | extra: branch=default |
|
296 | 303 | description: |
|
297 | 304 | commit2 |
|
298 | 305 | |
|
299 | 306 | |
|
300 | 307 | result: 0 |
|
301 | 308 | $ hg blackbox |
|
302 | 309 | 1970/01/01 00:00:00 bob @45589e459b2edfbf3dbde7e01f611d2c1e7453d7 (5000)> updating the branch cache |
|
303 | 310 | 1970/01/01 00:00:00 bob @45589e459b2edfbf3dbde7e01f611d2c1e7453d7 (5000)> updated branch cache (served) in * seconds (glob) |
|
304 | 311 | 1970/01/01 00:00:00 bob @45589e459b2edfbf3dbde7e01f611d2c1e7453d7 (5000)> wrote branch cache (served) with 1 labels and 1 nodes |
|
305 | 312 | 1970/01/01 00:00:00 bob @45589e459b2edfbf3dbde7e01f611d2c1e7453d7 (5000)> --debug commit -m commit2 -d 2000-01-02 foo exited 0 after *.?? seconds (glob) |
|
306 | 313 | 1970/01/01 00:00:00 bob @45589e459b2edfbf3dbde7e01f611d2c1e7453d7 (5000)> --debug log -r 0 |
|
307 | 314 | 1970/01/01 00:00:00 bob @45589e459b2edfbf3dbde7e01f611d2c1e7453d7 (5000)> writing .hg/cache/tags2-visible with 0 tags |
|
308 | 315 | 1970/01/01 00:00:00 bob @45589e459b2edfbf3dbde7e01f611d2c1e7453d7 (5000)> --debug log -r 0 exited 0 after *.?? seconds (glob) |
|
309 | 316 | 1970/01/01 00:00:00 bob @45589e459b2edfbf3dbde7e01f611d2c1e7453d7 (5000)> --debug log -r tip |
|
310 | 317 | 1970/01/01 00:00:00 bob @45589e459b2edfbf3dbde7e01f611d2c1e7453d7 (5000)> --debug log -r tip exited 0 after *.?? seconds (glob) |
|
311 | 318 | 1970/01/01 00:00:00 bob @45589e459b2edfbf3dbde7e01f611d2c1e7453d7 (5000)> blackbox |
|
312 | 319 | |
|
313 | 320 | Test log recursion from dirty status check |
|
314 | 321 | |
|
315 | 322 | $ cat > ../r.py <<EOF |
|
316 | 323 | > from mercurial import context, error, extensions |
|
317 | 324 | > x=[False] |
|
318 | 325 | > def status(orig, *args, **opts): |
|
319 | 326 | > args[0].repo().ui.log(b"broken", b"recursion?") |
|
320 | 327 | > return orig(*args, **opts) |
|
321 | 328 | > def reposetup(ui, repo): |
|
322 | 329 | > extensions.wrapfunction(context.basectx, 'status', status) |
|
323 | 330 | > EOF |
|
324 | 331 | $ hg id --config extensions.x=../r.py --config blackbox.dirty=True |
|
325 | 332 | 45589e459b2e tip |
|
326 | 333 | |
|
327 | 334 | cleanup |
|
328 | 335 | $ cd .. |
|
329 | 336 | |
|
330 | 337 | Test missing log directory, which shouldn't be created automatically |
|
331 | 338 | |
|
332 | 339 | $ cat <<'EOF' > closeremove.py |
|
333 | 340 | > def reposetup(ui, repo): |
|
334 | 341 | > class rmrepo(repo.__class__): |
|
335 | 342 | > def close(self): |
|
336 | 343 | > super(rmrepo, self).close() |
|
337 | 344 | > self.ui.debug(b'removing %s\n' % self.vfs.base) |
|
338 | 345 | > self.vfs.rmtree() |
|
339 | 346 | > repo.__class__ = rmrepo |
|
340 | 347 | > EOF |
|
341 | 348 | |
|
342 | 349 | $ hg init gone |
|
343 | 350 | $ cd gone |
|
344 | 351 | $ cat <<'EOF' > .hg/hgrc |
|
345 | 352 | > [extensions] |
|
346 | 353 | > closeremove = ../closeremove.py |
|
347 | 354 | > EOF |
|
348 | 355 | $ hg log --debug |
|
349 | 356 | removing $TESTTMP/gone/.hg |
|
350 | 357 | warning: cannot write to blackbox.log: $ENOENT$ (no-windows !) |
|
351 | 358 | warning: cannot write to blackbox.log: $TESTTMP/gone/.hg/blackbox.log: $ENOTDIR$ (windows !) |
|
352 | 359 | $ cd .. |
|
353 | 360 | |
|
354 | 361 | blackbox should disable itself if track is empty |
|
355 | 362 | |
|
356 | 363 | $ hg --config blackbox.track= init nothing_tracked |
|
357 | 364 | $ cd nothing_tracked |
|
358 | 365 | $ cat >> .hg/hgrc << EOF |
|
359 | 366 | > [blackbox] |
|
360 | 367 | > track = |
|
361 | 368 | > EOF |
|
362 | 369 | $ hg blackbox |
|
363 | 370 | $ cd $TESTTMP |
|
364 | 371 | |
|
365 | 372 | a '*' entry in blackbox.track is interpreted as log everything |
|
366 | 373 | |
|
367 | 374 | $ hg --config blackbox.track='*' \ |
|
368 | 375 | > --config blackbox.logsource=True \ |
|
369 | 376 | > init track_star |
|
370 | 377 | $ cd track_star |
|
371 | 378 | $ cat >> .hg/hgrc << EOF |
|
372 | 379 | > [blackbox] |
|
373 | 380 | > logsource = True |
|
374 | 381 | > track = * |
|
375 | 382 | > EOF |
|
376 | 383 | (only look for entries with specific logged sources, otherwise this test is |
|
377 | 384 | pretty brittle) |
|
378 | 385 | $ hg blackbox | egrep '\[command(finish)?\]' |
|
379 | 386 | 1970/01/01 00:00:00 bob @0000000000000000000000000000000000000000 (5000) [commandfinish]> --config *blackbox.track=* --config *blackbox.logsource=True* init track_star exited 0 after * seconds (glob) |
|
380 | 387 | 1970/01/01 00:00:00 bob @0000000000000000000000000000000000000000 (5000) [command]> blackbox |
|
381 | 388 | $ cd $TESTTMP |
|
382 | 389 | |
|
383 | 390 | #if chg |
|
384 | 391 | |
|
385 | 392 | when using chg, blackbox.log should get rotated correctly |
|
386 | 393 | |
|
387 | 394 | $ cat > $TESTTMP/noop.py << EOF |
|
388 | 395 | > from __future__ import absolute_import |
|
389 | 396 | > import time |
|
390 | 397 | > from mercurial import registrar, scmutil |
|
391 | 398 | > cmdtable = {} |
|
392 | 399 | > command = registrar.command(cmdtable) |
|
393 | 400 | > @command(b'noop') |
|
394 | 401 | > def noop(ui, repo): |
|
395 | 402 | > pass |
|
396 | 403 | > EOF |
|
397 | 404 | |
|
398 | 405 | $ hg init blackbox-chg |
|
399 | 406 | $ cd blackbox-chg |
|
400 | 407 | |
|
401 | 408 | $ cat > .hg/hgrc << EOF |
|
402 | 409 | > [blackbox] |
|
403 | 410 | > maxsize = 500B |
|
404 | 411 | > [extensions] |
|
405 | 412 | > # extension change forces chg to restart |
|
406 | 413 | > noop=$TESTTMP/noop.py |
|
407 | 414 | > EOF |
|
408 | 415 | |
|
409 | 416 | $ "$PYTHON" -c 'print("a" * 400)' > .hg/blackbox.log |
|
410 | 417 | $ chg noop |
|
411 | 418 | $ chg noop |
|
412 | 419 | $ chg noop |
|
413 | 420 | $ chg noop |
|
414 | 421 | $ chg noop |
|
415 | 422 | |
|
416 | 423 | $ cat > showsize.py << 'EOF' |
|
417 | 424 | > import os |
|
418 | 425 | > import sys |
|
419 | 426 | > limit = 500 |
|
420 | 427 | > for p in sys.argv[1:]: |
|
421 | 428 | > size = os.stat(p).st_size |
|
422 | 429 | > if size >= limit: |
|
423 | 430 | > desc = '>=' |
|
424 | 431 | > else: |
|
425 | 432 | > desc = '<' |
|
426 | 433 | > print('%s: %s %d' % (p, desc, limit)) |
|
427 | 434 | > EOF |
|
428 | 435 | |
|
429 | 436 | $ "$PYTHON" showsize.py .hg/blackbox* |
|
430 | 437 | .hg/blackbox.log: < 500 |
|
431 | 438 | .hg/blackbox.log.1: >= 500 |
|
432 | 439 | .hg/blackbox.log.2: >= 500 |
|
433 | 440 | |
|
434 | 441 | $ cd .. |
|
435 | 442 | |
|
436 | 443 | With chg, blackbox should not create the log file if the repo is gone |
|
437 | 444 | |
|
438 | 445 | $ hg init repo1 |
|
439 | 446 | $ hg --config extensions.a=! -R repo1 log |
|
440 | 447 | $ rm -rf $TESTTMP/repo1 |
|
441 | 448 | $ hg --config extensions.a=! init repo1 |
|
442 | 449 | |
|
443 | 450 | #endif |
|
444 | 451 | |
|
445 | 452 | blackbox should work if repo.ui.log is not called (issue5518) |
|
446 | 453 | |
|
447 | 454 | $ cat > $TESTTMP/raise.py << EOF |
|
448 | 455 | > from __future__ import absolute_import |
|
449 | 456 | > from mercurial import registrar, scmutil |
|
450 | 457 | > cmdtable = {} |
|
451 | 458 | > command = registrar.command(cmdtable) |
|
452 | 459 | > @command(b'raise') |
|
453 | 460 | > def raisecmd(*args): |
|
454 | 461 | > raise RuntimeError('raise') |
|
455 | 462 | > EOF |
|
456 | 463 | |
|
457 | 464 | $ cat >> $HGRCPATH << EOF |
|
458 | 465 | > [blackbox] |
|
459 | 466 | > track = commandexception |
|
460 | 467 | > [extensions] |
|
461 | 468 | > raise=$TESTTMP/raise.py |
|
462 | 469 | > EOF |
|
463 | 470 | |
|
464 | 471 | $ hg init $TESTTMP/blackbox-exception-only |
|
465 | 472 | $ cd $TESTTMP/blackbox-exception-only |
|
466 | 473 | |
|
467 | 474 | #if chg |
|
468 | 475 | (chg exits 255 because it fails to receive an exit code) |
|
469 | 476 | $ hg raise 2>/dev/null |
|
470 | 477 | [255] |
|
471 | 478 | #else |
|
472 | 479 | (hg exits 1 because Python default exit code for uncaught exception is 1) |
|
473 | 480 | $ hg raise 2>/dev/null |
|
474 | 481 | [1] |
|
475 | 482 | #endif |
|
476 | 483 | |
|
477 | 484 | $ head -1 .hg/blackbox.log |
|
478 | 485 | 1970/01/01 00:00:00 bob @0000000000000000000000000000000000000000 (5000)> ** Unknown exception encountered with possibly-broken third-party extension mock |
|
479 | 486 | $ tail -2 .hg/blackbox.log |
|
480 | 487 | RuntimeError: raise |
|
481 | 488 |
General Comments 0
You need to be logged in to leave comments.
Login now