diff --git a/mercurial/upgrade.py b/mercurial/upgrade.py --- a/mercurial/upgrade.py +++ b/mercurial/upgrade.py @@ -150,19 +150,6 @@ ui.write((b'\n')) ui.write(b'\n') - def printoptimisations(): - optimisations = [ - a for a in actions if a.type == upgrade_actions.OPTIMISATION - ] - optimisations.sort(key=lambda a: a.name) - if optimisations: - ui.write(_(b'optimisations: ')) - write_labeled( - [a.name for a in optimisations], - "upgrade-repo.optimisation.performed", - ) - ui.write(b'\n\n') - upgrade_op = upgrade_actions.UpgradeOperation( ui, newreqs, @@ -219,7 +206,7 @@ ) printrequirements() - printoptimisations() + upgrade_op.print_optimisations() upgrade_op.print_upgrade_actions() upgrade_op.print_affected_revlogs() @@ -239,7 +226,7 @@ # Else we're in the run=true case. ui.write(_(b'upgrade will perform the following actions:\n\n')) printrequirements() - printoptimisations() + upgrade_op.print_optimisations() upgrade_op.print_upgrade_actions() upgrade_op.print_affected_revlogs() diff --git a/mercurial/upgrade_utils/actions.py b/mercurial/upgrade_utils/actions.py --- a/mercurial/upgrade_utils/actions.py +++ b/mercurial/upgrade_utils/actions.py @@ -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))