Mercurial > hg
comparison 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 |
comparison
equal
deleted
inserted
replaced
428:183c87d4e1a0 | 429:688d03d6997a |
---|---|
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, util | 9 import fancyopts, ui, hg, util |
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''' |
722 'overwrite locally modified files')], | 735 'overwrite locally modified files')], |
723 'hg update [options] [node]'), | 736 'hg update [options] [node]'), |
724 "verify": (verify, [], 'hg verify'), | 737 "verify": (verify, [], 'hg verify'), |
725 } | 738 } |
726 | 739 |
727 norepo = "init branch help debugindex debugindexdot" | 740 norepo = "init version help debugindex debugindexdot" |
728 | 741 |
729 def find(cmd): | 742 def find(cmd): |
730 i = None | 743 i = None |
731 for e in table.keys(): | 744 for e in table.keys(): |
732 if re.match("(%s)$" % e, cmd): | 745 if re.match("(%s)$" % e, cmd): |
747 opts = [('v', 'verbose', None, 'verbose'), | 760 opts = [('v', 'verbose', None, 'verbose'), |
748 ('d', 'debug', None, 'debug'), | 761 ('d', 'debug', None, 'debug'), |
749 ('q', 'quiet', None, 'quiet'), | 762 ('q', 'quiet', None, 'quiet'), |
750 ('p', 'profile', None, 'profile'), | 763 ('p', 'profile', None, 'profile'), |
751 ('y', 'noninteractive', None, 'run non-interactively'), | 764 ('y', 'noninteractive', None, 'run non-interactively'), |
765 ('', 'version', None, 'output version information and exit'), | |
752 ] | 766 ] |
753 | 767 |
754 args = fancyopts.fancyopts(args, opts, options, | 768 args = fancyopts.fancyopts(args, opts, options, |
755 'hg [options] <command> [options] [files]') | 769 'hg [options] <command> [options] [files]') |
756 | 770 |
759 else: | 773 else: |
760 cmd, args = args[0], args[1:] | 774 cmd, args = args[0], args[1:] |
761 | 775 |
762 u = ui.ui(options["verbose"], options["debug"], options["quiet"], | 776 u = ui.ui(options["verbose"], options["debug"], options["quiet"], |
763 not options["noninteractive"]) | 777 not options["noninteractive"]) |
778 | |
779 if options["version"]: | |
780 show_version(u) | |
781 sys.exit(0) | |
764 | 782 |
765 try: | 783 try: |
766 i = find(cmd) | 784 i = find(cmd) |
767 except UnknownCommand: | 785 except UnknownCommand: |
768 u.warn("hg: unknown command '%s'\n" % cmd) | 786 u.warn("hg: unknown command '%s'\n" % cmd) |