help: suggest '-v -e' to get built-in aliases for extensions (issue4461)
authorChingis Dugarzhapov <chingis.dug@gmail.com>
Mon, 22 Dec 2014 03:20:50 +0100
changeset 23624 861ddedfb402
parent 23623 80a37f706011
child 23625 3a8a85469ee8
help: suggest '-v -e' to get built-in aliases for extensions (issue4461) If extension name matches one of command names, suggest user to type 'hg help -v -e <extension>' to get full list of built-in aliases
mercurial/help.py
tests/test-extension.t
--- a/mercurial/help.py	Thu Dec 18 10:11:38 2014 -0800
+++ b/mercurial/help.py	Mon Dec 22 03:20:50 2014 +0100
@@ -371,6 +371,9 @@
             elif name and not full:
                 rst.append(_('\n(use "hg help %s" to show the full help '
                              'text)\n') % name)
+            elif name and cmds and name in cmds.keys():
+                rst.append(_('\n(use "hg help -v -e %s" to show built-in '
+                             'aliases and global options)\n') % name)
             else:
                 rst.append(_('\n(use "hg help -v%s" to show built-in aliases '
                              'and global options)\n')
--- a/tests/test-extension.t	Thu Dec 18 10:11:38 2014 -0800
+++ b/tests/test-extension.t	Mon Dec 22 03:20:50 2014 +0100
@@ -462,7 +462,7 @@
   
    extdiff       use external program to diff repository (or selected files)
   
-  (use "hg help -v extdiff" to show built-in aliases and global options)
+  (use "hg help -v -e extdiff" to show built-in aliases and global options)
 
 
 
@@ -573,6 +573,214 @@
   strip
   mq
 
+For extensions, which name matches one of its commands, help
+message should ask '-v -e' to get list of built-in aliases
+along with extension help itself
+
+  $ mkdir $TESTTMP/d
+  $ cat > $TESTTMP/d/dodo.py <<EOF
+  > """
+  > This is an awesome 'dodo' extension. It does nothing and
+  > writes 'Foo foo'
+  > """
+  > from mercurial import cmdutil, commands
+  > cmdtable = {}
+  > command = cmdutil.command(cmdtable)
+  > @command('dodo', [], 'hg dodo')
+  > def dodo(ui, *args, **kwargs):
+  >     """Does nothing"""
+  >     ui.write("I do nothing. Yay\\n")
+  > @command('foofoo', [], 'hg foofoo')
+  > def foofoo(ui, *args, **kwargs):
+  >     """Writes 'Foo foo'"""
+  >     ui.write("Foo foo\\n")
+  > EOF
+  $ dodopath=$TESTTMP/d/dodo.py
+
+  $ echo "dodo = $dodopath" >> $HGRCPATH
+
+Make sure that user is asked to enter '-v -e' to get list of built-in aliases
+  $ hg help -e dodo
+  dodo extension -
+  
+  This is an awesome 'dodo' extension. It does nothing and writes 'Foo foo'
+  
+  list of commands:
+  
+   dodo          Does nothing
+   foofoo        Writes 'Foo foo'
+  
+  (use "hg help -v -e dodo" to show built-in aliases and global options)
+
+Make sure that '-v -e' prints list of built-in aliases along with
+extension help itself
+  $ hg help -v -e dodo
+  dodo extension -
+  
+  This is an awesome 'dodo' extension. It does nothing and writes 'Foo foo'
+  
+  list of commands:
+  
+   dodo          Does nothing
+   foofoo        Writes 'Foo foo'
+  
+  global options ([+] can be repeated):
+  
+   -R --repository REPO   repository root directory or name of overlay bundle
+                          file
+      --cwd DIR           change working directory
+   -y --noninteractive    do not prompt, automatically pick the first choice for
+                          all prompts
+   -q --quiet             suppress output
+   -v --verbose           enable additional output
+      --config CONFIG [+] set/override config option (use 'section.name=value')
+      --debug             enable debugging output
+      --debugger          start debugger
+      --encoding ENCODE   set the charset encoding (default: ascii)
+      --encodingmode MODE set the charset encoding mode (default: strict)
+      --traceback         always print a traceback on exception
+      --time              time how long the command takes
+      --profile           print command execution profile
+      --version           output version information and exit
+   -h --help              display help and exit
+      --hidden            consider hidden changesets
+
+Make sure that single '-v' option shows help and built-ins only for 'dodo' command
+  $ hg help -v dodo
+  hg dodo
+  
+  Does nothing
+  
+  (use "hg help -e dodo" to show help for the dodo extension)
+  
+  options:
+  
+    --mq operate on patch repository
+  
+  global options ([+] can be repeated):
+  
+   -R --repository REPO   repository root directory or name of overlay bundle
+                          file
+      --cwd DIR           change working directory
+   -y --noninteractive    do not prompt, automatically pick the first choice for
+                          all prompts
+   -q --quiet             suppress output
+   -v --verbose           enable additional output
+      --config CONFIG [+] set/override config option (use 'section.name=value')
+      --debug             enable debugging output
+      --debugger          start debugger
+      --encoding ENCODE   set the charset encoding (default: ascii)
+      --encodingmode MODE set the charset encoding mode (default: strict)
+      --traceback         always print a traceback on exception
+      --time              time how long the command takes
+      --profile           print command execution profile
+      --version           output version information and exit
+   -h --help              display help and exit
+      --hidden            consider hidden changesets
+
+In case when extension name doesn't match any of its commands,
+help message should ask for '-v' to get list of built-in aliases
+along with extension help
+  $ cat > $TESTTMP/d/dudu.py <<EOF
+  > """
+  > This is an awesome 'dudu' extension. It does something and
+  > also writes 'Beep beep'
+  > """
+  > from mercurial import cmdutil, commands
+  > cmdtable = {}
+  > command = cmdutil.command(cmdtable)
+  > @command('something', [], 'hg something')
+  > def something(ui, *args, **kwargs):
+  >     """Does something"""
+  >     ui.write("I do something. Yaaay\\n")
+  > @command('beep', [], 'hg beep')
+  > def beep(ui, *args, **kwargs):
+  >     """Writes 'Beep beep'"""
+  >     ui.write("Beep beep\\n")
+  > EOF
+  $ dudupath=$TESTTMP/d/dudu.py
+
+  $ echo "dudu = $dudupath" >> $HGRCPATH
+
+  $ hg help -e dudu
+  dudu extension -
+  
+  This is an awesome 'dudu' extension. It does something and also writes 'Beep
+  beep'
+  
+  list of commands:
+  
+   beep          Writes 'Beep beep'
+   something     Does something
+  
+  (use "hg help -v dudu" to show built-in aliases and global options)
+
+In case when extension name doesn't match any of its commands,
+help options '-v' and '-v -e' should be equivalent
+  $ hg help -v dudu
+  dudu extension -
+  
+  This is an awesome 'dudu' extension. It does something and also writes 'Beep
+  beep'
+  
+  list of commands:
+  
+   beep          Writes 'Beep beep'
+   something     Does something
+  
+  global options ([+] can be repeated):
+  
+   -R --repository REPO   repository root directory or name of overlay bundle
+                          file
+      --cwd DIR           change working directory
+   -y --noninteractive    do not prompt, automatically pick the first choice for
+                          all prompts
+   -q --quiet             suppress output
+   -v --verbose           enable additional output
+      --config CONFIG [+] set/override config option (use 'section.name=value')
+      --debug             enable debugging output
+      --debugger          start debugger
+      --encoding ENCODE   set the charset encoding (default: ascii)
+      --encodingmode MODE set the charset encoding mode (default: strict)
+      --traceback         always print a traceback on exception
+      --time              time how long the command takes
+      --profile           print command execution profile
+      --version           output version information and exit
+   -h --help              display help and exit
+      --hidden            consider hidden changesets
+
+  $ hg help -v -e dudu
+  dudu extension -
+  
+  This is an awesome 'dudu' extension. It does something and also writes 'Beep
+  beep'
+  
+  list of commands:
+  
+   beep          Writes 'Beep beep'
+   something     Does something
+  
+  global options ([+] can be repeated):
+  
+   -R --repository REPO   repository root directory or name of overlay bundle
+                          file
+      --cwd DIR           change working directory
+   -y --noninteractive    do not prompt, automatically pick the first choice for
+                          all prompts
+   -q --quiet             suppress output
+   -v --verbose           enable additional output
+      --config CONFIG [+] set/override config option (use 'section.name=value')
+      --debug             enable debugging output
+      --debugger          start debugger
+      --encoding ENCODE   set the charset encoding (default: ascii)
+      --encodingmode MODE set the charset encoding mode (default: strict)
+      --traceback         always print a traceback on exception
+      --time              time how long the command takes
+      --profile           print command execution profile
+      --version           output version information and exit
+   -h --help              display help and exit
+      --hidden            consider hidden changesets
+
 Disabled extension commands:
 
   $ ORGHGRCPATH=$HGRCPATH