Patchwork [4,of,6] help: provide help of bad alias without executing aliascmd()

login
register
mail settings
Submitter Yuya Nishihara
Date Aug. 14, 2014, 2:31 a.m.
Message ID <ed528eaade5d3de13652.1407983486@mimosa>
Download mbox | patch
Permalink /patch/5390/
State Accepted
Headers show

Comments

Yuya Nishihara - Aug. 14, 2014, 2:31 a.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1407926327 -32400
#      Wed Aug 13 19:38:47 2014 +0900
# Node ID ed528eaade5d3de13652d54fc1d650ec0f26fa62
# Parent  cb7cc831f040ddd6a880157d1c6c6ddd0fc5c3fb
help: provide help of bad alias without executing aliascmd()

The output is slightly changed because of minirst formatting.  Previously,
ui.pushbuffer() had no effect because "badalias" message was written to stderr.

"if not unknowncmd" should no longer be needed because there's no call loop.

Patch

diff --git a/mercurial/help.py b/mercurial/help.py
--- a/mercurial/help.py
+++ b/mercurial/help.py
@@ -236,10 +236,12 @@  def help_(ui, name, unknowncmd=False, fu
 
         # check if it's an invalid alias and display its error if it is
         if getattr(entry[0], 'badalias', None):
-            if not unknowncmd:
-                ui.pushbuffer()
-                entry[0](ui)
-                rst.append(ui.popbuffer())
+            rst.append(entry[0].badalias + '\n')
+            if entry[0].unknowncmd:
+                try:
+                    rst.extend(helpextcmd(entry[0].cmdname))
+                except error.UnknownCommand:
+                    pass
             return rst
 
         # synopsis
diff --git a/tests/test-alias.t b/tests/test-alias.t
--- a/tests/test-alias.t
+++ b/tests/test-alias.t
@@ -97,6 +97,7 @@  disabled
   [255]
   $ hg help disabled
   alias 'disabled' resolves to unknown command 'email'
+  
   'email' is provided by the following extension:
   
       patchbomb     command to send changesets as (a series of) patch emails
@@ -128,7 +129,8 @@  invalid options
   error in definition for alias 'no--cwd': --cwd may only be given on the command line
   [255]
   $ hg help no--cwd
-  error in definition for alias 'no--cwd': --cwd may only be given on the command line
+  error in definition for alias 'no--cwd': --cwd may only be given on the
+  command line
   $ hg no-R
   error in definition for alias 'no-R': -R may only be given on the command line
   [255]
@@ -138,12 +140,14 @@  invalid options
   error in definition for alias 'no--repo': --repo may only be given on the command line
   [255]
   $ hg help no--repo
-  error in definition for alias 'no--repo': --repo may only be given on the command line
+  error in definition for alias 'no--repo': --repo may only be given on the
+  command line
   $ hg no--repository
   error in definition for alias 'no--repository': --repository may only be given on the command line
   [255]
   $ hg help no--repository
-  error in definition for alias 'no--repository': --repository may only be given on the command line
+  error in definition for alias 'no--repository': --repository may only be given
+  on the command line
   $ hg no--config
   error in definition for alias 'no--config': --config may only be given on the command line
   [255]