D4820: logtoprocess: sends the canonical command name to the subprocess
lothiraldan (Boris Feld)
phabricator at mercurial-scm.org
Mon Oct 22 15:57:09 UTC 2018
This revision was automatically updated to reflect the committed changes.
Closed by commit rHG106adc261492: logtoprocess: sends the canonical command name to the subprocess (authored by lothiraldan, committed by ).
REPOSITORY
rHG Mercurial
CHANGES SINCE LAST UPDATE
https://phab.mercurial-scm.org/D4820?vs=12307&id=12308
REVISION DETAIL
https://phab.mercurial-scm.org/D4820
AFFECTED FILES
mercurial/dispatch.py
tests/test-logtoprocess.t
CHANGE DETAILS
diff --git a/tests/test-logtoprocess.t b/tests/test-logtoprocess.t
--- a/tests/test-logtoprocess.t
+++ b/tests/test-logtoprocess.t
@@ -17,7 +17,7 @@
> configitem('logtoprocess', 'foo',
> default=None,
> )
- > @command(b'foo', [])
+ > @command(b'foobar', [])
> def foo(ui, repo):
> ui.log('foo', 'a message: %s\n', 'spam')
> EOF
@@ -35,7 +35,8 @@
> echo "\$EVENT";
> echo "\$MSG1";
> echo "\$MSG2";
- > echo "\$MSG3") > $TESTTMP/commandfinish.log
+ > echo "\$MSG3";
+ > echo "canonical: \$OPT_CANONICAL_COMMAND") > $TESTTMP/commandfinish.log
> foo=(echo 'logtoprocess foo output:';
> echo "\$EVENT";
> echo "\$MSG1";
@@ -46,22 +47,23 @@
ui.log('commandfinish') call. The foo command also uses ui.log.
Use sort to avoid ordering issues between the various processes we spawn:
- $ hg foo
+ $ hg fooba
$ sleep 1
$ cat $TESTTMP/command.log | sort
command
- foo
- foo
+ fooba
+ fooba
logtoprocess command output:
#if no-chg
$ cat $TESTTMP/commandfinish.log | sort
0
+ canonical: foobar
commandfinish
- foo
- foo exited 0 after * seconds (glob)
+ fooba
+ fooba exited 0 after * seconds (glob)
logtoprocess commandfinish output:
$ cat $TESTTMP/foo.log | sort
diff --git a/mercurial/dispatch.py b/mercurial/dispatch.py
--- a/mercurial/dispatch.py
+++ b/mercurial/dispatch.py
@@ -66,6 +66,9 @@
# low-level repo state (for example, changelog) before extensions.
self.prereposetups = prereposetups or []
+ # store the parsed and canonical command
+ self.canonical_command = None
+
def _runexithandlers(self):
exc = None
handlers = self.ui._exithandlers
@@ -243,7 +246,8 @@
req.ui.log('uiblocked', 'ui blocked ms',
**pycompat.strkwargs(req.ui._blockedtimes))
req.ui.log("commandfinish", "%s exited %d after %0.2f seconds\n",
- msg, ret & 255, duration)
+ msg, ret & 255, duration,
+ canonical_command=req.canonical_command)
try:
req._runexithandlers()
except: # exiting, so no re-raises
@@ -853,6 +857,9 @@
fullargs = args
cmd, func, args, options, cmdoptions = _parse(lui, args)
+ # store the canonical command name in request object for later access
+ req.canonical_command = cmd
+
if options["config"] != req.earlyoptions["config"]:
raise error.Abort(_("option --config may not be abbreviated!"))
if options["cwd"] != req.earlyoptions["cwd"]:
To: lothiraldan, #hg-reviewers
Cc: yuja, mercurial-devel
More information about the Mercurial-devel
mailing list