diff mercurial/transaction.py @ 39677:d27fde3e023e

transaction: make file a private attribute This holds a file handle for the journal file. This file handle should not be touched outside the journal class and doesn't belong on the public interface. Differential Revision: https://phab.mercurial-scm.org/D4625
author Gregory Szorc <gregory.szorc@gmail.com>
date Mon, 17 Sep 2018 15:57:32 -0700
parents 77c4e2ae9f07
children 040007cd3d81
line wrap: on
line diff
--- a/mercurial/transaction.py	Mon Sep 17 15:55:57 2018 -0700
+++ b/mercurial/transaction.py	Mon Sep 17 15:57:32 2018 -0700
@@ -157,7 +157,7 @@
 
         # a dict of arguments to be passed to hooks
         self.hookargs = {}
-        self.file = opener.open(self._journal, "w")
+        self._file = opener.open(self._journal, "w")
 
         # a list of ('location', 'path', 'backuppath', cache) entries.
         # - if 'backuppath' is empty, no file existed at backup time
@@ -233,8 +233,8 @@
         self.entries.append((file, offset, data))
         self.map[file] = len(self.entries) - 1
         # add enough data to the journal to do the truncate
-        self.file.write("%s\0%d\n" % (file, offset))
-        self.file.flush()
+        self._file.write("%s\0%d\n" % (file, offset))
+        self._file.flush()
 
     @active
     def addbackup(self, file, hardlink=True, location=''):
@@ -368,8 +368,8 @@
             raise KeyError(file)
         index = self.map[file]
         self.entries[index] = (file, offset, data)
-        self.file.write("%s\0%d\n" % (file, offset))
-        self.file.flush()
+        self._file.write("%s\0%d\n" % (file, offset))
+        self._file.flush()
 
     @active
     def nest(self, name=r'<unnamed>'):
@@ -468,7 +468,7 @@
         self._count -= 1
         if self._count != 0:
             return
-        self.file.close()
+        self._file.close()
         self._backupsfile.close()
         # cleanup temporary files
         for l, f, b, c in self._backupentries:
@@ -560,7 +560,7 @@
     def _abort(self):
         self._count = 0
         self._usages = 0
-        self.file.close()
+        self._file.close()
         self._backupsfile.close()
 
         try: