# HG changeset patch # User Chingis Dugarzhapov # Date 2014-12-22 02:20:50 # Node ID 861ddedfb402b9319410f270d0d6d4c215f480ff # Parent 80a37f706011146973a1443d2351d4b3fbf83bbb 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 ' to get full list of built-in aliases diff --git a/mercurial/help.py b/mercurial/help.py --- a/mercurial/help.py +++ b/mercurial/help.py @@ -371,6 +371,9 @@ def help_(ui, name, unknowncmd=False, fu 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') diff --git a/tests/test-extension.t b/tests/test-extension.t --- a/tests/test-extension.t +++ b/tests/test-extension.t @@ -462,7 +462,7 @@ Extension module help vs command help: 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 @@ Show extensions: 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 < """ + > 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 < """ + > 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