Mercurial > hg > pyhgsh
comparison hg @ 83:9fd5b35cfc45
Add -q quiet option
Make -d and -v do something
Add a bunch of debug and note messages
author | mpm@selenic.com |
---|---|
date | Tue, 17 May 2005 11:06:59 -0800 |
parents | 17884f79d59d |
children | b2b3fdbd79f4 |
comparison
equal
deleted
inserted
replaced
82:7ed96baa7caa | 83:9fd5b35cfc45 |
---|---|
87 tn = "" | 87 tn = "" |
88 sys.stdout.write(mdiff.unidiff(to, date1, tn, date2, f)) | 88 sys.stdout.write(mdiff.unidiff(to, date1, tn, date2, f)) |
89 | 89 |
90 options = {} | 90 options = {} |
91 opts = [('v', 'verbose', None, 'verbose'), | 91 opts = [('v', 'verbose', None, 'verbose'), |
92 ('d', 'debug', None, 'debug')] | 92 ('d', 'debug', None, 'debug'), |
93 ('q', 'quiet', None, 'quiet')] | |
93 | 94 |
94 args = fancyopts.fancyopts(sys.argv[1:], opts, options, | 95 args = fancyopts.fancyopts(sys.argv[1:], opts, options, |
95 'hg [options] <command> [command options] [files]') | 96 'hg [options] <command> [command options] [files]') |
96 | 97 |
97 try: | 98 try: |
98 cmd = args[0] | 99 cmd = args[0] |
99 args = args[1:] | 100 args = args[1:] |
100 except: | 101 except: |
101 cmd = "" | 102 cmd = "" |
102 | 103 |
103 ui = hg.ui(options["verbose"], options["debug"]) | 104 ui = hg.ui(options["verbose"], options["debug"], options["quiet"]) |
104 | 105 |
105 if cmd == "init": | 106 if cmd == "init": |
106 repo = hg.repository(ui, ".", create=1) | 107 repo = hg.repository(ui, ".", create=1) |
107 sys.exit(0) | 108 sys.exit(0) |
108 elif cmd == "branch" or cmd == "clone": | 109 elif cmd == "branch" or cmd == "clone": |
113 sys.exit(0) | 114 sys.exit(0) |
114 else: | 115 else: |
115 try: | 116 try: |
116 repo = hg.repository(ui=ui) | 117 repo = hg.repository(ui=ui) |
117 except IOError: | 118 except IOError: |
118 print "Unable to open repository" | 119 ui.warn("Unable to open repository\n") |
119 sys.exit(0) | 120 sys.exit(0) |
120 | 121 |
121 if cmd == "checkout" or cmd == "co": | 122 if cmd == "checkout" or cmd == "co": |
122 node = repo.changelog.tip() | 123 node = repo.changelog.tip() |
123 if args: | 124 if args: |
174 raise "patch failed!" | 175 raise "patch failed!" |
175 repo.commit(repo.current, files, text) | 176 repo.commit(repo.current, files, text) |
176 | 177 |
177 elif cmd == "status": | 178 elif cmd == "status": |
178 (c, a, d) = repo.diffdir(repo.root, repo.current) | 179 (c, a, d) = repo.diffdir(repo.root, repo.current) |
179 for f in c: print "C", f | 180 for f in c: ui.status("C %s\n" % f) |
180 for f in a: print "?", f | 181 for f in a: ui.status("? %s\n" % f) |
181 for f in d: print "R", f | 182 for f in d: ui.status("R %s\n" % f) |
182 | 183 |
183 elif cmd == "diff": | 184 elif cmd == "diff": |
184 revs = [] | 185 revs = [] |
185 | 186 |
186 if args: | 187 if args: |
189 args = fancyopts.fancyopts(args, opts, doptions, | 190 args = fancyopts.fancyopts(args, opts, doptions, |
190 'hg diff [options] [files]') | 191 'hg diff [options] [files]') |
191 revs = map(lambda x: repo.lookup(x), doptions['revision']) | 192 revs = map(lambda x: repo.lookup(x), doptions['revision']) |
192 | 193 |
193 if len(revs) > 2: | 194 if len(revs) > 2: |
194 print "too many revisions to diff" | 195 self.ui.warn("too many revisions to diff\n") |
195 sys.exit(1) | 196 sys.exit(1) |
196 | 197 |
197 if os.getcwd() != repo.root: | 198 if os.getcwd() != repo.root: |
198 relpath = os.getcwd()[len(repo.root) + 1: ] | 199 relpath = os.getcwd()[len(repo.root) + 1: ] |
199 if not args: args = [ relpath ] | 200 if not args: args = [ relpath ] |
341 hg.hex(e[4][:5]), hg.hex(e[5][:5]), hg.hex(e[6][:5])) | 342 hg.hex(e[4][:5]), hg.hex(e[5][:5]), hg.hex(e[6][:5])) |
342 | 343 |
343 elif cmd == "merge": | 344 elif cmd == "merge": |
344 if args: | 345 if args: |
345 other = hg.repository(ui, args[0]) | 346 other = hg.repository(ui, args[0]) |
346 print "requesting changegroup" | 347 ui.status("requesting changegroup") |
347 cg = repo.getchangegroup(other) | 348 cg = repo.getchangegroup(other) |
348 repo.addchangegroup(cg) | 349 repo.addchangegroup(cg) |
349 else: | 350 else: |
350 print "missing source repository" | 351 print "missing source repository" |
351 | 352 |