D4625: transaction: make file a private attribute

indygreg (Gregory Szorc) phabricator at mercurial-scm.org
Mon Sep 17 19:36:23 EDT 2018


indygreg created this revision.
Herald added subscribers: mercurial-devel, mjpieters.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  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.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D4625

AFFECTED FILES
  mercurial/transaction.py

CHANGE DETAILS

diff --git a/mercurial/transaction.py b/mercurial/transaction.py
--- a/mercurial/transaction.py
+++ b/mercurial/transaction.py
@@ -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:



To: indygreg, #hg-reviewers
Cc: mjpieters, mercurial-devel


More information about the Mercurial-devel mailing list