Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/commands.py @ 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 |
---|---|
149 def branch(ui, path): | 149 def branch(ui, path): |
150 '''branch from a local repository''' | 150 '''branch from a local repository''' |
151 # this should eventually support remote repos | 151 # this should eventually support remote repos |
152 os.system("cp -al %s/.hg .hg" % path) | 152 os.system("cp -al %s/.hg .hg" % path) |
153 | 153 |
154 def cat(ui, repo, file, rev = []): | |
155 r = repo.file(file) | |
156 n = r.tip() | |
157 if rev: n = r.lookup(rev) | |
158 sys.stdout.write(r.read(n)) | |
159 | |
154 def checkout(ui, repo, changeset=None): | 160 def checkout(ui, repo, changeset=None): |
155 '''checkout a given changeset or the current tip''' | 161 '''checkout a given changeset or the current tip''' |
156 (c, a, d, u) = repo.diffdir(repo.root) | 162 (c, a, d, u) = repo.diffdir(repo.root) |
157 if c or a or d: | 163 if c or a or d: |
158 ui.warn("aborting (outstanding changes in working directory)\n") | 164 ui.warn("aborting (outstanding changes in working directory)\n") |
164 repo.checkout(node) | 170 repo.checkout(node) |
165 | 171 |
166 def commit(ui, repo, *files): | 172 def commit(ui, repo, *files): |
167 """commit the specified files or all outstanding changes""" | 173 """commit the specified files or all outstanding changes""" |
168 repo.commit(relpath(repo, files)) | 174 repo.commit(relpath(repo, files)) |
175 | |
176 def debugaddchangegroup(ui, repo): | |
177 data = sys.stdin.read() | |
178 repo.addchangegroup(data) | |
179 | |
180 def debugchangegroup(ui, repo, roots): | |
181 newer = repo.newer(map(repo.lookup, roots)) | |
182 for chunk in repo.changegroup(newer): | |
183 sys.stdout.write(chunk) | |
184 | |
185 def debugindex(ui, file): | |
186 r = hg.revlog(open, file, "") | |
187 print " rev offset length base linkrev"+\ | |
188 " p1 p2 nodeid" | |
189 for i in range(r.count()): | |
190 e = r.index[i] | |
191 print "% 6d % 9d % 7d % 6d % 7d %s.. %s.. %s.." % ( | |
192 i, e[0], e[1], e[2], e[3], | |
193 hg.hex(e[4][:5]), hg.hex(e[5][:5]), hg.hex(e[6][:5])) | |
194 | |
195 def debugindexdot(ui, file): | |
196 r = hg.revlog(open, file, "") | |
197 print "digraph G {" | |
198 for i in range(r.count()): | |
199 e = r.index[i] | |
200 print "\t%d -> %d" % (r.rev(e[4]), i) | |
201 if e[5] != hg.nullid: | |
202 print "\t%d -> %d" % (r.rev(e[5]), i) | |
203 print "}" | |
169 | 204 |
170 def diff(ui, repo, *files, **opts): | 205 def diff(ui, repo, *files, **opts): |
171 revs = [] | 206 revs = [] |
172 if opts['rev']: | 207 if opts['rev']: |
173 revs = map(lambda x: repo.lookup(x), opts['rev']) | 208 revs = map(lambda x: repo.lookup(x), opts['rev']) |
298 time.localtime(float(changes[2].split(' ')[0]))) | 333 time.localtime(float(changes[2].split(' ')[0]))) |
299 print "description:" | 334 print "description:" |
300 print changes[4].rstrip() | 335 print changes[4].rstrip() |
301 print | 336 print |
302 | 337 |
338 def manifest(ui, repo, rev = []): | |
339 n = repo.manifest.tip() | |
340 if rev: | |
341 n = repo.manifest.lookup(rev) | |
342 m = repo.manifest.read(n) | |
343 files = m.keys() | |
344 files.sort() | |
345 | |
346 for f in files: | |
347 print hg.hex(m[f]), f | |
348 | |
303 def parents(ui, repo, node = None): | 349 def parents(ui, repo, node = None): |
304 '''show the parents of the current working dir''' | 350 '''show the parents of the current working dir''' |
305 if node: | 351 if node: |
306 p = repo.changelog.parents(repo.lookup(hg.bin(node))) | 352 p = repo.changelog.parents(repo.lookup(hg.bin(node))) |
307 else: | 353 else: |
379 for f in c: print "C", f | 425 for f in c: print "C", f |
380 for f in a: print "A", f | 426 for f in a: print "A", f |
381 for f in d: print "R", f | 427 for f in d: print "R", f |
382 for f in u: print "?", f | 428 for f in u: print "?", f |
383 | 429 |
430 def tags(ui, repo): | |
431 repo.lookup(0) # prime the cache | |
432 i = repo.tags.items() | |
433 i.sort() | |
434 for k, n in i: | |
435 try: | |
436 r = repo.changelog.rev(n) | |
437 except KeyError: | |
438 r = "?" | |
439 print "%-30s %5d:%s" % (k, repo.changelog.rev(n), hg.hex(n)) | |
440 | |
384 def tip(ui, repo): | 441 def tip(ui, repo): |
385 n = repo.changelog.tip() | 442 n = repo.changelog.tip() |
386 t = repo.changelog.rev(n) | 443 t = repo.changelog.rev(n) |
387 ui.status("%d:%s\n" % (t, hg.hex(n))) | 444 ui.status("%d:%s\n" % (t, hg.hex(n))) |
388 | 445 |
401 ('u', 'user', None, 'show user'), | 458 ('u', 'user', None, 'show user'), |
402 ('n', 'number', None, 'show revision number'), | 459 ('n', 'number', None, 'show revision number'), |
403 ('c', 'changeset', None, 'show changeset')], | 460 ('c', 'changeset', None, 'show changeset')], |
404 'hg annotate [-u] [-c] [-n] [-r id] [files]'), | 461 'hg annotate [-u] [-c] [-n] [-r id] [files]'), |
405 "branch|clone": (branch, [], 'hg branch [path]'), | 462 "branch|clone": (branch, [], 'hg branch [path]'), |
463 "cat|dump": (cat, [], 'hg cat <file> [rev]'), | |
406 "checkout|co": (checkout, [], 'hg checkout [changeset]'), | 464 "checkout|co": (checkout, [], 'hg checkout [changeset]'), |
407 "commit|ci": (commit, [], 'hg commit [files]'), | 465 "commit|ci": (commit, [], 'hg commit [files]'), |
466 "debugaddchangegroup": (debugaddchangegroup, [], 'debugaddchangegroup'), | |
467 "debugchangegroup": (debugchangegroup, [], 'debugchangegroup [roots]'), | |
468 "debugindex": (debugindex, [], 'debugindex <file>'), | |
469 "debugindexdot": (debugindexdot, [], 'debugindexdot <file>'), | |
408 "diff": (diff, [('r', 'rev', [], 'revision')], | 470 "diff": (diff, [('r', 'rev', [], 'revision')], |
409 'hg diff [-r A] [-r B] [files]'), | 471 'hg diff [-r A] [-r B] [files]'), |
410 "export": (export, [], "hg export <changeset>"), | 472 "export": (export, [], "hg export <changeset>"), |
411 "forget": (forget, [], "hg forget [files]"), | 473 "forget": (forget, [], "hg forget [files]"), |
412 "heads": (heads, [], 'hg heads'), | 474 "heads": (heads, [], 'hg heads'), |
413 "history": (history, [], 'hg history'), | 475 "history": (history, [], 'hg history'), |
414 "help": (help, [], 'hg help [command]'), | 476 "help": (help, [], 'hg help [command]'), |
415 "init": (init, [], 'hg init'), | 477 "init": (init, [], 'hg init'), |
416 "log": (log, [], 'hg log <file>'), | 478 "log": (log, [], 'hg log <file>'), |
479 "manifest|dumpmanifest": (manifest, [], 'hg manifest [rev]'), | |
417 "parents": (parents, [], 'hg parents [node]'), | 480 "parents": (parents, [], 'hg parents [node]'), |
418 "patch|import": (patch, | 481 "patch|import": (patch, |
419 [('p', 'strip', 1, 'path strip'), | 482 [('p', 'strip', 1, 'path strip'), |
420 ('b', 'base', "", 'base path'), | 483 ('b', 'base', "", 'base path'), |
421 ('q', 'quiet', "", 'silence diff')], | 484 ('q', 'quiet', "", 'silence diff')], |
436 ('a', 'address', '', 'interface address'), | 499 ('a', 'address', '', 'interface address'), |
437 ('n', 'name', os.getcwd(), 'repository name'), | 500 ('n', 'name', os.getcwd(), 'repository name'), |
438 ('t', 'templates', "", 'template map')], | 501 ('t', 'templates', "", 'template map')], |
439 "hg serve [options]"), | 502 "hg serve [options]"), |
440 "status": (status, [], 'hg status'), | 503 "status": (status, [], 'hg status'), |
504 "tags": (tags, [], 'hg tags'), | |
441 "tip": (tip, [], 'hg tip'), | 505 "tip": (tip, [], 'hg tip'), |
442 "undo": (undo, [], 'hg undo'), | 506 "undo": (undo, [], 'hg undo'), |
443 "verify": (verify, [], 'hg verify'), | 507 "verify": (verify, [], 'hg verify'), |
444 } | 508 } |
445 | 509 |
446 norepo = "init branch help" | 510 norepo = "init branch help debugindex debugindexdot" |
447 | 511 |
448 def find(cmd): | 512 def find(cmd): |
449 i = None | 513 i = None |
450 for e in table.keys(): | 514 for e in table.keys(): |
451 if re.match(e + "$", cmd): | 515 if re.match(e + "$", cmd): |