Mercurial > public > mercurial-scm > hg-stable
diff mercurial/upgrade_utils/actions.py @ 46190:9ab2ab5bf9af
upgrade: move `printoptimisations() to UpgradeOperation class
Part of refactor where we make things more arranged and integrated into single
`UpgradeOperation` class.
Differential Revision: https://phab.mercurial-scm.org/D9576
author | Pulkit Goyal <7895pulkit@gmail.com> |
---|---|
date | Sat, 12 Dec 2020 18:00:18 +0530 |
parents | dfddcbb0c244 |
children | aba979b1b90b |
line wrap: on
line diff
--- a/mercurial/upgrade_utils/actions.py Sat Dec 12 17:54:59 2020 +0530 +++ b/mercurial/upgrade_utils/actions.py Sat Dec 12 18:00:18 2020 +0530 @@ -564,6 +564,28 @@ self._actions_names = set([a.name for a in actions]) self.revlogs_to_process = revlogs_to_process + def _write_labeled(self, l, label): + """ + Utility function to aid writing of a list under one label + """ + first = True + for r in sorted(l): + if not first: + self.ui.write(b', ') + self.ui.write(r, label=label) + first = False + + def print_optimisations(self): + optimisations = [a for a in self.actions if a.type == OPTIMISATION] + optimisations.sort(key=lambda a: a.name) + if optimisations: + self.ui.write(_(b'optimisations: ')) + self._write_labeled( + [a.name for a in optimisations], + "upgrade-repo.optimisation.performed", + ) + self.ui.write(b'\n\n') + def print_upgrade_actions(self): for a in self.actions: self.ui.status(b'%s\n %s\n\n' % (a.name, a.upgrademessage))