changeset 14284:1f9e11f65cd7

help: add -e/--extension switch to display extension help text
author Henri Wiechers <hwiechers@gmail.com>
date Wed, 20 Jan 2010 20:24:20 +0200
parents 035489c9ea53
children aa64a87b493d
files mercurial/commands.py tests/test-bad-extension.t tests/test-debugcomplete.t tests/test-extension.t
diffstat 4 files changed, 103 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/commands.py	Mon May 09 18:11:08 2011 +0200
+++ b/mercurial/commands.py	Wed Jan 20 20:24:20 2010 +0200
@@ -2133,7 +2133,7 @@
         displayer.show(ctx)
     displayer.close()
 
-def help_(ui, name=None, with_version=False, unknowncmd=False, full=True):
+def help_(ui, name=None, with_version=False, unknowncmd=False, full=True, **opts):
     """show help for a given topic or a help overview
 
     With no arguments, print a list of commands with short help messages.
@@ -2332,6 +2332,8 @@
         i = None
         if unknowncmd:
             queries = (helpextcmd,)
+        elif opts.get('extension'):
+            queries = (helpext,)
         else:
             queries = (helptopic, helpcmd, helpext, helpextcmd)
         for f in queries:
@@ -4705,7 +4707,9 @@
            _('show normal and closed branch heads')),
          ] + templateopts,
          _('[-ac] [-r STARTREV] [REV]...')),
-    "help": (help_, [], _('[TOPIC]')),
+    "help": (help_,
+        [('e', 'extension', None, _('show only help for extensions'))],
+        _('[-e] [TOPIC]')),
     "identify|id":
         (identify,
          [('r', 'rev', '',
--- a/tests/test-bad-extension.t	Mon May 09 18:11:08 2011 +0200
+++ b/tests/test-bad-extension.t	Wed Jan 20 20:24:20 2010 +0200
@@ -10,6 +10,6 @@
   $ hg -q help help
   *** failed to import extension badext from $TESTTMP/badext.py: bit bucket overflow
   *** 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
--- a/tests/test-debugcomplete.t	Mon May 09 18:11:08 2011 +0200
+++ b/tests/test-debugcomplete.t	Wed Jan 20 20:24:20 2010 +0200
@@ -239,7 +239,7 @@
   debugwireargs: three, four, five, ssh, remotecmd, insecure
   grep: print0, all, text, follow, ignore-case, files-with-matches, line-number, rev, user, date, include, exclude
   heads: rev, topo, active, closed, style, template
-  help: 
+  help: extension
   identify: rev, num, id, branch, tags, bookmarks
   import: strip, base, force, no-commit, exact, import-branch, message, logfile, date, user, similarity
   incoming: force, newest-first, bundle, rev, bookmarks, branch, patch, git, limit, no-merges, stat, style, template, ssh, remotecmd, insecure, subrepos
--- a/tests/test-extension.t	Mon May 09 18:11:08 2011 +0200
+++ b/tests/test-extension.t	Wed Jan 20 20:24:20 2010 +0200
@@ -232,6 +232,101 @@
   [+] marked option can be specified multiple times
   $ echo 'debugextension = !' >> $HGRCPATH
 
+Extension module help vs command help:
+
+  $ echo 'extdiff =' >> $HGRCPATH
+  $ hg help extdiff
+  hg extdiff [OPT]... [FILE]...
+  
+  use external program to diff repository (or selected files)
+  
+      Show differences between revisions for the specified files, using an
+      external program. The default program used is diff, with default options
+      "-Npru".
+  
+      To select a different program, use the -p/--program option. The program
+      will be passed the names of two directories to compare. To pass additional
+      options to the program, use -o/--option. These will be passed before the
+      names of the directories to compare.
+  
+      When two revision arguments are given, then changes are shown between
+      those revisions. If only one revision is specified then that revision is
+      compared to the working directory, and, when no revisions are specified,
+      the working directory files are compared to its parent.
+  
+  options:
+  
+   -p --program CMD          comparison program to run
+   -o --option OPT [+]       pass option to comparison program
+   -r --rev REV [+]          revision
+   -c --change REV           change made by revision
+   -I --include PATTERN [+]  include names matching the given patterns
+   -X --exclude PATTERN [+]  exclude names matching the given patterns
+  
+  [+] marked option can be specified multiple times
+  
+  use "hg -v help extdiff" to show global options
+
+  $ hg help --extension extdiff
+  extdiff extension - command to allow external programs to compare revisions
+  
+  The extdiff Mercurial extension allows you to use external programs to compare
+  revisions, or revision with working directory. The external diff programs are
+  called with a configurable set of options and two non-option arguments: paths
+  to directories containing snapshots of files to compare.
+  
+  The extdiff extension also allows to configure new diff commands, so you do
+  not need to type "hg extdiff -p kdiff3" always.
+  
+    [extdiff]
+    # add new command that runs GNU diff(1) in 'context diff' mode
+    cdiff = gdiff -Nprc5
+    ## or the old way:
+    #cmd.cdiff = gdiff
+    #opts.cdiff = -Nprc5
+  
+    # add new command called vdiff, runs kdiff3
+    vdiff = kdiff3
+  
+    # add new command called meld, runs meld (no need to name twice)
+    meld =
+  
+    # add new command called vimdiff, runs gvimdiff with DirDiff plugin
+    # (see http://www.vim.org/scripts/script.php?script_id=102) Non
+    # English user, be sure to put "let g:DirDiffDynamicDiffText = 1" in
+    # your .vimrc
+    vimdiff = gvim -f '+next' '+execute "DirDiff" argv(0) argv(1)'
+  
+  Tool arguments can include variables that are expanded at runtime:
+  
+    $parent1, $plabel1 - filename, descriptive label of first parent
+    $child,   $clabel  - filename, descriptive label of child revision
+    $parent2, $plabel2 - filename, descriptive label of second parent
+    $root              - repository root
+    $parent is an alias for $parent1.
+  
+  The extdiff extension will look in your [diff-tools] and [merge-tools]
+  sections for diff tool arguments, when none are specified in [extdiff].
+  
+    [extdiff]
+    kdiff3 =
+  
+    [diff-tools]
+    kdiff3.diffargs=--L1 '$plabel1' --L2 '$clabel' $parent $child
+  
+  You can use -I/-X and list of file or directory names like normal "hg diff"
+  command. The extdiff extension makes snapshots of only needed files, so
+  running the external diff program will actually be pretty fast (at least
+  faster than having to compare the entire tree).
+  
+  list of commands:
+  
+   extdiff   use external program to diff repository (or selected files)
+  
+  use "hg -v help extdiff" to show builtin aliases and global options
+
+  $ echo 'extdiff = !' >> $HGRCPATH
+
 Issue811: Problem loading extensions twice (by site and by user)
 
   $ debugpath=`pwd`/debugissue811.py