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']) |
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): |