Patchwork dispatch: include resolved command name when logging command

login
register
mail settings
Submitter Augie Fackler
Date Nov. 16, 2016, 10:36 p.m.
Message ID <34a175911ad07fc75285.1479335812@augie-macbookair2.roam.corp.google.com>
Download mbox | patch
Permalink /patch/17610/
State Changes Requested
Delegated to: Yuya Nishihara
Headers show

Comments

Augie Fackler - Nov. 16, 2016, 10:36 p.m.
# HG changeset patch
# User Augie Fackler <augie@google.com>
# Date 1479335668 18000
#      Wed Nov 16 17:34:28 2016 -0500
# Node ID 34a175911ad07fc7528540e93c4110f393812748
# Parent  a1beadaa406116c0266c46064a00003be7de7394
dispatch: include resolved command name when logging command

This will be useful for anyone that wants to log the specific command
that was executed without having to parse the joined command line
arguments.
Augie Fackler - Nov. 16, 2016, 10:39 p.m.
Wait, I missed something semi-obvious: this isn't the full resolved command name, so it's not what I had in mind. I'll send a more complete patch once I get that sorted.

> On Nov 16, 2016, at 17:36, Augie Fackler <raf@durin42.com> wrote:
> 
> # HG changeset patch
> # User Augie Fackler <augie@google.com>
> # Date 1479335668 18000
> #      Wed Nov 16 17:34:28 2016 -0500
> # Node ID 34a175911ad07fc7528540e93c4110f393812748
> # Parent  a1beadaa406116c0266c46064a00003be7de7394
> dispatch: include resolved command name when logging command
> 
> This will be useful for anyone that wants to log the specific command
> that was executed without having to parse the joined command line
> arguments.
> 
> diff --git a/mercurial/dispatch.py b/mercurial/dispatch.py
> --- a/mercurial/dispatch.py
> +++ b/mercurial/dispatch.py
> @@ -899,7 +899,7 @@ def _dispatch(req):
>             ui.warn(_("warning: --repository ignored\n"))
> 
>         msg = ' '.join(' ' in a and repr(a) or a for a in fullargs)
> -        ui.log("command", '%s\n', msg)
> +        ui.log("command", '%s\n', msg, cmd=cmd)
>         d = lambda: util.checksignature(func)(ui, *args, **cmdoptions)
>         try:
>             return runcommand(lui, repo, cmd, fullargs, ui, options, d,
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
Augie Fackler - Nov. 16, 2016, 10:48 p.m.
> On Nov 16, 2016, at 17:39, Augie Fackler <raf@durin42.com> wrote:
> 
> Wait, I missed something semi-obvious: this isn't the full resolved command name, so it's not what I had in mind. I'll send a more complete patch once I get that sorted.

Oh, wait. I misread test output, which is probably a hint that this could use a more formal test somehow. I'm open to suggestions on that front, or if people are comfortable with it I'm also happy to see it land as-is.

Thanks!

> 
>> On Nov 16, 2016, at 17:36, Augie Fackler <raf@durin42.com> wrote:
>> 
>> # HG changeset patch
>> # User Augie Fackler <augie@google.com>
>> # Date 1479335668 18000
>> #      Wed Nov 16 17:34:28 2016 -0500
>> # Node ID 34a175911ad07fc7528540e93c4110f393812748
>> # Parent  a1beadaa406116c0266c46064a00003be7de7394
>> dispatch: include resolved command name when logging command
>> 
>> This will be useful for anyone that wants to log the specific command
>> that was executed without having to parse the joined command line
>> arguments.
>> 
>> diff --git a/mercurial/dispatch.py b/mercurial/dispatch.py
>> --- a/mercurial/dispatch.py
>> +++ b/mercurial/dispatch.py
>> @@ -899,7 +899,7 @@ def _dispatch(req):
>>            ui.warn(_("warning: --repository ignored\n"))
>> 
>>        msg = ' '.join(' ' in a and repr(a) or a for a in fullargs)
>> -        ui.log("command", '%s\n', msg)
>> +        ui.log("command", '%s\n', msg, cmd=cmd)
>>        d = lambda: util.checksignature(func)(ui, *args, **cmdoptions)
>>        try:
>>            return runcommand(lui, repo, cmd, fullargs, ui, options, d,
>> _______________________________________________
>> Mercurial-devel mailing list
>> Mercurial-devel@mercurial-scm.org
>> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
>
Yuya Nishihara - Nov. 20, 2016, 11:08 a.m.
On Wed, 16 Nov 2016 17:48:06 -0500, Augie Fackler wrote:
> > On Nov 16, 2016, at 17:39, Augie Fackler <raf@durin42.com> wrote:
> > 
> > Wait, I missed something semi-obvious: this isn't the full resolved command name, so it's not what I had in mind. I'll send a more complete patch once I get that sorted.
> 
> Oh, wait. I misread test output, which is probably a hint that this could use a more formal test somehow. I'm open to suggestions on that front, or if people are comfortable with it I'm also happy to see it land as-is.

Seems fine to land as-is. Do we need to update the docstring of ui.log(),
which says "**opts currently has no defined meanings" ?

> >> On Nov 16, 2016, at 17:36, Augie Fackler <raf@durin42.com> wrote:
> >> This will be useful for anyone that wants to log the specific command
> >> that was executed without having to parse the joined command line
> >> arguments.

We could extend the event "command" to "command.<cmd>" (and make blackbox
support prefix match) if the purpose of the cmd argument is filtering.
Augie Fackler - Nov. 20, 2016, 2:25 p.m.
> On Nov 20, 2016, at 6:08 AM, Yuya Nishihara <yuya@tcha.org> wrote:
> 
> On Wed, 16 Nov 2016 17:48:06 -0500, Augie Fackler wrote:
>>> On Nov 16, 2016, at 17:39, Augie Fackler <raf@durin42.com> wrote:
>>> 
>>> Wait, I missed something semi-obvious: this isn't the full resolved command name, so it's not what I had in mind. I'll send a more complete patch once I get that sorted.
>> 
>> Oh, wait. I misread test output, which is probably a hint that this could use a more formal test somehow. I'm open to suggestions on that front, or if people are comfortable with it I'm also happy to see it land as-is.
> 
> Seems fine to land as-is. Do we need to update the docstring of ui.log(),
> which says "**opts currently has no defined meanings” ?

Oh, good catch. I’ll add that and do a resend.

> 
>>>> On Nov 16, 2016, at 17:36, Augie Fackler <raf@durin42.com> wrote:
>>>> This will be useful for anyone that wants to log the specific command
>>>> that was executed without having to parse the joined command line
>>>> arguments.
> 
> We could extend the event "command" to "command.<cmd>" (and make blackbox
> support prefix match) if the purpose of the cmd argument is filtering.

For my needs, it’s actually so I can log the command the user typed without having to re-do argument parsing on the command line - at work we want to have an idea of how long various commands take, and our infrastructure works best when we’ve got protocol buffers as output, so we’ve got a custom internal blackbox-like extension that does that.

I’ll send a new version on Monday.

Patch

diff --git a/mercurial/dispatch.py b/mercurial/dispatch.py
--- a/mercurial/dispatch.py
+++ b/mercurial/dispatch.py
@@ -899,7 +899,7 @@  def _dispatch(req):
             ui.warn(_("warning: --repository ignored\n"))
 
         msg = ' '.join(' ' in a and repr(a) or a for a in fullargs)
-        ui.log("command", '%s\n', msg)
+        ui.log("command", '%s\n', msg, cmd=cmd)
         d = lambda: util.checksignature(func)(ui, *args, **cmdoptions)
         try:
             return runcommand(lui, repo, cmd, fullargs, ui, options, d,