localrepo: change aftertrans to be independant of the store path
authorBenoit Boissinot <benoit.boissinot@ens-lyon.org>
Tue, 05 Dec 2006 11:28:21 +0100
changeset 3790 f183c18568df
parent 3789 734b1d6ba3dc
child 3791 8643b9f90b51
localrepo: change aftertrans to be independant of the store path
mercurial/localrepo.py
--- a/mercurial/localrepo.py	Tue Dec 05 11:23:37 2006 +0100
+++ b/mercurial/localrepo.py	Tue Dec 05 11:28:21 2006 +0100
@@ -483,9 +483,11 @@
             ds = ""
         self.opener("journal.dirstate", "w").write(ds)
 
+        renames = [(self.sjoin("journal"), self.sjoin("undo")),
+                   (self.join("journal.dirstate"), self.join("undo.dirstate"))]
         tr = transaction.transaction(self.ui.warn, self.sopener,
                                        self.sjoin("journal"),
-                                       aftertrans(self.path))
+                                       aftertrans(renames))
         self.transhandle = tr
         return tr
 
@@ -1897,12 +1899,11 @@
         return self.pull(remote, heads)
 
 # used to avoid circular references so destructors work
-def aftertrans(base):
-    p = base
+def aftertrans(files):
+    renamefiles = [tuple(t) for t in files]
     def a():
-        util.rename(os.path.join(p, "journal"), os.path.join(p, "undo"))
-        util.rename(os.path.join(p, "journal.dirstate"),
-                    os.path.join(p, "undo.dirstate"))
+        for src, dest in renamefiles:
+            util.rename(src, dest)
     return a
 
 def instance(ui, path, create):