162 r = repo.file(file) |
162 r = repo.file(file) |
163 n = r.tip() |
163 n = r.tip() |
164 if rev: n = r.lookup(rev) |
164 if rev: n = r.lookup(rev) |
165 sys.stdout.write(r.read(n)) |
165 sys.stdout.write(r.read(n)) |
166 |
166 |
167 def checkout(ui, repo, changeset=None): |
|
168 '''checkout a given changeset or the current tip''' |
|
169 (c, a, d, u) = repo.diffdir(repo.root) |
|
170 if c or a or d: |
|
171 ui.warn("aborting (outstanding changes in working directory)\n") |
|
172 sys.exit(1) |
|
173 |
|
174 node = repo.changelog.tip() |
|
175 if changeset: |
|
176 node = repo.lookup(changeset) |
|
177 repo.checkout(node) |
|
178 |
|
179 def commit(ui, repo, *files): |
167 def commit(ui, repo, *files): |
180 """commit the specified files or all outstanding changes""" |
168 """commit the specified files or all outstanding changes""" |
181 repo.commit(relpath(repo, files)) |
169 repo.commit(relpath(repo, files)) |
182 |
170 |
183 def debugaddchangegroup(ui, repo): |
171 def debugaddchangegroup(ui, repo): |
403 |
391 |
404 def remove(ui, repo, file, *files): |
392 def remove(ui, repo, file, *files): |
405 """remove the specified files on the next commit""" |
393 """remove the specified files on the next commit""" |
406 repo.remove(relpath(repo, (file,) + files)) |
394 repo.remove(relpath(repo, (file,) + files)) |
407 |
395 |
408 def resolve(ui, repo, node=None): |
|
409 '''merge a given node or the current tip into the working dir''' |
|
410 if not node: |
|
411 node = repo.changelog.tip() |
|
412 else: |
|
413 node = repo.lookup(node) |
|
414 repo.resolve(node) |
|
415 |
|
416 def serve(ui, repo, **opts): |
396 def serve(ui, repo, **opts): |
417 from mercurial import hgweb |
397 from mercurial import hgweb |
418 hgweb.server(repo.root, opts["name"], opts["templates"], |
398 hgweb.server(repo.root, opts["name"], opts["templates"], |
419 opts["address"], opts["port"]) |
399 opts["address"], opts["port"]) |
420 |
400 |
450 t = repo.changelog.rev(n) |
430 t = repo.changelog.rev(n) |
451 ui.status("%d:%s\n" % (t, hg.hex(n))) |
431 ui.status("%d:%s\n" % (t, hg.hex(n))) |
452 |
432 |
453 def undo(ui, repo): |
433 def undo(ui, repo): |
454 repo.undo() |
434 repo.undo() |
|
435 |
|
436 def update(ui, repo, node=None): |
|
437 '''update or merge working directory |
|
438 |
|
439 If there are no outstanding changes in the working directory and |
|
440 there is a linear relationship between the current version and the |
|
441 requested version, the result is the requested version. |
|
442 |
|
443 Otherwise the result is a merge between the contents of the |
|
444 current working directory and the requested version. Files that |
|
445 changed between either parent are marked as changed for the next |
|
446 commit and a commit must be performed before any further updates |
|
447 are allowed. |
|
448 ''' |
|
449 node = node and repo.lookup(node) or repo.changelog.tip() |
|
450 repo.update(node) |
455 |
451 |
456 def verify(ui, repo): |
452 def verify(ui, repo): |
457 """verify the integrity of the repository""" |
453 """verify the integrity of the repository""" |
458 return repo.verify() |
454 return repo.verify() |
459 |
455 |
466 ('n', 'number', None, 'show revision number'), |
462 ('n', 'number', None, 'show revision number'), |
467 ('c', 'changeset', None, 'show changeset')], |
463 ('c', 'changeset', None, 'show changeset')], |
468 'hg annotate [-u] [-c] [-n] [-r id] [files]'), |
464 'hg annotate [-u] [-c] [-n] [-r id] [files]'), |
469 "branch|clone": (branch, [], 'hg branch [path]'), |
465 "branch|clone": (branch, [], 'hg branch [path]'), |
470 "cat|dump": (cat, [], 'hg cat <file> [rev]'), |
466 "cat|dump": (cat, [], 'hg cat <file> [rev]'), |
471 "checkout|co": (checkout, [], 'hg checkout [changeset]'), |
|
472 "commit|ci": (commit, [], 'hg commit [files]'), |
467 "commit|ci": (commit, [], 'hg commit [files]'), |
473 "debugaddchangegroup": (debugaddchangegroup, [], 'debugaddchangegroup'), |
468 "debugaddchangegroup": (debugaddchangegroup, [], 'debugaddchangegroup'), |
474 "debugchangegroup": (debugchangegroup, [], 'debugchangegroup [roots]'), |
469 "debugchangegroup": (debugchangegroup, [], 'debugchangegroup [roots]'), |
475 "debugindex": (debugindex, [], 'debugindex <file>'), |
470 "debugindex": (debugindex, [], 'debugindex <file>'), |
476 "debugindexdot": (debugindexdot, [], 'debugindexdot <file>'), |
471 "debugindexdot": (debugindexdot, [], 'debugindexdot <file>'), |
499 ('t', 'text', "", 'commit text'), |
494 ('t', 'text', "", 'commit text'), |
500 ('l', 'logfile', "", 'commit text file')], |
495 ('l', 'logfile', "", 'commit text file')], |
501 'hg rawcommit [options] [files]'), |
496 'hg rawcommit [options] [files]'), |
502 "recover": (recover, [], "hg recover"), |
497 "recover": (recover, [], "hg recover"), |
503 "remove": (remove, [], "hg remove [files]"), |
498 "remove": (remove, [], "hg remove [files]"), |
504 "resolve": (resolve, [], 'hg resolve [node]'), |
|
505 "serve": (serve, [('p', 'port', 8000, 'listen port'), |
499 "serve": (serve, [('p', 'port', 8000, 'listen port'), |
506 ('a', 'address', '', 'interface address'), |
500 ('a', 'address', '', 'interface address'), |
507 ('n', 'name', os.getcwd(), 'repository name'), |
501 ('n', 'name', os.getcwd(), 'repository name'), |
508 ('t', 'templates', "", 'template map')], |
502 ('t', 'templates', "", 'template map')], |
509 "hg serve [options]"), |
503 "hg serve [options]"), |
510 "status": (status, [], 'hg status'), |
504 "status": (status, [], 'hg status'), |
511 "tags": (tags, [], 'hg tags'), |
505 "tags": (tags, [], 'hg tags'), |
512 "tip": (tip, [], 'hg tip'), |
506 "tip": (tip, [], 'hg tip'), |
513 "undo": (undo, [], 'hg undo'), |
507 "undo": (undo, [], 'hg undo'), |
|
508 "update|up|checkout|co|resolve": (update, [], 'hg update [node]'), |
514 "verify": (verify, [], 'hg verify'), |
509 "verify": (verify, [], 'hg verify'), |
515 } |
510 } |
516 |
511 |
517 norepo = "init branch help debugindex debugindexdot" |
512 norepo = "init branch help debugindex debugindexdot" |
518 |
513 |