comparison mercurial/commands.py @ 590:38d106db75bc

hg revert should revert to parent, not to tip -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 hg revert should revert to parent, not to tip manifest hash: b6b622d0316f9f7ef60e500fb73844a4b0ad7b69 -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.0 (GNU/Linux) iD8DBQFCx27VywK+sNU5EO8RAnpHAKC1H3GAPC5wYlgpJG7Z7rWPl+vblQCeKVsz UCjkaDw40evLbltWoY24xQs= =dmvS -----END PGP SIGNATURE-----
author mpm@selenic.com
date Sat, 02 Jul 2005 20:51:33 -0800
parents 0c3bae18403b
children eb46971fc57f
comparison
equal deleted inserted replaced
589:4be4d4580467 590:38d106db75bc
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):]