diff --git a/hgext/blackbox.py b/hgext/blackbox.py --- a/hgext/blackbox.py +++ b/hgext/blackbox.py @@ -211,6 +211,13 @@ if util.safehasattr(ui, 'setrepo'): ui.setrepo(repo) + + # Set lastui even if ui.log is not called. This gives blackbox a + # fallback place to log. + global lastui + if lastui is None: + lastui = ui + repo._wlockfreeprefix.add('blackbox.log') @command('^blackbox', diff --git a/tests/test-blackbox.t b/tests/test-blackbox.t --- a/tests/test-blackbox.t +++ b/tests/test-blackbox.t @@ -15,6 +15,7 @@ $ echo a > a $ hg add a $ hg blackbox --config blackbox.dirty=True + 1970/01/01 00:00:00 bob @0000000000000000000000000000000000000000 (5000)> init blackboxtest exited 0 after * seconds (glob) 1970/01/01 00:00:00 bob @0000000000000000000000000000000000000000 (5000)> add a 1970/01/01 00:00:00 bob @0000000000000000000000000000000000000000 (5000)> add a exited 0 after * seconds (glob) 1970/01/01 00:00:00 bob @0000000000000000000000000000000000000000+ (5000)> blackbox @@ -22,6 +23,7 @@ alias expansion is logged $ hg confuse $ hg blackbox + 1970/01/01 00:00:00 bob @0000000000000000000000000000000000000000 (5000)> init blackboxtest exited 0 after * seconds (glob) 1970/01/01 00:00:00 bob @0000000000000000000000000000000000000000 (5000)> add a 1970/01/01 00:00:00 bob @0000000000000000000000000000000000000000 (5000)> add a exited 0 after * seconds (glob) 1970/01/01 00:00:00 bob @0000000000000000000000000000000000000000+ (5000)> blackbox @@ -174,6 +176,7 @@ $ hg init blackboxtest3 $ cd blackboxtest3 $ hg blackbox + 1970/01/01 00:00:00 bob @0000000000000000000000000000000000000000 (5000)> init blackboxtest3 exited 0 after * seconds (glob) 1970/01/01 00:00:00 bob @0000000000000000000000000000000000000000 (5000)> blackbox $ mv .hg/blackbox.log .hg/blackbox.log- $ mkdir .hg/blackbox.log @@ -284,3 +287,41 @@ $ cd .. #endif + +blackbox should work if repo.ui.log is not called (issue5518) + + $ cat > $TESTTMP/raise.py << EOF + > from __future__ import absolute_import + > from mercurial import registrar, scmutil + > cmdtable = {} + > command = registrar.command(cmdtable) + > @command('raise') + > def raisecmd(*args): + > raise RuntimeError('raise') + > EOF + + $ cat >> $HGRCPATH << EOF + > [blackbox] + > track = commandexception + > [extensions] + > raise=$TESTTMP/raise.py + > EOF + + $ hg init $TESTTMP/blackbox-exception-only + $ cd $TESTTMP/blackbox-exception-only + +#if chg + (chg exits 255 because it fails to receive an exit code) + $ hg raise 2>/dev/null + [255] +#else + (hg exits 1 because Python default exit code for uncaught exception is 1) + $ hg raise 2>/dev/null + [1] +#endif + + $ head -1 .hg/blackbox.log + 1970/01/01 00:00:00 bob @0000000000000000000000000000000000000000 (5000)> ** Unknown exception encountered with possibly-broken third-party extension mock + $ tail -2 .hg/blackbox.log + RuntimeError: raise +