Mercurial > hg > pyhgsh
comparison hg @ 248:b7645b3c86ff
migrate remaining commands
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
migrate remaining commands
This removes basically everything from the top-level hg script
manifest hash: 34883e89d8def30e28936b38a9342d2f650f4c94
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.0 (GNU/Linux)
iD8DBQFCoiD7ywK+sNU5EO8RAh0cAKCeOO9vahYs0tGmMNKk8bflw35p2wCgr6Wr
y0SNLHSVBMCzXtC9zlfDPog=
=3nJx
-----END PGP SIGNATURE-----
author | mpm@selenic.com |
---|---|
date | Sat, 04 Jun 2005 13:45:31 -0800 |
parents | 863b508c5b36 |
children | 619e775aa7f9 |
comparison
equal
deleted
inserted
replaced
247:863b508c5b36 | 248:b7645b3c86ff |
---|---|
15 # psyco.full() | 15 # psyco.full() |
16 # except: | 16 # except: |
17 # pass | 17 # pass |
18 | 18 |
19 import sys | 19 import sys |
20 from mercurial import hg, fancyopts, ui, commands | 20 from mercurial import commands |
21 | 21 |
22 try: | 22 sys.exit(commands.dispatch(sys.argv[1:])) |
23 sys.exit(commands.dispatch(sys.argv[1:])) | |
24 except commands.UnknownCommand: | |
25 # fall through | |
26 pass | |
27 | 23 |
28 options = {} | |
29 opts = [('v', 'verbose', None, 'verbose'), | |
30 ('d', 'debug', None, 'debug'), | |
31 ('q', 'quiet', None, 'quiet'), | |
32 ('y', 'noninteractive', None, 'run non-interactively'), | |
33 ] | |
34 | |
35 args = fancyopts.fancyopts(sys.argv[1:], opts, options, | |
36 'hg [options] <command> [command options] [files]') | |
37 | |
38 try: | |
39 cmd = args[0] | |
40 args = args[1:] | |
41 except: | |
42 cmd = "help" | |
43 | |
44 ui = ui.ui(options["verbose"], options["debug"], options["quiet"], | |
45 not options["noninteractive"]) | |
46 | |
47 try: | |
48 repo = hg.repository(ui=ui) | |
49 except IOError: | |
50 ui.warn("Unable to open repository\n") | |
51 sys.exit(0) | |
52 | |
53 if cmd == "debugchangegroup": | |
54 newer = repo.newer(map(repo.lookup, args)) | |
55 for chunk in repo.changegroup(newer): | |
56 sys.stdout.write(chunk) | |
57 | |
58 elif cmd == "debugaddchangegroup": | |
59 data = sys.stdin.read() | |
60 repo.addchangegroup(data) | |
61 | |
62 elif cmd == "dump": | |
63 if args: | |
64 r = repo.file(args[0]) | |
65 n = r.tip() | |
66 if len(args) > 1: n = r.lookup(args[1]) | |
67 sys.stdout.write(r.read(n)) | |
68 else: | |
69 print "missing filename" | |
70 | |
71 elif cmd == "dumpmanifest": | |
72 n = repo.manifest.tip() | |
73 if len(args) > 0: | |
74 n = repo.manifest.lookup(args[0]) | |
75 m = repo.manifest.read(n) | |
76 files = m.keys() | |
77 files.sort() | |
78 | |
79 for f in files: | |
80 print hg.hex(m[f]), f | |
81 | |
82 elif cmd == "debugindex": | |
83 if ".hg" not in args[0]: | |
84 args[0] = ".hg/data/" + repo.file(args[0]).encodepath(args[0]) + "i" | |
85 | |
86 r = hg.revlog(open, args[0], "") | |
87 print " rev offset length base linkrev"+\ | |
88 " p1 p2 nodeid" | |
89 for i in range(r.count()): | |
90 e = r.index[i] | |
91 print "% 6d % 9d % 7d % 6d % 7d %s.. %s.. %s.." % ( | |
92 i, e[0], e[1], e[2], e[3], | |
93 hg.hex(e[4][:5]), hg.hex(e[5][:5]), hg.hex(e[6][:5])) | |
94 | |
95 elif cmd == "debugindexdot": | |
96 if ".hg" not in args[0]: | |
97 args[0] = ".hg/data/" + repo.file(args[0]).encodepath(args[0]) + "i" | |
98 | |
99 r = hg.revlog(open, args[0], "") | |
100 print "digraph G {" | |
101 for i in range(r.count()): | |
102 e = r.index[i] | |
103 print "\t%d -> %d" % (r.rev(e[4]), i) | |
104 if e[5] != hg.nullid: | |
105 print "\t%d -> %d" % (r.rev(e[5]), i) | |
106 print "}" | |
107 | |
108 elif cmd == "tags": | |
109 repo.lookup(0) # prime the cache | |
110 i = repo.tags.items() | |
111 i.sort() | |
112 for k, n in i: | |
113 try: | |
114 r = repo.changelog.rev(n) | |
115 except KeyError: | |
116 r = "?" | |
117 print "%-30s %5d:%s" % (k, repo.changelog.rev(n), hg.hex(n)) | |
118 | |
119 else: | |
120 if cmd: ui.warn("unknown command\n\n") | |
121 sys.exit(1) |