changeset 20087:cf3b8285af00

transaction: take journal file path relative to vfs to use file API via vfs
author FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
date Tue, 12 Nov 2013 16:23:52 +0900
parents f3df2612f3c3
children 7cbb79bddee7
files mercurial/localrepo.py mercurial/transaction.py
diffstat 2 files changed, 12 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/localrepo.py	Tue Nov 12 16:23:52 2013 +0900
+++ b/mercurial/localrepo.py	Tue Nov 12 16:23:52 2013 +0900
@@ -833,7 +833,7 @@
         renames = [(vfs, x, undoname(x)) for vfs, x in self._journalfiles()]
         rp = report and report or self.ui.warn
         tr = transaction.transaction(rp, self.sopener,
-                                     self.sjoin("journal"),
+                                     "journal",
                                      aftertrans(renames),
                                      self.store.createmode)
         self._transref = weakref.ref(tr)
@@ -867,7 +867,7 @@
         try:
             if self.svfs.exists("journal"):
                 self.ui.status(_("rolling back interrupted transaction\n"))
-                transaction.rollback(self.sopener, self.sjoin("journal"),
+                transaction.rollback(self.sopener, "journal",
                                      self.ui.warn)
                 self.invalidate()
                 return True
@@ -923,7 +923,7 @@
 
         parents = self.dirstate.parents()
         self.destroying()
-        transaction.rollback(self.sopener, self.sjoin('undo'), ui.warn)
+        transaction.rollback(self.sopener, 'undo', ui.warn)
         if self.vfs.exists('undo.bookmarks'):
             self.vfs.rename('undo.bookmarks', 'bookmarks')
         if self.svfs.exists('undo.phaseroots'):
--- a/mercurial/transaction.py	Tue Nov 12 16:23:52 2013 +0900
+++ b/mercurial/transaction.py	Tue Nov 12 16:23:52 2013 +0900
@@ -12,8 +12,8 @@
 # GNU General Public License version 2 or any later version.
 
 from i18n import _
-import os, errno
-import error, util
+import errno
+import error
 
 def active(func):
     def _active(self, *args, **kwds):
@@ -39,7 +39,7 @@
             except (IOError, OSError), inst:
                 if inst.errno != errno.ENOENT:
                     raise
-    util.unlink(journal)
+    opener.unlink(journal)
 
 class transaction(object):
     def __init__(self, report, opener, journal, after=None, createmode=None):
@@ -53,9 +53,9 @@
         self.journal = journal
         self._queue = []
 
-        self.file = util.posixfile(self.journal, "w")
+        self.file = opener.open(self.journal, "w")
         if createmode is not None:
-            os.chmod(self.journal, createmode & 0666)
+            opener.chmod(self.journal, createmode & 0666)
 
     def __del__(self):
         if self.journal:
@@ -133,8 +133,8 @@
         self.entries = []
         if self.after:
             self.after()
-        if os.path.isfile(self.journal):
-            util.unlink(self.journal)
+        if self.opener.isfile(self.journal):
+            self.opener.unlink(self.journal)
         self.journal = None
 
     @active
@@ -152,7 +152,7 @@
         try:
             if not self.entries:
                 if self.journal:
-                    util.unlink(self.journal)
+                    self.opener.unlink(self.journal)
                 return
 
             self.report(_("transaction abort!\n"))
@@ -170,7 +170,7 @@
 def rollback(opener, file, report):
     entries = []
 
-    fp = util.posixfile(file)
+    fp = opener.open(file)
     lines = fp.readlines()
     fp.close()
     for l in lines: