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