comparison tests/test-logtoprocess.t @ 30976:e92daf156d5c

ui: provide a mechanism to track and log blocked time We want to log the time Mercurial spends trapped in things outside programmatic control. Provide a mechanism to give us both command runtime and as many different sources of blocking as we deem useful.
author Simon Farnsworth <simonfar@fb.com>
date Wed, 15 Feb 2017 13:17:45 -0800
parents a368da441b32
children fdecd24ca4dc
comparison
equal deleted inserted replaced
30975:22fbca1d11ed 30976:e92daf156d5c
8 > command = cmdutil.command(cmdtable) 8 > command = cmdutil.command(cmdtable)
9 > @command('foo', []) 9 > @command('foo', [])
10 > def foo(ui, repo): 10 > def foo(ui, repo):
11 > ui.log('foo', 'a message: %(bar)s\n', bar='spam') 11 > ui.log('foo', 'a message: %(bar)s\n', bar='spam')
12 > EOF 12 > EOF
13 $ cp $HGRCPATH $HGRCPATH.bak
13 $ cat >> $HGRCPATH << EOF 14 $ cat >> $HGRCPATH << EOF
14 > [extensions] 15 > [extensions]
15 > logtoprocess= 16 > logtoprocess=
16 > foocommand=$TESTTMP/foocommand.py 17 > foocommand=$TESTTMP/foocommand.py
17 > [logtoprocess] 18 > [logtoprocess]
50 foo exited 0 after * seconds (glob) 51 foo exited 0 after * seconds (glob)
51 logtoprocess command output: 52 logtoprocess command output:
52 logtoprocess commandfinish output: 53 logtoprocess commandfinish output:
53 logtoprocess foo output: 54 logtoprocess foo output:
54 spam 55 spam
56
57 Confirm that logging blocked time catches stdio properly:
58 $ cp $HGRCPATH.bak $HGRCPATH
59 $ cat >> $HGRCPATH << EOF
60 > [extensions]
61 > logtoprocess=
62 > pager=
63 > [logtoprocess]
64 > uiblocked=echo "\$EVENT command \$OPT_COMMAND_DURATION ms"
65 > [ui]
66 > logblockedtimes=True
67 > EOF
68
69 $ hg log
70 uiblocked command [0-9]+.[0-9]* ms (re)