Mercurial > hg
changeset 4315:bc6f5a1d8b7b
Add a pointer to "hg -v help" to the bottom of hg help {,cmd} output
This should make it easier to discover global options.
As a bonus, they are no longer displayed by something like a
hg -v help dates
author | Alexis S. L. Carvalho <alexis@cecm.usp.br> |
---|---|
date | Sat, 07 Apr 2007 04:27:55 -0300 |
parents | 43dedce9667e |
children | 6e4334be0aaa |
files | mercurial/commands.py tests/test-extdiff.out tests/test-globalopts.out tests/test-help.out tests/test-mq.out tests/test-strict.out |
diffstat | 6 files changed, 62 insertions(+), 27 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/commands.py Sat Apr 07 04:27:55 2007 -0300 +++ b/mercurial/commands.py Sat Apr 07 04:27:55 2007 -0300 @@ -1268,6 +1268,23 @@ commands it provides.""" option_lists = [] + def addglobalopts(aliases): + if ui.verbose: + option_lists.append((_("global options:"), globalopts)) + if name == 'shortlist': + option_lists.append((_('use "hg help" for the full list ' + 'of commands'), ())) + else: + if name == 'shortlist': + msg = _('use "hg help" for the full list of commands ' + 'or "hg -v" for details') + elif aliases: + msg = _('use "hg -v help%s" to show aliases and ' + 'global options') % (name and " " + name or "") + else: + msg = _('use "hg -v help %s" to show global options') % name + option_lists.append((msg, ())) + def helpcmd(name): if with_version: version_(ui) @@ -1291,7 +1308,9 @@ # options if i[1]: - option_lists.append(("options", i[1])) + option_lists.append((_("options:\n"), i[1])) + + addglobalopts(False) def helplist(select=None): h = {} @@ -1321,6 +1340,9 @@ else: ui.write(' %-*s %s\n' % (m, f, h[f])) + if not ui.quiet: + addglobalopts(True) + def helptopic(name): v = None for i in help.helptable: @@ -1360,12 +1382,7 @@ ui.status(_('no commands defined\n')) return - if ui.verbose: - ui.status(_('list of commands:\n\n')) - else: - ui.status(_('list of commands (use "hg help -v %s" ' - 'to show aliases and global options):\n\n') % name) - + ui.status(_('list of commands:\n\n')) modcmds = dict.fromkeys([c.split('|', 1)[0] for c in ct]) helplist(modcmds.has_key) @@ -1391,24 +1408,16 @@ # list of commands if name == "shortlist": - ui.status(_('basic commands (use "hg help" ' - 'for the full list or option "-v" for details):\n\n')) - elif ui.verbose: + ui.status(_('basic commands:\n\n')) + else: ui.status(_('list of commands:\n\n')) - else: - ui.status(_('list of commands (use "hg help -v" ' - 'to show aliases and global options):\n\n')) helplist() - # global options - if ui.verbose: - option_lists.append(("global options", globalopts)) - # list all option lists opt_output = [] for title, options in option_lists: - opt_output.append(("\n%s:\n" % title, None)) + opt_output.append(("\n%s" % title, None)) for shortopt, longopt, default, desc in options: if "DEPRECATED" in desc and not ui.verbose: continue opt_output.append(("%2s%s" % (shortopt and "-%s" % shortopt, @@ -1419,7 +1428,7 @@ or ""))) if opt_output: - opts_len = max([len(line[0]) for line in opt_output if line[1]]) + opts_len = max([len(line[0]) for line in opt_output if line[1]] or [0]) for first, second in opt_output: if second: ui.write(" %-*s %s\n" % (opts_len, first, second))
--- a/tests/test-extdiff.out Sat Apr 07 04:27:55 2007 -0300 +++ b/tests/test-extdiff.out Sat Apr 07 04:27:55 2007 -0300 @@ -24,6 +24,8 @@ -r --rev revision -I --include include names matching the given patterns -X --exclude exclude names matching the given patterns + +use "hg -v help falabala" to show global options making snapshot of 1 files from rev e27a2475d60a making snapshot of 1 files from rev 5e49ec8d3f05 diffing a.e27a2475d60a a.5e49ec8d3f05
--- a/tests/test-globalopts.out Sat Apr 07 04:27:55 2007 -0300 +++ b/tests/test-globalopts.out Sat Apr 07 04:27:55 2007 -0300 @@ -117,7 +117,7 @@ %% -h/--help Mercurial Distributed SCM -list of commands (use "hg help -v" to show aliases and global options): +list of commands: add add the specified files on the next commit addremove add all new files, delete all missing files @@ -165,9 +165,11 @@ update update working directory verify verify the integrity of the repository version output version and copyright information + +use "hg -v help" to show aliases and global options Mercurial Distributed SCM -list of commands (use "hg help -v" to show aliases and global options): +list of commands: add add the specified files on the next commit addremove add all new files, delete all missing files @@ -215,4 +217,6 @@ update update working directory verify verify the integrity of the repository version output version and copyright information + +use "hg -v help" to show aliases and global options %% not tested: --debugger
--- a/tests/test-help.out Sat Apr 07 04:27:55 2007 -0300 +++ b/tests/test-help.out Sat Apr 07 04:27:55 2007 -0300 @@ -1,6 +1,6 @@ Mercurial Distributed SCM -basic commands (use "hg help" for the full list or option "-v" for details): +basic commands: add add the specified files on the next commit annotate show changeset information per file line @@ -19,6 +19,8 @@ serve export the repository via HTTP status show changed files in the working directory update update working directory + +use "hg help" for the full list of commands or "hg -v" for details add add the specified files on the next commit annotate show changeset information per file line clone make a copy of an existing repository @@ -38,7 +40,7 @@ update update working directory Mercurial Distributed SCM -list of commands (use "hg help -v" to show aliases and global options): +list of commands: add add the specified files on the next commit addremove add all new files, delete all missing files @@ -86,6 +88,8 @@ update update working directory verify verify the integrity of the repository version output version and copyright information + +use "hg -v help" to show aliases and global options add add the specified files on the next commit addremove add all new files, delete all missing files annotate show changeset information per file line @@ -148,6 +152,8 @@ -I --include include names matching the given patterns -X --exclude exclude names matching the given patterns -n --dry-run do not perform actions, just print output + +use "hg -v help add" to show global options hg add: option --skjdfks not recognized hg add [OPTION]... [FILE]... @@ -165,6 +171,8 @@ -I --include include names matching the given patterns -X --exclude exclude names matching the given patterns -n --dry-run do not perform actions, just print output + +use "hg -v help add" to show global options hg diff [OPTION]... [-r REV1 [-r REV2]] [FILE]... diff repository (or selected files) @@ -199,6 +207,8 @@ -B --ignore-blank-lines ignore changes whose lines are all blank -I --include include names matching the given patterns -X --exclude exclude names matching the given patterns + +use "hg -v help diff" to show global options hg status [OPTION]... [FILE]... show changed files in the working directory @@ -243,13 +253,15 @@ --rev show difference from revision -I --include include names matching the given patterns -X --exclude exclude names matching the given patterns + +use "hg -v help status" to show global options hg status [OPTION]... [FILE]... show changed files in the working directory hg: unknown command 'foo' Mercurial Distributed SCM -basic commands (use "hg help" for the full list or option "-v" for details): +basic commands: add add the specified files on the next commit annotate show changeset information per file line @@ -268,10 +280,12 @@ serve export the repository via HTTP status show changed files in the working directory update update working directory + +use "hg help" for the full list of commands or "hg -v" for details hg: unknown command 'skjdfks' Mercurial Distributed SCM -basic commands (use "hg help" for the full list or option "-v" for details): +basic commands: add add the specified files on the next commit annotate show changeset information per file line @@ -290,3 +304,5 @@ serve export the repository via HTTP status show changed files in the working directory update update working directory + +use "hg help" for the full list of commands or "hg -v" for details
--- a/tests/test-mq.out Sat Apr 07 04:27:55 2007 -0300 +++ b/tests/test-mq.out Sat Apr 07 04:27:55 2007 -0300 @@ -22,7 +22,7 @@ remove patch from applied stack qpop refresh contents of top applied patch qrefresh -list of commands (use "hg help -v mq" to show aliases and global options): +list of commands: qapplied print the patches already applied qclone clone main and patch repository at same time @@ -48,6 +48,8 @@ qtop print the name of the current patch qunapplied print the patches not yet applied strip strip a revision and all later revs on the same branch + +use "hg -v help mq" to show aliases and global options adding a 1 files updated, 0 files merged, 0 files removed, 0 files unresolved adding b/z
--- a/tests/test-strict.out Sat Apr 07 04:27:55 2007 -0300 +++ b/tests/test-strict.out Sat Apr 07 04:27:55 2007 -0300 @@ -3,7 +3,7 @@ hg: unknown command 'an' Mercurial Distributed SCM -basic commands (use "hg help" for the full list or option "-v" for details): +basic commands: add add the specified files on the next commit annotate show changeset information per file line @@ -22,6 +22,8 @@ serve export the repository via HTTP status show changed files in the working directory update update working directory + +use "hg help" for the full list of commands or "hg -v" for details 0: a % should succeed - up is an alias, not an abbreviation 0 files updated, 0 files merged, 0 files removed, 0 files unresolved