changeset 40651:1243295fcc3a

logtoprocess: update commandfinish options arguments d2c997b8001f changed the logtoprocess API with the effect of not exposing the positional arguments to the logtoprocess scripts anymore. We have some scripts that use the duration and return code of the "commandfinish" event to monitor hg calls. Update the logging of the "commandfinish" to expose those values as options argument, which will be accessible as `OPT_RETURN_CODE` and `OPT_DURATION` in logtoprocess arguments. The code has been formatted with Black. Differential Revision: https://phab.mercurial-scm.org/D5282
author Boris Feld <boris.feld@octobus.net>
date Fri, 16 Nov 2018 14:21:47 +0100
parents ea84c2b286a2
children 291080871f50
files mercurial/dispatch.py
diffstat 1 files changed, 11 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/dispatch.py	Thu Nov 15 13:16:46 2018 -0800
+++ b/mercurial/dispatch.py	Fri Nov 16 14:21:47 2018 +0100
@@ -250,9 +250,17 @@
                 req.ui._blockedtimes['command_duration'] = duration * 1000
                 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,
-                       canonical_command=req.canonical_command)
+            return_code = ret & 255
+            req.ui.log(
+                "commandfinish",
+                "%s exited %d after %0.2f seconds\n",
+                msg,
+                return_code,
+                duration,
+                return_code=return_code,
+                duration=duration,
+                canonical_command=req.canonical_command,
+            )
             try:
                 req._runexithandlers()
             except: # exiting, so no re-raises