diff mercurial/commands.py @ 848:221628fe9b62

Always show short help when an unknown command is given.
author Thomas Arendsen Hein <thomas@intevation.de>
date Sat, 06 Aug 2005 14:04:59 +0100
parents a30f7ee30914
children 8933ef744325
line wrap: on
line diff
--- 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)