D4622: transaction: make count and usages private attributes

indygreg (Gregory Szorc) phabricator at mercurial-scm.org
Tue Sep 18 17:28:56 EDT 2018


This revision was automatically updated to reflect the committed changes.
Closed by commit rHG3e8952c0cb45: transaction: make count and usages private attributes (authored by indygreg, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D4622?vs=11121&id=11148

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

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
@@ -38,7 +38,7 @@
 
 def active(func):
     def _active(self, *args, **kwds):
-        if self.count == 0:
+        if self._count == 0:
             raise error.Abort(_(
                 'cannot use transaction when it is already committed/aborted'))
         return func(self, *args, **kwds)
@@ -119,8 +119,8 @@
         which determine whether file stat ambiguity should be avoided
         for corresponded files.
         """
-        self.count = 1
-        self.usages = 1
+        self._count = 1
+        self._usages = 1
         self.report = report
         # a vfs to the store content
         self.opener = opener
@@ -191,7 +191,7 @@
     def __repr__(self):
         name = r'/'.join(self.names)
         return (r'<transaction name=%s, count=%d, usages=%d>' %
-                (name, self.count, self.usages))
+                (name, self._count, self._usages))
 
     def __del__(self):
         if self.journal:
@@ -373,22 +373,22 @@
 
     @active
     def nest(self, name=r'<unnamed>'):
-        self.count += 1
-        self.usages += 1
+        self._count += 1
+        self._usages += 1
         self.names.append(name)
         return self
 
     def release(self):
-        if self.count > 0:
-            self.usages -= 1
+        if self._count > 0:
+            self._usages -= 1
         if self.names:
             self.names.pop()
         # if the transaction scopes are left without being closed, fail
-        if self.count > 0 and self.usages == 0:
+        if self._count > 0 and self._usages == 0:
             self._abort()
 
     def running(self):
-        return self.count > 0
+        return self._count > 0
 
     def addpending(self, category, callback):
         """add a callback to be called when the transaction is pending
@@ -454,7 +454,7 @@
     @active
     def close(self):
         '''commit the transaction'''
-        if self.count == 1:
+        if self._count == 1:
             self.validator(self)  # will raise exception if needed
             self.validator = None # Help prevent cycles.
             self._generatefiles(group=gengroupprefinalize)
@@ -465,8 +465,8 @@
             self._finalizecallback = None
             self._generatefiles(group=gengrouppostfinalize)
 
-        self.count -= 1
-        if self.count != 0:
+        self._count -= 1
+        if self._count != 0:
             return
         self.file.close()
         self._backupsfile.close()
@@ -557,8 +557,8 @@
 
 
     def _abort(self):
-        self.count = 0
-        self.usages = 0
+        self._count = 0
+        self._usages = 0
         self.file.close()
         self._backupsfile.close()
 



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


More information about the Mercurial-devel mailing list