Patchwork [v2] blackbox: also log alias expansions

login
register
mail settings
Submitter Augie Fackler
Date Aug. 25, 2016, 4:49 a.m.
Message ID <28b1db977fd9f2ec1766.1472100594@imladris.local>
Download mbox | patch
Permalink /patch/16407/
State Accepted
Headers show

Comments

Augie Fackler - Aug. 25, 2016, 4:49 a.m.
# HG changeset patch
# User Augie Fackler <augie@google.com>
# Date 1471984808 14400
#      Tue Aug 23 16:40:08 2016 -0400
# Node ID 28b1db977fd9f2ec176618912072db95b2a7d36f
# Parent  a67829d1ca07d19150aadd58725f1bb3ed284e3a
blackbox: also log alias expansions

This should be extremely useful for helping users debug without having
to see their complete configuration.

Shell aliases do not get their expansion logged, because we don't look
and see if we're in a repo before we dive into the execution of a
shell alias. As a result, the ui object doesn't know where to log.
Yuya Nishihara - Aug. 25, 2016, 1:25 p.m.
On Thu, 25 Aug 2016 00:49:54 -0400, Augie Fackler wrote:
> # HG changeset patch
> # User Augie Fackler <augie@google.com>
> # Date 1471984808 14400
> #      Tue Aug 23 16:40:08 2016 -0400
> # Node ID 28b1db977fd9f2ec176618912072db95b2a7d36f
> # Parent  a67829d1ca07d19150aadd58725f1bb3ed284e3a
> blackbox: also log alias expansions

Queued, thanks.

Patch

diff --git a/mercurial/dispatch.py b/mercurial/dispatch.py
--- a/mercurial/dispatch.py
+++ b/mercurial/dispatch.py
@@ -500,6 +500,8 @@  class cmdalias(object):
             ui.debug("alias '%s' shadows command '%s'\n" %
                      (self.name, self.cmdname))
 
+        ui.log('commandalias', "alias '%s' expands to '%s'\n",
+               self.name, self.definition)
         if util.safehasattr(self, 'shell'):
             return self.fn(ui, *args, **opts)
         else:
diff --git a/tests/test-blackbox.t b/tests/test-blackbox.t
--- a/tests/test-blackbox.t
+++ b/tests/test-blackbox.t
@@ -4,6 +4,8 @@  setup
   > blackbox=
   > mock=$TESTDIR/mockblackbox.py
   > mq=
+  > [alias]
+  > confuse = log --limit 3
   > EOF
   $ hg init blackboxtest
   $ cd blackboxtest
@@ -17,6 +19,18 @@  command, exit codes, and duration
   1970/01/01 00:00:00 bob @0000000000000000000000000000000000000000 (5000)> add a exited 0 after * seconds (glob)
   1970/01/01 00:00:00 bob @0000000000000000000000000000000000000000+ (5000)> blackbox
 
+alias expansion is logged
+  $ hg confuse
+  $ hg blackbox
+  1970/01/01 00:00:00 bob @0000000000000000000000000000000000000000 (5000)> add a
+  1970/01/01 00:00:00 bob @0000000000000000000000000000000000000000 (5000)> add a exited 0 after * seconds (glob)
+  1970/01/01 00:00:00 bob @0000000000000000000000000000000000000000+ (5000)> blackbox
+  1970/01/01 00:00:00 bob @0000000000000000000000000000000000000000+ (5000)> blackbox --config blackbox.dirty=True exited 0 after * seconds (glob)
+  1970/01/01 00:00:00 bob @0000000000000000000000000000000000000000 (5000)> confuse
+  1970/01/01 00:00:00 bob @0000000000000000000000000000000000000000 (5000)> alias 'confuse' expands to 'log --limit 3'
+  1970/01/01 00:00:00 bob @0000000000000000000000000000000000000000 (5000)> confuse exited 0 after * seconds (glob)
+  1970/01/01 00:00:00 bob @0000000000000000000000000000000000000000 (5000)> blackbox
+
 incoming change tracking
 
 create two heads to verify that we only see one change in the log later