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