733 """remove the specified files on the next commit""" |
733 """remove the specified files on the next commit""" |
734 repo.remove(relpath(repo, (file,) + files)) |
734 repo.remove(relpath(repo, (file,) + files)) |
735 |
735 |
736 def revert(ui, repo, *names, **opts): |
736 def revert(ui, repo, *names, **opts): |
737 """revert modified files or dirs back to their unmodified states""" |
737 """revert modified files or dirs back to their unmodified states""" |
738 node = opts['rev'] and repo.lookup(opts['rev']) or repo.changelog.tip() |
738 node = opts['rev'] and repo.lookup(opts['rev']) or \ |
|
739 repo.dirstate.parents()[0] |
739 root = os.path.realpath(repo.root) |
740 root = os.path.realpath(repo.root) |
|
741 |
740 def trimpath(p): |
742 def trimpath(p): |
741 p = os.path.realpath(p) |
743 p = os.path.realpath(p) |
742 if p.startswith(root): |
744 if p.startswith(root): |
743 rest = p[len(root):] |
745 rest = p[len(root):] |
744 if not rest: |
746 if not rest: |
745 return rest |
747 return rest |
746 if p.startswith(os.sep): |
748 if p.startswith(os.sep): |
747 return rest[1:] |
749 return rest[1:] |
748 return p |
750 return p |
|
751 |
749 relnames = map(trimpath, names or [os.getcwd()]) |
752 relnames = map(trimpath, names or [os.getcwd()]) |
750 chosen = {} |
753 chosen = {} |
|
754 |
751 def choose(name): |
755 def choose(name): |
752 def body(name): |
756 def body(name): |
753 for r in relnames: |
757 for r in relnames: |
754 if not name.startswith(r): continue |
758 if not name.startswith(r): continue |
755 rest = name[len(r):] |
759 rest = name[len(r):] |