[PATCH] help: added possibility to priotize help from extension module first

Erik Zielke ez at aragost.com
Tue Oct 5 05:51:26 CDT 2010


# HG changeset patch
# User Erik Zielke <ez at aragost.com>
# Date 1286272736 -7200
# Node ID 8ad7363fe88e71a9c9903c0104921f8e2b4c5771
# Parent  f365aed7cc5b4ce5f42d1e2d20001e2dc7951c5b
help: added possibility to priotize help from extension module first

Added -e/--ext option to help, which makes the help from the extension
module be priotized first. This can be useful when an extension has
the same name as one of its commands.

diff -r f365aed7cc5b -r 8ad7363fe88e mercurial/commands.py
--- a/mercurial/commands.py	Fri Oct 01 23:16:11 2010 +0200
+++ b/mercurial/commands.py	Tue Oct 05 11:58:56 2010 +0200
@@ -1823,7 +1823,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, **opts):
     """show help for a given topic or a help overview
 
     With no arguments, print a list of commands with short help messages.
@@ -2018,6 +2018,8 @@
             queries = (helpextcmd,)
         else:
             queries = (helptopic, helpcmd, helpext, helpextcmd)
+            if opts.get('ext'):
+                queries = (helpext, helptopic, helpcmd, helpextcmd)
         for f in queries:
             try:
                 f(name)
@@ -4164,7 +4166,10 @@
            _('show normal and closed branch heads')),
          ] + templateopts,
          _('[-ac] [-r STARTREV] [REV]...')),
-    "help": (help_, [], _('[TOPIC]')),
+    "help": (help_,
+             [('e', 'ext', None, 
+               _('Prioritizes extension module help first'))],
+             _('[-e] [TOPIC]')),
     "identify|id":
         (identify,
          [('r', 'rev', '',
diff -r f365aed7cc5b -r 8ad7363fe88e tests/test-bad-extension.t
--- a/tests/test-bad-extension.t	Fri Oct 01 23:16:11 2010 +0200
+++ b/tests/test-bad-extension.t	Tue Oct 05 11:58:56 2010 +0200
@@ -10,6 +10,6 @@
   $ hg -q help help
   \*\*\* failed to import extension badext from */badext.py: bit bucket overflow (glob)
   *** failed to import extension badext2: No module named badext2
-  hg help [TOPIC]
+  hg help [-e] [TOPIC]
   
   show help for a given topic or a help overview
diff -r f365aed7cc5b -r 8ad7363fe88e tests/test-debugcomplete.t
--- a/tests/test-debugcomplete.t	Fri Oct 01 23:16:11 2010 +0200
+++ b/tests/test-debugcomplete.t	Tue Oct 05 11:58:56 2010 +0200
@@ -225,7 +225,7 @@
   debugwalk: include, exclude
   grep: print0, all, follow, ignore-case, files-with-matches, line-number, rev, user, date, include, exclude
   heads: rev, topo, active, closed, style, template
-  help: 
+  help: ext
   identify: rev, num, id, branch, tags
   import: strip, base, force, no-commit, exact, import-branch, message, logfile, date, user, similarity
   incoming: force, newest-first, bundle, rev, branch, patch, git, limit, no-merges, stat, style, template, ssh, remotecmd, subrepos
diff -r f365aed7cc5b -r 8ad7363fe88e tests/test-help-extension.t
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/test-help-extension.t	Tue Oct 05 11:58:56 2010 +0200
@@ -0,0 +1,69 @@
+Set up a repo
+
+  $ echo "[extensions]" >> $HGRCPATH
+  $ echo "record=" >> $HGRCPATH
+
+Test extension help
+  $ hg help record
+  hg record [OPTION]... [FILE]...
+  
+  interactively select changes to commit
+  
+      If a list of files is omitted, all changes reported by "hg status" will be
+      candidates for recording.
+  
+      See "hg help dates" for a list of formats valid for -d/--date.
+  
+      You will be prompted for whether to record changes to each modified file,
+      and for files with multiple changes, for each change to use. For each
+      query, the following responses are possible:
+  
+        y - record this change
+        n - skip this change
+  
+        s - skip remaining changes to this file
+        f - record remaining changes to this file
+  
+        d - done, skip remaining changes and files
+        a - record all changes to all remaining files
+        q - quit, recording no changes
+  
+        ? - display help
+  
+      This command is not available when committing a merge.
+  
+  options:
+  
+   -A --addremove            mark new/missing files as added/removed before
+                             committing
+      --close-branch         mark a branch as closed, hiding it from the branch
+                             list
+   -I --include PATTERN [+]  include names matching the given patterns
+   -X --exclude PATTERN [+]  exclude names matching the given patterns
+   -m --message TEXT         use text as commit message
+   -l --logfile FILE         read commit message from file
+   -d --date DATE            record datecode as commit date
+   -u --user USER            record the specified user as committer
+  
+  [+] marked option can be specified multiple times
+  
+  use "hg -v help record" to show global options
+
+Test extension help
+  $ hg help -e record
+  record extension - commands to interactively select changes for commit/qrefresh
+  
+  list of commands:
+  
+   record   interactively select changes to commit
+  
+  use "hg -v help record" to show aliases and global options
+
+  $ hg help --ext record
+  record extension - commands to interactively select changes for commit/qrefresh
+  
+  list of commands:
+  
+   record   interactively select changes to commit
+  
+  use "hg -v help record" to show aliases and global options


More information about the Mercurial-devel mailing list