Mercurial > public > mercurial-scm > hg
comparison mercurial/upgrade_utils/actions.py @ 46210:6b40aac4da8e
upgrade: rename actions to upgrade_actions
The `actions` were a list of optimizations and format upgrades which will be
upgraded. This does not include things which will be downgraded.
Let's rename the variable for clarity. It now makes obvious that we don't have
any concrete information on what things are downgraded.
Differential Revision: https://phab.mercurial-scm.org/D9616
author | Pulkit Goyal <7895pulkit@gmail.com> |
---|---|
date | Wed, 16 Dec 2020 14:16:10 +0530 |
parents | a51d345f1404 |
children | c97d8e0406a6 |
comparison
equal
deleted
inserted
replaced
46209:a51d345f1404 | 46210:6b40aac4da8e |
---|---|
524 # These are unconditionally added. There is logic later that figures out | 524 # These are unconditionally added. There is logic later that figures out |
525 # which ones to apply. | 525 # which ones to apply. |
526 return list(ALL_OPTIMISATIONS) | 526 return list(ALL_OPTIMISATIONS) |
527 | 527 |
528 | 528 |
529 def determineactions( | 529 def determine_upgrade_actions( |
530 repo, format_upgrades, optimizations, sourcereqs, destreqs | 530 repo, format_upgrades, optimizations, sourcereqs, destreqs |
531 ): | 531 ): |
532 """Determine upgrade actions that will be performed. | 532 """Determine upgrade actions that will be performed. |
533 | 533 |
534 Given a list of improvements as returned by ``find_format_upgrades`` and | 534 Given a list of improvements as returned by ``find_format_upgrades`` and |
567 def __init__( | 567 def __init__( |
568 self, | 568 self, |
569 ui, | 569 ui, |
570 new_requirements, | 570 new_requirements, |
571 current_requirements, | 571 current_requirements, |
572 actions, | 572 upgrade_actions, |
573 revlogs_to_process, | 573 revlogs_to_process, |
574 ): | 574 ): |
575 self.ui = ui | 575 self.ui = ui |
576 self.new_requirements = new_requirements | 576 self.new_requirements = new_requirements |
577 self.current_requirements = current_requirements | 577 self.current_requirements = current_requirements |
578 self.actions = actions | 578 # list of upgrade actions the operation will perform |
579 self._actions_names = set([a.name for a in actions]) | 579 self.upgrade_actions = upgrade_actions |
580 self._upgrade_actions_names = set([a.name for a in upgrade_actions]) | |
580 self.revlogs_to_process = revlogs_to_process | 581 self.revlogs_to_process = revlogs_to_process |
581 # requirements which will be added by the operation | 582 # requirements which will be added by the operation |
582 self._added_requirements = ( | 583 self._added_requirements = ( |
583 self.new_requirements - self.current_requirements | 584 self.new_requirements - self.current_requirements |
584 ) | 585 ) |
592 ) | 593 ) |
593 # optimizations which are not used and it's recommended that they | 594 # optimizations which are not used and it's recommended that they |
594 # should use them | 595 # should use them |
595 all_optimizations = findoptimizations(None) | 596 all_optimizations = findoptimizations(None) |
596 self.unused_optimizations = [ | 597 self.unused_optimizations = [ |
597 i for i in all_optimizations if i not in self.actions | 598 i for i in all_optimizations if i not in self.upgrade_actions |
598 ] | 599 ] |
599 | 600 |
600 def _write_labeled(self, l, label): | 601 def _write_labeled(self, l, label): |
601 """ | 602 """ |
602 Utility function to aid writing of a list under one label | 603 Utility function to aid writing of a list under one label |
628 ) | 629 ) |
629 self.ui.write((b'\n')) | 630 self.ui.write((b'\n')) |
630 self.ui.write(b'\n') | 631 self.ui.write(b'\n') |
631 | 632 |
632 def print_optimisations(self): | 633 def print_optimisations(self): |
633 optimisations = [a for a in self.actions if a.type == OPTIMISATION] | 634 optimisations = [ |
635 a for a in self.upgrade_actions if a.type == OPTIMISATION | |
636 ] | |
634 optimisations.sort(key=lambda a: a.name) | 637 optimisations.sort(key=lambda a: a.name) |
635 if optimisations: | 638 if optimisations: |
636 self.ui.write(_(b'optimisations: ')) | 639 self.ui.write(_(b'optimisations: ')) |
637 self._write_labeled( | 640 self._write_labeled( |
638 [a.name for a in optimisations], | 641 [a.name for a in optimisations], |
639 "upgrade-repo.optimisation.performed", | 642 "upgrade-repo.optimisation.performed", |
640 ) | 643 ) |
641 self.ui.write(b'\n\n') | 644 self.ui.write(b'\n\n') |
642 | 645 |
643 def print_upgrade_actions(self): | 646 def print_upgrade_actions(self): |
644 for a in self.actions: | 647 for a in self.upgrade_actions: |
645 self.ui.status(b'%s\n %s\n\n' % (a.name, a.upgrademessage)) | 648 self.ui.status(b'%s\n %s\n\n' % (a.name, a.upgrademessage)) |
646 | 649 |
647 def print_affected_revlogs(self): | 650 def print_affected_revlogs(self): |
648 if not self.revlogs_to_process: | 651 if not self.revlogs_to_process: |
649 self.ui.write((b'no revlogs to process\n')) | 652 self.ui.write((b'no revlogs to process\n')) |
655 | 658 |
656 def print_unused_optimizations(self): | 659 def print_unused_optimizations(self): |
657 for i in self.unused_optimizations: | 660 for i in self.unused_optimizations: |
658 self.ui.status(_(b'%s\n %s\n\n') % (i.name, i.description)) | 661 self.ui.status(_(b'%s\n %s\n\n') % (i.name, i.description)) |
659 | 662 |
660 def has_action(self, name): | 663 def has_upgrade_action(self, name): |
661 """ Check whether the upgrade operation will perform this action """ | 664 """ Check whether the upgrade operation will perform this action """ |
662 return name in self._actions_names | 665 return name in self._upgrade_actions_names |
663 | 666 |
664 | 667 |
665 ### Code checking if a repository can got through the upgrade process at all. # | 668 ### Code checking if a repository can got through the upgrade process at all. # |
666 | 669 |
667 | 670 |