Mercurial > hg
changeset 849:8933ef744325
Further help improvements:
Show command aliases in 'hg help something', unless in quiet mode.
Show short command description with 'hg help -q something'.
Show global options in verbose mode of command help.
State that Mercurial is a Distributed SCM.
author | Thomas Arendsen Hein <thomas@intevation.de> |
---|---|
date | Sat, 06 Aug 2005 15:43:12 +0100 |
parents | 221628fe9b62 |
children | d2bf8b9534b1 |
files | mercurial/commands.py tests/test-help tests/test-help.out |
diffstat | 3 files changed, 145 insertions(+), 41 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/commands.py Sat Aug 06 14:04:59 2005 +0100 +++ b/mercurial/commands.py Sat Aug 06 15:43:12 2005 +0100 @@ -276,7 +276,8 @@ def show_version(ui): """output version and copyright information""" - ui.write("Mercurial version %s\n" % version.get_version()) + ui.write("Mercurial Distributed SCM (version %s)\n" + % version.get_version()) ui.status( "\nCopyright (C) 2005 Matt Mackall <mpm@selenic.com>\n" "This is free software; see the source for copying conditions. " @@ -287,10 +288,25 @@ def help_(ui, cmd=None): """show help for a given command or all commands""" if cmd and cmd != 'shortlist': - i = find(cmd) + key, i = find(cmd) + # synopsis ui.write("%s\n\n" % i[2]) - if i[1]: + # description + doc = i[0].__doc__ + if ui.quiet: + doc = doc.splitlines(0)[0] + ui.write("%s\n" % doc.rstrip()) + + # aliases + if not ui.quiet: + aliases = ', '.join(key.split('|')[1:]) + if aliases: + ui.write("\naliases: %s\n" % aliases) + + # options + if not ui.quiet and i[1]: + ui.write("\noptions:\n\n") for s, l, d, c in i[1]: opt = ' ' if s: @@ -302,33 +318,24 @@ ui.write(opt, "\n") if c: ui.write(' %s\n' % c) - ui.write("\n") - ui.write(i[0].__doc__, "\n") - sys.exit(0) else: + # program name if ui.verbose: show_version(ui) - ui.write('\n') - if ui.verbose: - ui.write("global options:\n\n") - for s, l, d, c in globalopts: - opt = ' ' - if s: - opt = opt + '-' + s + ' ' - if l: - opt = opt + '--' + l + ' ' - if d: - opt = opt + '(' + str(d) + ')' - ui.write(opt, "\n") - if c: - ui.write(' %s\n' % c) - ui.write("\n") + else: + ui.status("Mercurial Distributed SCM\n") + ui.status('\n') - ui.write('hg commands:\n\n') - + # list of commands if cmd == "shortlist": - ui.write('basic hg commands (use "hg help" for more):\n\n') + ui.status('basic commands (use "hg help" ' + 'for the full list or option "-v" for details):\n\n') + elif ui.verbose: + 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') h = {} cmds = {} @@ -336,9 +343,9 @@ f = c.split("|")[0] if cmd == "shortlist" and not f.startswith("^"): continue + f = f.lstrip("^") if not ui.debugflag and f.startswith("debug"): continue - f = f.lstrip("^") d = "" if e[0].__doc__: d = e[0].__doc__.splitlines(0)[0].rstrip() @@ -355,6 +362,21 @@ else: ui.write(' %-*s %s\n' % (m, f, h[f])) + # global options + if ui.verbose: + ui.write("\nglobal options:\n\n") + for s, l, d, c in globalopts: + opt = ' ' + if s: + opt = opt + '-' + s + ' ' + if l: + opt = opt + '--' + l + ' ' + if d: + opt = opt + '(' + str(d) + ')' + ui.write(opt, "\n") + if c: + ui.write(' %s\n' % c) + # Commands start here, listed alphabetically def add(ui, repo, *pats, **opts): @@ -1330,7 +1352,7 @@ def find(cmd): for e in table.keys(): if re.match("(%s)$" % e, cmd): - return table[e] + return e, table[e] raise UnknownCommand(cmd) @@ -1362,7 +1384,7 @@ else: cmd, args = args[0], args[1:] - i = find(cmd) + i = find(cmd)[1] # combine global options into local c = list(i[1])
--- a/tests/test-help Sat Aug 06 14:04:59 2005 +0100 +++ b/tests/test-help Sat Aug 06 15:43:12 2005 +0100 @@ -1,11 +1,15 @@ #!/bin/sh +hg +hg -q hg help hg -q help hg add -h hg add --skjdfks hg help diff +hg help status +hg -q help status hg help foo -hg -q commands +hg skjdfks exit 0
--- a/tests/test-help.out Sat Aug 06 14:04:59 2005 +0100 +++ b/tests/test-help.out Sat Aug 06 15:43:12 2005 +0100 @@ -1,4 +1,44 @@ ++ hg +Mercurial Distributed SCM + +basic commands (use "hg help" for the full list or option "-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 + commit commit the specified files or all outstanding changes + diff diff working directory (or selected files) + export dump the header and diffs for one or more changesets + init create a new repository in the current directory + log show the revision history of the repository or a single file + pull pull changes from the specified source + push push changes to the specified destination + remove remove the specified files on the next commit + revert revert modified files or dirs back to their unmodified states + serve export the repository via HTTP + status show changed files in the working directory + update update or merge working directory ++ hg -q + add add the specified files on the next commit + annotate show changeset information per file line + clone make a copy of an existing repository + commit commit the specified files or all outstanding changes + diff diff working directory (or selected files) + export dump the header and diffs for one or more changesets + init create a new repository in the current directory + log show the revision history of the repository or a single file + pull pull changes from the specified source + push push changes to the specified destination + remove remove the specified files on the next commit + revert revert modified files or dirs back to their unmodified states + serve export the repository via HTTP + status show changed files in the working directory + update update or merge working directory + hg help +Mercurial Distributed SCM + +list of commands (use "hg help -v" 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 @@ -76,36 +116,72 @@ hg add: option -h not recognized hg add [FILE]... - -I --include - include path in search - -X --exclude - exclude path from search +add the specified files on the next commit -add the specified files on the next commit -+ hg add --skjdfks -hg add: option --skjdfks not recognized -hg add [FILE]... +options: -I --include include path in search -X --exclude exclude path from search ++ hg add --skjdfks +hg add: option --skjdfks not recognized +hg add [FILE]... add the specified files on the next commit + +options: + + -I --include + include path in search + -X --exclude + exclude path from search + hg help diff hg diff [-r REV1 [-r REV2]] [FILE]... +diff working directory (or selected files) + +options: + -r --rev revision -I --include include path in search -X --exclude exclude path from search ++ hg help status +hg status [FILE]... -diff working directory (or selected files) +show changed files in the working directory + + M = modified + A = added + R = removed + ? = not tracked + +options: + + -m --modified + show only modified files + -a --added + show only added files + -r --removed + show only removed files + -u --unknown + show only unknown (not tracked) files + -I --include + include path in search + -X --exclude + exclude path from search ++ hg -q help status +hg status [FILE]... + +show changed files in the working directory + hg help foo hg: unknown command 'foo' -basic hg commands (use "hg help" for more): +Mercurial Distributed SCM + +basic commands (use "hg help" for the full list or option "-v" for details): add add the specified files on the next commit annotate show changeset information per file line @@ -122,9 +198,11 @@ serve export the repository via HTTP status show changed files in the working directory update update or merge working directory -+ hg -q commands -hg: unknown command 'commands' -basic hg commands (use "hg help" for more): ++ hg skjdfks +hg: unknown command 'skjdfks' +Mercurial Distributed SCM + +basic commands (use "hg help" for the full list or option "-v" for details): add add the specified files on the next commit annotate show changeset information per file line