Mercurial > public > mercurial-scm > hg-stable
diff mercurial/localrepo.py @ 1447:508a3f559553
revert added and removed files to their normal state before reverting
add a test for revert
author | Benoit Boissinot <benoit.boissinot@ens-lyon.org> |
---|---|
date | Tue, 25 Oct 2005 15:51:28 -0700 |
parents | 0980d77f5e9a |
children | 182879d71922 |
line wrap: on
line diff
--- a/mercurial/localrepo.py Tue Oct 25 14:58:11 2005 -0700 +++ b/mercurial/localrepo.py Tue Oct 25 15:51:28 2005 -0700 @@ -555,6 +555,30 @@ else: self.dirstate.update([f], "r") + def undelete(self, list): + pl = self.dirstate.parents() + if pl[1] != nullid: + self.ui.warn("aborting: outstanding uncommitted merges\n") + return 1 + p = pl[0] + mn = self.changelog.read(p)[0] + mf = self.manifest.readflags(mn) + m = self.manifest.read(mn) + for f in list: + if self.dirstate.state(f) not in "r": + self.ui.warn("%s not removed!\n" % f) + else: + t = self.file(f).read(m[f]) + try: + self.wwrite(f, t) + except IOError, e: + if e.errno != errno.ENOENT: + raise + os.makedirs(os.path.dirname(self.wjoin(f))) + self.wwrite(f, t) + util.set_exec(self.wjoin(f), mf[f]) + self.dirstate.update([f], "n") + def copy(self, source, dest): p = self.wjoin(dest) if not os.path.exists(p):