[PATCH 5 of 5] help: list extensions with -v, and provide help for an extension

Johannes Stezenbach js at sig21.net
Sat May 24 16:11:09 CDT 2008


# HG changeset patch
# User Johannes Stezenbach <js at sig21.net>
# Date 1211663393 -7200
# Node ID 4baf90063915829e244e7ee6c52d20267671ef04
# Parent  2997131eab6d4a92f4299cb40add962f3c850b03
help: list extensions with -v, and provide help for an extension
(including list of commands provided by the extension)
with 'hg help -e <ext>'

diff -r 2997131eab6d -r 4baf90063915 mercurial/commands.py
--- a/mercurial/commands.py	Sat May 24 22:18:25 2008 +0200
+++ b/mercurial/commands.py	Sat May 24 23:09:53 2008 +0200
@@ -1222,7 +1222,7 @@
     for n in heads:
         displayer.show(changenode=n)
 
-def help_(ui, name=None, with_version=False):
+def help_(ui, name=None, with_version=False, **opts):
     """show help for a command, extension, or list of commands
 
     With no arguments, print a list of commands and short help.
@@ -1361,7 +1361,11 @@
 
     if name and name != 'shortlist':
         i = None
-        for f in (helpcmd, helptopic, helpext):
+        if opts['extension']:
+            h = (helpext,)
+        else:
+            h = (helpcmd, helptopic, helpext)
+        for f in h:
             try:
                 f(name)
                 i = None
@@ -1409,6 +1413,10 @@
         topics_len = max([len(s[0]) for s in topics])
         for t, desc in topics:
             ui.write(" %-*s  %s\n" % (topics_len, t, desc))
+
+        ui.write(_("\nextensions (try 'hg help -e <ext>'):\n"))
+        for name, mod in extensions.extensions():
+            ui.write("  %s\n" % name)
 
     if opt_output:
         opts_len = max([len(line[0]) for line in opt_output if line[1]] or [0])
@@ -3110,7 +3118,10 @@
          [('r', 'rev', '', _('show only heads which are descendants of rev')),
          ] + templateopts,
          _('hg heads [-r REV] [REV]...')),
-    "help": (help_, [], _('hg help [COMMAND]')),
+    "help":
+        (help_,
+         [('e', 'extension', None, _('print help for an extension'))],
+         _('hg help [COMMAND]')),
     "identify|id":
         (identify,
          [('r', 'rev', '', _('identify the specified rev')),




More information about the Mercurial-devel mailing list