Mercurial > public > mercurial-scm > hg
comparison mercurial/upgrade_utils/actions.py @ 52636: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 |
comparison
equal
deleted
inserted
replaced
52635:cdfaba964f21 | 52636:0e11e532c958 |
---|---|
880 self.ui.write(_(b'requirements\n')) | 880 self.ui.write(_(b'requirements\n')) |
881 self.ui.write(_(b' preserved: ')) | 881 self.ui.write(_(b' preserved: ')) |
882 self._write_labeled( | 882 self._write_labeled( |
883 self._preserved_requirements, b"upgrade-repo.requirement.preserved" | 883 self._preserved_requirements, b"upgrade-repo.requirement.preserved" |
884 ) | 884 ) |
885 self.ui.write((b'\n')) | 885 self.ui.writenoi18n(b'\n') |
886 if self._removed_requirements: | 886 if self._removed_requirements: |
887 self.ui.write(_(b' removed: ')) | 887 self.ui.write(_(b' removed: ')) |
888 self._write_labeled( | 888 self._write_labeled( |
889 self._removed_requirements, b"upgrade-repo.requirement.removed" | 889 self._removed_requirements, b"upgrade-repo.requirement.removed" |
890 ) | 890 ) |
891 self.ui.write((b'\n')) | 891 self.ui.writenoi18n(b'\n') |
892 if self._added_requirements: | 892 if self._added_requirements: |
893 self.ui.write(_(b' added: ')) | 893 self.ui.write(_(b' added: ')) |
894 self._write_labeled( | 894 self._write_labeled( |
895 self._added_requirements, b"upgrade-repo.requirement.added" | 895 self._added_requirements, b"upgrade-repo.requirement.added" |
896 ) | 896 ) |
897 self.ui.write((b'\n')) | 897 self.ui.writenoi18n(b'\n') |
898 self.ui.write(b'\n') | 898 self.ui.write(b'\n') |
899 | 899 |
900 def print_optimisations(self): | 900 def print_optimisations(self): |
901 optimisations = [ | 901 optimisations = [ |
902 a for a in self.upgrade_actions if a.type == OPTIMISATION | 902 a for a in self.upgrade_actions if a.type == OPTIMISATION |
914 for a in self.upgrade_actions: | 914 for a in self.upgrade_actions: |
915 self.ui.status(b'%s\n %s\n\n' % (a.name, a.upgrademessage)) | 915 self.ui.status(b'%s\n %s\n\n' % (a.name, a.upgrademessage)) |
916 | 916 |
917 def print_affected_revlogs(self): | 917 def print_affected_revlogs(self): |
918 if not self.revlogs_to_process: | 918 if not self.revlogs_to_process: |
919 self.ui.write((b'no revlogs to process\n')) | 919 self.ui.writenoi18n(b'no revlogs to process\n') |
920 else: | 920 else: |
921 self.ui.write((b'processed revlogs:\n')) | 921 self.ui.writenoi18n(b'processed revlogs:\n') |
922 for r in sorted(self.revlogs_to_process): | 922 for r in sorted(self.revlogs_to_process): |
923 self.ui.write((b' - %s\n' % r)) | 923 self.ui.writenoi18n(b' - %s\n' % r) |
924 self.ui.write((b'\n')) | 924 self.ui.writenoi18n(b'\n') |
925 | 925 |
926 def print_unused_optimizations(self): | 926 def print_unused_optimizations(self): |
927 for i in self.unused_optimizations: | 927 for i in self.unused_optimizations: |
928 self.ui.status(_(b'%s\n %s\n\n') % (i.name, i.description)) | 928 self.ui.status(_(b'%s\n %s\n\n') % (i.name, i.description)) |
929 | 929 |