D5282: logtoprocess: update commandfinish options arguments

lothiraldan (Boris Feld) phabricator at mercurial-scm.org
Fri Nov 16 13:33:28 UTC 2018


lothiraldan created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  https://phab.mercurial-scm.org/rHGd2c997b8001ff5fff0ae3d042362f321a707dd55 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.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D5282

AFFECTED FILES
  mercurial/dispatch.py

CHANGE DETAILS

diff --git a/mercurial/dispatch.py b/mercurial/dispatch.py
--- a/mercurial/dispatch.py
+++ b/mercurial/dispatch.py
@@ -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



To: lothiraldan, #hg-reviewers
Cc: mercurial-devel


More information about the Mercurial-devel mailing list