##// END OF EJS Templates
logtoprocess: sends the canonical command name to the subprocess...
Boris Feld -
r40438:106adc26 default
parent child Browse files
Show More
@@ -66,6 +66,9 b' class request(object):'
66 # low-level repo state (for example, changelog) before extensions.
66 # low-level repo state (for example, changelog) before extensions.
67 self.prereposetups = prereposetups or []
67 self.prereposetups = prereposetups or []
68
68
69 # store the parsed and canonical command
70 self.canonical_command = None
71
69 def _runexithandlers(self):
72 def _runexithandlers(self):
70 exc = None
73 exc = None
71 handlers = self.ui._exithandlers
74 handlers = self.ui._exithandlers
@@ -243,7 +246,8 b' def dispatch(req):'
243 req.ui.log('uiblocked', 'ui blocked ms',
246 req.ui.log('uiblocked', 'ui blocked ms',
244 **pycompat.strkwargs(req.ui._blockedtimes))
247 **pycompat.strkwargs(req.ui._blockedtimes))
245 req.ui.log("commandfinish", "%s exited %d after %0.2f seconds\n",
248 req.ui.log("commandfinish", "%s exited %d after %0.2f seconds\n",
246 msg, ret & 255, duration)
249 msg, ret & 255, duration,
250 canonical_command=req.canonical_command)
247 try:
251 try:
248 req._runexithandlers()
252 req._runexithandlers()
249 except: # exiting, so no re-raises
253 except: # exiting, so no re-raises
@@ -853,6 +857,9 b' def _dispatch(req):'
853 fullargs = args
857 fullargs = args
854 cmd, func, args, options, cmdoptions = _parse(lui, args)
858 cmd, func, args, options, cmdoptions = _parse(lui, args)
855
859
860 # store the canonical command name in request object for later access
861 req.canonical_command = cmd
862
856 if options["config"] != req.earlyoptions["config"]:
863 if options["config"] != req.earlyoptions["config"]:
857 raise error.Abort(_("option --config may not be abbreviated!"))
864 raise error.Abort(_("option --config may not be abbreviated!"))
858 if options["cwd"] != req.earlyoptions["cwd"]:
865 if options["cwd"] != req.earlyoptions["cwd"]:
@@ -17,7 +17,7 b' Test if logtoprocess correctly captures '
17 > configitem('logtoprocess', 'foo',
17 > configitem('logtoprocess', 'foo',
18 > default=None,
18 > default=None,
19 > )
19 > )
20 > @command(b'foo', [])
20 > @command(b'foobar', [])
21 > def foo(ui, repo):
21 > def foo(ui, repo):
22 > ui.log('foo', 'a message: %s\n', 'spam')
22 > ui.log('foo', 'a message: %s\n', 'spam')
23 > EOF
23 > EOF
@@ -35,7 +35,8 b' Test if logtoprocess correctly captures '
35 > echo "\$EVENT";
35 > echo "\$EVENT";
36 > echo "\$MSG1";
36 > echo "\$MSG1";
37 > echo "\$MSG2";
37 > echo "\$MSG2";
38 > echo "\$MSG3") > $TESTTMP/commandfinish.log
38 > echo "\$MSG3";
39 > echo "canonical: \$OPT_CANONICAL_COMMAND") > $TESTTMP/commandfinish.log
39 > foo=(echo 'logtoprocess foo output:';
40 > foo=(echo 'logtoprocess foo output:';
40 > echo "\$EVENT";
41 > echo "\$EVENT";
41 > echo "\$MSG1";
42 > echo "\$MSG1";
@@ -46,22 +47,23 b' Running a command triggers both a ui.log'
46 ui.log('commandfinish') call. The foo command also uses ui.log.
47 ui.log('commandfinish') call. The foo command also uses ui.log.
47
48
48 Use sort to avoid ordering issues between the various processes we spawn:
49 Use sort to avoid ordering issues between the various processes we spawn:
49 $ hg foo
50 $ hg fooba
50 $ sleep 1
51 $ sleep 1
51 $ cat $TESTTMP/command.log | sort
52 $ cat $TESTTMP/command.log | sort
52
53
53 command
54 command
54 foo
55 fooba
55 foo
56 fooba
56 logtoprocess command output:
57 logtoprocess command output:
57
58
58 #if no-chg
59 #if no-chg
59 $ cat $TESTTMP/commandfinish.log | sort
60 $ cat $TESTTMP/commandfinish.log | sort
60
61
61 0
62 0
63 canonical: foobar
62 commandfinish
64 commandfinish
63 foo
65 fooba
64 foo exited 0 after * seconds (glob)
66 fooba exited 0 after * seconds (glob)
65 logtoprocess commandfinish output:
67 logtoprocess commandfinish output:
66 $ cat $TESTTMP/foo.log | sort
68 $ cat $TESTTMP/foo.log | sort
67
69
General Comments 0
You need to be logged in to leave comments. Login now