Always show short help when an unknown command is given.
--- a/mercurial/commands.py Sat Aug 06 13:33:14 2005 +0100
+++ b/mercurial/commands.py Sat Aug 06 14:04:59 2005 +0100
@@ -287,27 +287,24 @@
def help_(ui, cmd=None):
"""show help for a given command or all commands"""
if cmd and cmd != 'shortlist':
- try:
- i = find(cmd)
- ui.write("%s\n\n" % i[2])
+ i = find(cmd)
+ ui.write("%s\n\n" % i[2])
- if i[1]:
- for s, l, d, c in i[1]:
- 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")
+ if i[1]:
+ for s, l, d, c in i[1]:
+ 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")
- ui.write(i[0].__doc__, "\n")
- except UnknownCommand:
- ui.warn("hg: unknown command %s\n" % cmd)
+ ui.write(i[0].__doc__, "\n")
sys.exit(0)
else:
if ui.verbose:
@@ -1401,12 +1398,12 @@
help_(u, inst.args[0])
else:
u.warn("hg: %s\n" % inst.args[1])
- help_(u)
+ help_(u, 'shortlist')
sys.exit(-1)
except UnknownCommand, inst:
u = ui.ui()
u.warn("hg: unknown command '%s'\n" % inst.args[0])
- help_(u)
+ help_(u, 'shortlist')
sys.exit(1)
if options["time"]:
@@ -1491,5 +1488,8 @@
u.debug(inst, "\n")
u.warn("%s: invalid arguments\n" % cmd)
help_(u, cmd)
+ except UnknownCommand, inst:
+ u.warn("hg: unknown command '%s'\n" % inst.args[0])
+ help_(u, 'shortlist')
sys.exit(-1)
--- a/tests/test-help.out Sat Aug 06 13:33:14 2005 +0100
+++ b/tests/test-help.out Sat Aug 06 14:04:59 2005 +0100
@@ -104,42 +104,40 @@
diff working directory (or selected files)
+ hg help foo
-hg: unknown command foo
+hg: unknown command 'foo'
+basic hg commands (use "hg help" for more):
+
+ 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 commands
hg: unknown command 'commands'
- 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
- cat output the latest or given revision of a file
- clone make a copy of an existing repository
- commit commit the specified files or all outstanding changes
- copy mark a file as copied or renamed for the next commit
- diff diff working directory (or selected files)
- export dump the header and diffs for one or more changesets
- forget don't add the specified files on the next commit
- heads show current repository heads
- help show help for a given command or all commands
- identify print information about the working copy
- import import an ordered set of patches
- init create a new repository in the current directory
- locate locate files matching specific patterns
- log show the revision history of the repository or a single file
- manifest output the latest or given revision of the project manifest
- parents show the parents of the working dir or revision
- paths show path or list of available paths
- pull pull changes from the specified source
- push push changes to the specified destination
- rawcommit raw commit interface
- recover roll back an interrupted transaction
- remove remove the specified files on the next commit
- revert revert modified files or dirs back to their unmodified states
- root print the root (top) of the current working dir
- serve export the repository via HTTP
- status show changed files in the working directory
- tag add a tag for the current tip or a given revision
- tags list repository tags
- tip show the tip revision
- undo undo the last commit or pull
- update update or merge working directory
- verify verify the integrity of the repository
- version output version and copyright information
+basic hg commands (use "hg help" for more):
+
+ 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