Mercurial > hg
changeset 13408:19ad316e5be3
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).
author | Adrian Buehlmann <adrian@cadifra.com> |
---|---|
date | Tue, 15 Feb 2011 14:41:49 +0100 |
parents | 354f304152ad |
children | 9e5df8719ad4 |
files | mercurial/transaction.py |
diffstat | 1 files changed, 7 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/transaction.py Mon Feb 14 23:59:21 2011 -0600 +++ b/mercurial/transaction.py Tue Feb 15 14:41:49 2011 +0100 @@ -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 @@ 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 @@ 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 @@ 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 @@ 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 @@ def rollback(opener, file, report): entries = [] - fp = open(file) + fp = util.posixfile(file) lines = fp.readlines() fp.close() for l in lines: