changeset 13950:14d0553bd48b

help: do not show full help text for command on option errors Example $ hg clone --jump foo bar hg clone: option --jump not recognized hg clone [OPTION]... SOURCE [DEST] make a copy of an existing repository options: -U --noupdate the clone will include an empty working copy (only a repository) -u --updaterev REV revision, tag or branch to check out -r --rev REV [+] include the specified changeset -b --branch BRANCH [+] clone only the specified branch --pull use pull protocol to copy metadata --uncompressed use uncompressed transfer (fast over LAN) -e --ssh CMD specify ssh command to use --remotecmd CMD specify hg command to run on the remote side --insecure do not verify server certificate (ignoring web.cacerts config) [+] marked option can be specified multiple times use "hg help clone" to show the full help text Motivation for this change If the user already has specified the command, he probably already knows the command to some extent. Apparently, he has a problem with the options, so we show him just the synopsis with the short help and the details about the options, with a hint on the last line how to get the full help text. Why is Mercurial better with this change? Experts who just forgot about the details of an option don't get that much text thrown at them, while the newbies still get a hint on the last line how to get the full help text.
author Adrian Buehlmann <adrian@cadifra.com>
date Sun, 17 Apr 2011 11:37:11 +0200
parents ba43aa1e173c
children 7a6a8a069aac
files mercurial/commands.py mercurial/dispatch.py tests/test-alias.t tests/test-dispatch.t tests/test-help.t tests/test-qrecord.t
diffstat 6 files changed, 10 insertions(+), 41 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/commands.py	Sun Apr 17 17:55:34 2011 +0200
+++ b/mercurial/commands.py	Sun Apr 17 11:37:11 2011 +0200
@@ -2047,7 +2047,7 @@
         displayer.show(ctx)
     displayer.close()
 
-def help_(ui, name=None, with_version=False, unknowncmd=False):
+def help_(ui, name=None, with_version=False, unknowncmd=False, full=True):
     """show help for a given topic or a help overview
 
     With no arguments, print a list of commands with short help messages.
@@ -2070,6 +2070,8 @@
             if name == 'shortlist':
                 msg = _('use "hg help" for the full list of commands '
                         'or "hg -v" for details')
+            elif name and not full:
+                msg = _('use "hg help %s" to show the full help text' % name)
             elif aliases:
                 msg = _('use "hg -v help%s" to show builtin aliases and '
                         'global options') % (name and " " + name or "")
@@ -2108,7 +2110,7 @@
             ui.write('hg %s\n' % aliases[0])
 
         # aliases
-        if not ui.quiet and len(aliases) > 1:
+        if full and not ui.quiet and len(aliases) > 1:
             ui.write(_("\naliases: %s\n") % ', '.join(aliases[1:]))
 
         # description
@@ -2120,7 +2122,7 @@
                 doc = _('shell alias for::\n\n    %s') % entry[0].definition[1:]
             else:
                 doc = _('alias for: hg %s\n\n%s') % (entry[0].definition, doc)
-        if ui.quiet:
+        if ui.quiet or not full:
             doc = doc.splitlines()[0]
         keep = ui.verbose and ['verbose'] or []
         formatted, pruned = minirst.format(doc, textwidth, keep=keep)
--- a/mercurial/dispatch.py	Sun Apr 17 17:55:34 2011 +0200
+++ b/mercurial/dispatch.py	Sun Apr 17 11:37:11 2011 +0200
@@ -90,7 +90,7 @@
     except error.CommandError, inst:
         if inst.args[0]:
             ui.warn(_("hg %s: %s\n") % (inst.args[0], inst.args[1]))
-            commands.help_(ui, inst.args[0])
+            commands.help_(ui, inst.args[0], full=False)
         else:
             ui.warn(_("hg: %s\n") % inst.args[1])
             commands.help_(ui, 'shortlist')
--- a/tests/test-alias.t	Sun Apr 17 17:55:34 2011 +0200
+++ b/tests/test-alias.t	Sun Apr 17 11:37:11 2011 +0200
@@ -304,13 +304,7 @@
   
   alias for: hg root
   
-  print the root (top) of the current working directory
-  
-      Print the root directory of the current repository.
-  
-      Returns 0 on success.
-  
-  use "hg -v help rt" to show global options
+  use "hg help rt" to show the full help text
   [255]
 
 invalid global arguments for normal commands, aliases, and shell aliases
--- a/tests/test-dispatch.t	Sun Apr 17 17:55:34 2011 +0200
+++ b/tests/test-dispatch.t	Sun Apr 17 11:37:11 2011 +0200
@@ -18,20 +18,6 @@
   
   output the current or given revision of files
   
-      Print the specified files as they were at the given revision. If no
-      revision is given, the parent of the working directory is used, or tip if
-      no revision is checked out.
-  
-      Output may be to a file, in which case the name of the file is given using
-      a format string. The formatting rules are the same as for the export
-      command, with the following additions:
-  
-      "%s"  basename of file being printed
-      "%d"  dirname of file being printed, or '.' if in repository root
-      "%p"  root-relative path name of file being printed
-  
-      Returns 0 on success.
-  
   options:
   
    -o --output FORMAT        print output to file with formatted name
@@ -42,7 +28,7 @@
   
   [+] marked option can be specified multiple times
   
-  use "hg -v help cat" to show global options
+  use "hg help cat" to show the full help text
   [255]
 
 [defaults]
--- a/tests/test-help.t	Sun Apr 17 17:55:34 2011 +0200
+++ b/tests/test-help.t	Sun Apr 17 11:37:11 2011 +0200
@@ -387,17 +387,6 @@
   
   add the specified files on the next commit
   
-      Schedule files to be version controlled and added to the repository.
-  
-      The files will be added to the repository at the next commit. To undo an
-      add before that, see "hg forget".
-  
-      If no names are given, add all files to the repository.
-  
-      Returns 0 if all files are successfully added.
-  
-  use "hg -v help add" to show verbose help
-  
   options:
   
    -I --include PATTERN [+]  include names matching the given patterns
@@ -407,7 +396,7 @@
   
   [+] marked option can be specified multiple times
   
-  use "hg -v help add" to show global options
+  use "hg help add" to show the full help text
   [255]
 
 Test ambiguous command help
--- a/tests/test-qrecord.t	Sun Apr 17 17:55:34 2011 +0200
+++ b/tests/test-qrecord.t	Sun Apr 17 11:37:11 2011 +0200
@@ -90,9 +90,7 @@
   
   interactively record a new patch
   
-      See "hg help qnew" & "hg help record" for more information and usage.
-  
-  use "hg -v help qrecord" to show global options
+  use "hg help qrecord" to show the full help text
   [255]
 
 qrecord patch (mq not present)