transaction: make report a private attribute
authorGregory Szorc <gregory.szorc@gmail.com>
Mon, 17 Sep 2018 16:11:25 -0700
changeset 39683 337d6e0fd9c9
parent 39682 b590f4763aba
child 39684 1a68c9b1920d
transaction: make report a private attribute This is a callable used for logging. It isn't used outside the transaction code. It doesn't need to be part of the public interface. Let's mark it as private. Differential Revision: https://phab.mercurial-scm.org/D4631
mercurial/transaction.py
tests/bruterebase.py
--- a/mercurial/transaction.py	Mon Sep 17 16:08:02 2018 -0700
+++ b/mercurial/transaction.py	Mon Sep 17 16:11:25 2018 -0700
@@ -121,7 +121,7 @@
         """
         self._count = 1
         self._usages = 1
-        self.report = report
+        self._report = report
         # a vfs to the store content
         self._opener = opener
         # a map to access file in various {location -> vfs}
@@ -473,8 +473,8 @@
         # cleanup temporary files
         for l, f, b, c in self._backupentries:
             if l not in self._vfsmap and c:
-                self.report("couldn't remove %s: unknown cache location %s\n"
-                            % (b, l))
+                self._report("couldn't remove %s: unknown cache location %s\n"
+                             % (b, l))
                 continue
             vfs = self._vfsmap[l]
             if not f and b and vfs.exists(b):
@@ -484,8 +484,8 @@
                     if not c:
                         raise
                     # Abort may be raise by read only opener
-                    self.report("couldn't remove %s: %s\n"
-                                % (vfs.join(b), inst))
+                    self._report("couldn't remove %s: %s\n"
+                                 % (vfs.join(b), inst))
         self.entries = []
         self._writeundo()
         if self._after:
@@ -497,8 +497,8 @@
             self._opener.unlink(self._journal)
         for l, _f, b, c in self._backupentries:
             if l not in self._vfsmap and c:
-                self.report("couldn't remove %s: unknown cache location"
-                            "%s\n" % (b, l))
+                self._report("couldn't remove %s: unknown cache location"
+                             "%s\n" % (b, l))
                 continue
             vfs = self._vfsmap[l]
             if b and vfs.exists(b):
@@ -508,8 +508,8 @@
                     if not c:
                         raise
                     # Abort may be raise by read only opener
-                    self.report("couldn't remove %s: %s\n"
-                                % (vfs.join(b), inst))
+                    self._report("couldn't remove %s: %s\n"
+                                 % (vfs.join(b), inst))
         self._backupentries = []
         self._journal = None
 
@@ -544,8 +544,8 @@
                 u = ''
             else:
                 if l not in self._vfsmap and c:
-                    self.report("couldn't remove %s: unknown cache location"
-                                "%s\n" % (b, l))
+                    self._report("couldn't remove %s: unknown cache location"
+                                 "%s\n" % (b, l))
                     continue
                 vfs = self._vfsmap[l]
                 base, name = vfs.split(b)
@@ -571,19 +571,19 @@
                     self._opener.unlink(self._journal)
                 return
 
-            self.report(_("transaction abort!\n"))
+            self._report(_("transaction abort!\n"))
 
             try:
                 for cat in sorted(self._abortcallback):
                     self._abortcallback[cat](self)
                 # Prevent double usage and help clear cycles.
                 self._abortcallback = None
-                _playback(self._journal, self.report, self._opener,
+                _playback(self._journal, self._report, self._opener,
                           self._vfsmap, self.entries, self._backupentries,
                           False, checkambigfiles=self._checkambigfiles)
-                self.report(_("rollback completed\n"))
+                self._report(_("rollback completed\n"))
             except BaseException:
-                self.report(_("rollback failed - please run hg recover\n"))
+                self._report(_("rollback failed - please run hg recover\n"))
         finally:
             self._journal = None
             self._releasefn(self, False) # notify failure of transaction
--- a/tests/bruterebase.py	Mon Sep 17 16:08:02 2018 -0700
+++ b/tests/bruterebase.py	Mon Sep 17 16:11:25 2018 -0700
@@ -45,7 +45,7 @@
             subset = [rev for j, rev in enumerate(srevs) if i & (1 << j) != 0]
             spec = revsetlang.formatspec(b'%ld', subset)
             tr = repo.transaction(b'rebase')
-            tr.report = lambda x: 0 # hide "transaction abort"
+            tr._report = lambda x: 0 # hide "transaction abort"
 
             ui.pushbuffer()
             try: