From 76e8469c0d7ebea6c31655892cc4521b7662f1c6 Mon Sep 17 00:00:00 2001 From: Adrian Buehlmann Date: Tue, 15 Feb 2011 14:41:49 +0100 Subject: [PATCH] transaction: use posixfile and unlink from util instead of open() and os.unlink() Avoids potential issues with file access on Windows (e.g. AV-scanners). --- mercurial/transaction.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/mercurial/transaction.py b/mercurial/transaction.py index a1fd2f3da2..d19729511d 100644 --- a/mercurial/transaction.py +++ b/mercurial/transaction.py @@ -13,7 +13,7 @@ from i18n import _ import os, errno -import error +import error, util def active(func): def _active(self, *args, **kwds): @@ -38,11 +38,11 @@ def _playback(journal, report, opener, entries, unlink=True): fp = opener(f) fn = fp.name fp.close() - os.unlink(fn) + util.unlink(fn) except (IOError, OSError), inst: if inst.errno != errno.ENOENT: raise - os.unlink(journal) + util.unlink(journal) class transaction(object): def __init__(self, report, opener, journal, after=None, createmode=None): @@ -56,7 +56,7 @@ class transaction(object): self.journal = journal self._queue = [] - self.file = open(self.journal, "w") + self.file = util.posixfile(self.journal, "w") if createmode is not None: os.chmod(self.journal, createmode & 0666) @@ -137,7 +137,7 @@ class transaction(object): if self.after: self.after() if os.path.isfile(self.journal): - os.unlink(self.journal) + util.unlink(self.journal) self.journal = None @active @@ -155,7 +155,7 @@ class transaction(object): try: if not self.entries: if self.journal: - os.unlink(self.journal) + util.unlink(self.journal) return self.report(_("transaction abort!\n")) @@ -173,7 +173,7 @@ class transaction(object): def rollback(opener, file, report): entries = [] - fp = open(file) + fp = util.posixfile(file) lines = fp.readlines() fp.close() for l in lines: