changeset 251:3fd8fc14b12f

backup dirstate for undo -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 backup dirstate for undo manifest hash: 2999407c1f8999e91ba0e23828cb406803b364a5 -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.0 (GNU/Linux) iD8DBQFCojXDywK+sNU5EO8RAotIAKC3P3Oz+9n/EgqkFc0UMTlUErSNAQCgpjYm hpuZlC4lNO6aRiDfPVDL8Cw= =DDtT -----END PGP SIGNATURE-----
author mpm@selenic.com
date Sat, 04 Jun 2005 15:14:11 -0800
parents 45ee7c4cae4f
children 5eda6c542978
files mercurial/hg.py
diffstat 1 files changed, 6 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/hg.py	Sat Jun 04 14:25:08 2005 -0800
+++ b/mercurial/hg.py	Sat Jun 04 15:14:11 2005 -0800
@@ -354,6 +354,9 @@
         return filelog(self.opener, f)
 
     def transaction(self):
+        # save dirstate for undo
+        ds = self.opener("dirstate").read()
+        self.opener("undo.dirstate", "w").write(ds)
         return transaction(self.opener, self.join("journal"),
                            self.join("undo"))
 
@@ -368,19 +371,11 @@
     def undo(self):
         lock = self.lock()
         if os.path.exists(self.join("undo")):
-            f = self.changelog.read(self.changelog.tip())[3]
             self.ui.status("attempting to rollback last transaction\n")
             rollback(self.opener, self.join("undo"))
-            self.manifest = manifest(self.opener)
-            self.changelog = changelog(self.opener)
-
-            self.ui.status("discarding dirstate\n")
-            node = self.changelog.tip()
-            f.sort()
-
-            self.dirstate.setparents(node)
-            self.dirstate.update(f, 'i')
-        
+            self.dirstate = None
+            os.rename(self.join("undo.dirstate"), self.join("dirstate"))
+            self.dirstate = dirstate(self.opener, self.ui, self.root)
         else:
             self.ui.warn("no undo information available\n")