Moved special handling of --version and no hg command from parse to dispatch.
authorThomas Arendsen Hein <thomas@intevation.de>
Fri, 26 Aug 2005 08:26:21 +0200
changeset 1047 a0538ea1ac50
parent 1046 772507daaa17
child 1048 7fbb440b2e63
Moved special handling of --version and no hg command from parse to dispatch. This allows e.g. 'hg status --version' to work.
mercurial/commands.py
--- a/mercurial/commands.py	Thu Aug 25 18:35:35 2005 +0200
+++ b/mercurial/commands.py	Fri Aug 26 08:26:21 2005 +0200
@@ -1556,17 +1556,15 @@
     except fancyopts.getopt.GetoptError, inst:
         raise ParseError(None, inst)
 
-    if options["version"]:
-        return ("version", show_version, [], options, cmdoptions)
-    elif not args:
-        return ("help", help_, ["shortlist"], options, cmdoptions)
+    if args:
+        cmd, args = args[0], args[1:]
+        i = find(cmd)[1]
+        c = list(i[1])
     else:
-        cmd, args = args[0], args[1:]
-
-    i = find(cmd)[1]
+        cmd = None
+        c = []
 
     # combine global options into local
-    c = list(i[1])
     for o in globalopts:
         c.append((o[0], o[1], options[o[1]], o[3]))
 
@@ -1581,7 +1579,7 @@
         options[n] = cmdoptions[n]
         del cmdoptions[n]
 
-    return (cmd, i[0], args, options, cmdoptions)
+    return (cmd, cmd and i[0] or None, args, options, cmdoptions)
 
 def dispatch(args):
     signal.signal(signal.SIGTERM, catchterm)
@@ -1634,6 +1632,13 @@
 
     try:
         try:
+            if options['version']:
+                show_version(u)
+                sys.exit(0)
+            elif not cmd:
+                help_(u, 'shortlist')
+                sys.exit(0)
+
             if cmd not in norepo.split():
                 path = options["repository"] or ""
                 repo = hg.repository(ui=u, path=path)