diff mercurial/upgrade_utils/actions.py @ 52661:0e11e532c958

style: use `ui.xxxnoi18n()` methods instead of wrapping msg in `()` These aliases were introduced back in 5209fc94b982, because `black` was going to strip away the extra parentheses, but they're needed to subvert `test-check-code.t`. That obviously changed at some point, but `pyupgrade`[1] also strips these out. While that tool is very useful in adapting code to modern standards, it lacks the ability to turn off most conversions, so constantly reverting these is a pain. Even without that, the code is more understandable with an explicit declaration. It also would have been an easy typo to miss the leading `_` in the i18n method `_()` that the checker is looking for, and fail to detect the problem. The `contrib/perf.py` code just uses a local alias to the original methods because (IIUC), this tries to be compatible with old versions of hg. But practically, these noi18n aliases were added before useful py3 support, and at some point, it won't be feasible to do py2 benchmarking anymore, and maybe this module can be cleaned up some. [1] https://github.com/asottile/pyupgrade
author Matt Harbison <matt_harbison@yahoo.com>
date Mon, 06 Jan 2025 13:29:42 -0500
parents f4733654f144
children 4cb75772818d
line wrap: on
line diff
--- a/mercurial/upgrade_utils/actions.py	Tue Jan 07 14:57:51 2025 -0500
+++ b/mercurial/upgrade_utils/actions.py	Mon Jan 06 13:29:42 2025 -0500
@@ -882,19 +882,19 @@
         self._write_labeled(
             self._preserved_requirements, b"upgrade-repo.requirement.preserved"
         )
-        self.ui.write((b'\n'))
+        self.ui.writenoi18n(b'\n')
         if self._removed_requirements:
             self.ui.write(_(b'   removed: '))
             self._write_labeled(
                 self._removed_requirements, b"upgrade-repo.requirement.removed"
             )
-            self.ui.write((b'\n'))
+            self.ui.writenoi18n(b'\n')
         if self._added_requirements:
             self.ui.write(_(b'   added: '))
             self._write_labeled(
                 self._added_requirements, b"upgrade-repo.requirement.added"
             )
-            self.ui.write((b'\n'))
+            self.ui.writenoi18n(b'\n')
         self.ui.write(b'\n')
 
     def print_optimisations(self):
@@ -916,12 +916,12 @@
 
     def print_affected_revlogs(self):
         if not self.revlogs_to_process:
-            self.ui.write((b'no revlogs to process\n'))
+            self.ui.writenoi18n(b'no revlogs to process\n')
         else:
-            self.ui.write((b'processed revlogs:\n'))
+            self.ui.writenoi18n(b'processed revlogs:\n')
             for r in sorted(self.revlogs_to_process):
-                self.ui.write((b'  - %s\n' % r))
-        self.ui.write((b'\n'))
+                self.ui.writenoi18n(b'  - %s\n' % r)
+        self.ui.writenoi18n(b'\n')
 
     def print_unused_optimizations(self):
         for i in self.unused_optimizations: