changeset 50868:0a4efb650b3e stable

transaction: fix __repr__() and make the default name bytes This likely was always wrong on py3, since going back to aff5996f3043, these were added as a r-strings. Callers seem to always be supplying bytes, which makes the `b'/'.join(...)` part OK, but then bytes can't be interpolated into str with "%s", so it wouldn't have worked in either case.
author Matt Harbison <matt_harbison@yahoo.com>
date Mon, 21 Aug 2023 10:21:58 -0400
parents 181936ad069a
children 5dc7e1907e48
files mercurial/transaction.py
diffstat 1 files changed, 4 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/transaction.py	Sun Aug 20 16:32:18 2023 -0400
+++ b/mercurial/transaction.py	Mon Aug 21 10:21:58 2023 -0400
@@ -16,6 +16,7 @@
 
 from .i18n import _
 from . import (
+    encoding,
     error,
     pycompat,
     util,
@@ -229,7 +230,7 @@
         validator=None,
         releasefn=None,
         checkambigfiles=None,
-        name='<unnamed>',
+        name=b'<unnamed>',
     ):
         """Begin a new transaction
 
@@ -318,7 +319,7 @@
     def __repr__(self):
         name = b'/'.join(self._names)
         return '<transaction name=%s, count=%d, usages=%d>' % (
-            name,
+            encoding.strfromlocal(name),
             self._count,
             self._usages,
         )
@@ -574,7 +575,7 @@
         self._file.flush()
 
     @active
-    def nest(self, name='<unnamed>'):
+    def nest(self, name=b'<unnamed>'):
         self._count += 1
         self._usages += 1
         self._names.append(name)