Mercurial > public > mercurial-scm > hg-stable
diff mercurial/commands.py @ 423:25afb21d97ba
Support for 'hg --version'. setup.py stores version from hg repository.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Support for 'hg --version'. setup.py stores version from hg repository.
manifest hash: c69058298ea12035f2cf356f987ba2fb5ff4bbae
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)
iD8DBQFCtD6ZW7P1GVgWeRoRAnGHAKCLscthht2UlBEMDmxL9cku4PlcswCffOVo
wTOhYkW4Ie5+8bdmL8EqsvY=
=uGpn
-----END PGP SIGNATURE-----
author | Thomas Arendsen Hein <thomas@intevation.de> |
---|---|
date | Sat, 18 Jun 2005 16:32:41 +0100 |
parents | 8f8bb77d560e |
children | 688d03d6997a |
line wrap: on
line diff
--- a/mercurial/commands.py Fri Jun 17 20:37:23 2005 +0100 +++ b/mercurial/commands.py Sat Jun 18 16:32:41 2005 +0100 @@ -8,7 +8,7 @@ import os, re, sys, signal import fancyopts, ui, hg 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 @@ -679,7 +692,7 @@ "verify": (verify, [], 'hg verify'), } -norepo = "init branch help debugindex debugindexdot" +norepo = "init version help debugindex debugindexdot" def find(cmd): i = None @@ -704,6 +717,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, @@ -717,6 +731,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: