Mercurial > hg
changeset 46192:25d11b24dedf
upgrade: move printing of unused optimizations to UpgradeOperation class
Differential Revision: https://phab.mercurial-scm.org/D9578
author | Pulkit Goyal <7895pulkit@gmail.com> |
---|---|
date | Mon, 14 Dec 2020 13:48:25 +0530 |
parents | aba979b1b90b |
children | 85f7cf314b39 |
files | mercurial/upgrade.py mercurial/upgrade_utils/actions.py |
diffstat | 2 files changed, 12 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/upgrade.py Sat Dec 12 18:09:16 2020 +0530 +++ b/mercurial/upgrade.py Mon Dec 14 13:48:25 2020 +0530 @@ -184,17 +184,14 @@ upgrade_op.print_upgrade_actions() upgrade_op.print_affected_revlogs() - unusedoptimize = [i for i in alloptimizations if i not in actions] - - if unusedoptimize: + if upgrade_op.unused_optimizations: ui.status( _( b'additional optimizations are available by specifying ' b'"--optimize <name>":\n\n' ) ) - for i in unusedoptimize: - ui.status(_(b'%s\n %s\n\n') % (i.name, i.description)) + upgrade_op.print_unused_optimizations() return # Else we're in the run=true case.
--- a/mercurial/upgrade_utils/actions.py Sat Dec 12 18:09:16 2020 +0530 +++ b/mercurial/upgrade_utils/actions.py Mon Dec 14 13:48:25 2020 +0530 @@ -583,6 +583,12 @@ self._preserved_requirements = ( self.current_requirements & self.new_requirements ) + # optimizations which are not used and it's recommended that they + # should use them + all_optimizations = findoptimizations(None) + self.unused_optimizations = [ + i for i in all_optimizations if i not in self.actions + ] def _write_labeled(self, l, label): """ @@ -640,6 +646,10 @@ self.ui.write((b' - %s\n' % r)) self.ui.write((b'\n')) + def print_unused_optimizations(self): + for i in self.unused_optimizations: + self.ui.status(_(b'%s\n %s\n\n') % (i.name, i.description)) + def has_action(self, name): """ Check whether the upgrade operation will perform this action """ return name in self._actions_names