Mercurial > public > mercurial-scm > hg
comparison 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 |
comparison
equal
deleted
inserted
replaced
396:8f8bb77d560e | 423:25afb21d97ba |
---|---|
6 # of the GNU General Public License, incorporated herein by reference. | 6 # of the GNU General Public License, incorporated herein by reference. |
7 | 7 |
8 import os, re, sys, signal | 8 import os, re, sys, signal |
9 import fancyopts, ui, hg | 9 import fancyopts, ui, hg |
10 from demandload import * | 10 from demandload import * |
11 demandload(globals(), "mdiff time hgweb traceback random signal errno") | 11 demandload(globals(), "mdiff time hgweb traceback random signal errno version") |
12 | 12 |
13 class UnknownCommand(Exception): pass | 13 class UnknownCommand(Exception): pass |
14 | 14 |
15 def filterfiles(filters, files): | 15 def filterfiles(filters, files): |
16 l = [ x for x in files if x in filters ] | 16 l = [ x for x in files if x in filters ] |
132 ui.status("\n") | 132 ui.status("\n") |
133 else: | 133 else: |
134 ui.status("summary: %s\n" % description.splitlines()[0]) | 134 ui.status("summary: %s\n" % description.splitlines()[0]) |
135 ui.status("\n") | 135 ui.status("\n") |
136 | 136 |
137 def show_version(ui): | |
138 """output version and copyright information""" | |
139 ui.write("Mercurial version %s\n" % version.get_version()) | |
140 ui.status( | |
141 "\nCopyright (C) 2005 Matt Mackall <mpm@selenic.com>\n" | |
142 "This is free software; see the source for copying conditions. " | |
143 "There is NO\nwarranty; " | |
144 "not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n" | |
145 ) | |
146 | |
137 def help(ui, cmd=None): | 147 def help(ui, cmd=None): |
138 '''show help for a given command or all commands''' | 148 '''show help for a given command or all commands''' |
139 if cmd: | 149 if cmd: |
140 try: | 150 try: |
141 i = find(cmd) | 151 i = find(cmd) |
154 ui.write(i[0].__doc__, "\n") | 164 ui.write(i[0].__doc__, "\n") |
155 except UnknownCommand: | 165 except UnknownCommand: |
156 ui.warn("hg: unknown command %s\n" % cmd) | 166 ui.warn("hg: unknown command %s\n" % cmd) |
157 sys.exit(0) | 167 sys.exit(0) |
158 else: | 168 else: |
159 ui.status('hg commands:\n\n') | 169 if not ui.quiet: |
170 show_version(ui) | |
171 ui.write('\n') | |
172 ui.write('hg commands:\n\n') | |
160 | 173 |
161 h = {} | 174 h = {} |
162 for e in table.values(): | 175 for e in table.values(): |
163 f = e[0] | 176 f = e[0] |
164 if f.__name__.startswith("debug"): continue | 177 if f.__name__.startswith("debug"): continue |
169 | 182 |
170 fns = h.keys() | 183 fns = h.keys() |
171 fns.sort() | 184 fns.sort() |
172 m = max(map(len, fns)) | 185 m = max(map(len, fns)) |
173 for f in fns: | 186 for f in fns: |
174 ui.status(' %-*s %s\n' % (m, f, h[f])) | 187 ui.write(' %-*s %s\n' % (m, f, h[f])) |
175 | 188 |
176 # Commands start here, listed alphabetically | 189 # Commands start here, listed alphabetically |
177 | 190 |
178 def add(ui, repo, file, *files): | 191 def add(ui, repo, file, *files): |
179 '''add the specified files on the next commit''' | 192 '''add the specified files on the next commit''' |
677 'overwrite locally modified files')], | 690 'overwrite locally modified files')], |
678 'hg update [options] [node]'), | 691 'hg update [options] [node]'), |
679 "verify": (verify, [], 'hg verify'), | 692 "verify": (verify, [], 'hg verify'), |
680 } | 693 } |
681 | 694 |
682 norepo = "init branch help debugindex debugindexdot" | 695 norepo = "init version help debugindex debugindexdot" |
683 | 696 |
684 def find(cmd): | 697 def find(cmd): |
685 i = None | 698 i = None |
686 for e in table.keys(): | 699 for e in table.keys(): |
687 if re.match("(%s)$" % e, cmd): | 700 if re.match("(%s)$" % e, cmd): |
702 opts = [('v', 'verbose', None, 'verbose'), | 715 opts = [('v', 'verbose', None, 'verbose'), |
703 ('d', 'debug', None, 'debug'), | 716 ('d', 'debug', None, 'debug'), |
704 ('q', 'quiet', None, 'quiet'), | 717 ('q', 'quiet', None, 'quiet'), |
705 ('p', 'profile', None, 'profile'), | 718 ('p', 'profile', None, 'profile'), |
706 ('y', 'noninteractive', None, 'run non-interactively'), | 719 ('y', 'noninteractive', None, 'run non-interactively'), |
720 ('', 'version', None, 'output version information and exit'), | |
707 ] | 721 ] |
708 | 722 |
709 args = fancyopts.fancyopts(args, opts, options, | 723 args = fancyopts.fancyopts(args, opts, options, |
710 'hg [options] <command> [options] [files]') | 724 'hg [options] <command> [options] [files]') |
711 | 725 |
714 else: | 728 else: |
715 cmd, args = args[0], args[1:] | 729 cmd, args = args[0], args[1:] |
716 | 730 |
717 u = ui.ui(options["verbose"], options["debug"], options["quiet"], | 731 u = ui.ui(options["verbose"], options["debug"], options["quiet"], |
718 not options["noninteractive"]) | 732 not options["noninteractive"]) |
733 | |
734 if options["version"]: | |
735 show_version(u) | |
736 sys.exit(0) | |
719 | 737 |
720 try: | 738 try: |
721 i = find(cmd) | 739 i = find(cmd) |
722 except UnknownCommand: | 740 except UnknownCommand: |
723 u.warn("hg: unknown command '%s'\n" % cmd) | 741 u.warn("hg: unknown command '%s'\n" % cmd) |