diff mercurial/commands.py @ 429:688d03d6997a

Pull from TAH -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Pull from TAH manifest hash: 600d04efbd836d555d11a3bd9d821d1d8c0a9790 -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.0 (GNU/Linux) iD8DBQFCuPFxywK+sNU5EO8RAjfzAKC18Zc2EOkXhy1zcpgGnyPHnFMdmgCfW5Ut I5HSWqZMt8H0WJx1Or7ajNc= =27D5 -----END PGP SIGNATURE-----
author mpm@selenic.com
date Tue, 21 Jun 2005 21:04:49 -0800
parents 28511fc21073 25afb21d97ba
children 5b38a5af4019
line wrap: on
line diff
--- a/mercurial/commands.py	Tue Jun 21 20:40:53 2005 -0800
+++ b/mercurial/commands.py	Tue Jun 21 21:04:49 2005 -0800
@@ -8,7 +8,7 @@
 import os, re, sys, signal
 import fancyopts, ui, hg, util
 from demandload import *
-demandload(globals(), "mdiff time hgweb traceback random signal errno")
+demandload(globals(), "mdiff time hgweb traceback random signal errno version")
 
 class UnknownCommand(Exception): pass
 
@@ -134,6 +134,16 @@
             ui.status("summary:     %s\n" % description.splitlines()[0])
     ui.status("\n")
 
+def show_version(ui):
+    """output version and copyright information"""
+    ui.write("Mercurial 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. "
+        "There is NO\nwarranty; "
+        "not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n"
+    )
+
 def help(ui, cmd=None):
     '''show help for a given command or all commands'''
     if cmd:
@@ -156,7 +166,10 @@
             ui.warn("hg: unknown command %s\n" % cmd)
         sys.exit(0)
     else:
-        ui.status('hg commands:\n\n')
+        if not ui.quiet:
+            show_version(ui)
+            ui.write('\n')
+        ui.write('hg commands:\n\n')
 
         h = {}
         for e in table.values():
@@ -171,7 +184,7 @@
         fns.sort()
         m = max(map(len, fns))
         for f in fns:
-            ui.status(' %-*s   %s\n' % (m, f, h[f]))
+            ui.write(' %-*s   %s\n' % (m, f, h[f]))
 
 # Commands start here, listed alphabetically
 
@@ -724,7 +737,7 @@
     "verify": (verify, [], 'hg verify'),
     }
 
-norepo = "init branch help debugindex debugindexdot"
+norepo = "init version help debugindex debugindexdot"
 
 def find(cmd):
     i = None
@@ -749,6 +762,7 @@
             ('q', 'quiet', None, 'quiet'),
             ('p', 'profile', None, 'profile'),
             ('y', 'noninteractive', None, 'run non-interactively'),
+            ('', 'version', None, 'output version information and exit'),
             ]
 
     args = fancyopts.fancyopts(args, opts, options,
@@ -762,6 +776,10 @@
     u = ui.ui(options["verbose"], options["debug"], options["quiet"],
            not options["noninteractive"])
 
+    if options["version"]:
+        show_version(u)
+        sys.exit(0)
+
     try:
         i = find(cmd)
     except UnknownCommand: