comparison mercurial/upgrade_utils/actions.py @ 49193:566066826e7c

upgrade: split some logic from UpgradeOperation The logic for automatic-upgrade and the upgrade-repo should be able to use the same code. However that code often need an UpgradeOperation object to function. So we start spliting the Operation into a minimal component that we will be able to reuse outside of the "classic" upgrade path. We will put the base-class to use in the next changeset. Differential Revision: https://phab.mercurial-scm.org/D12612
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Mon, 04 Apr 2022 19:30:32 +0200
parents 04a812f507be
children 7fe86498e84f
comparison
equal deleted inserted replaced
49192:2ab79873786e 49193:566066826e7c
689 # e.g. adding generaldelta could schedule parent redeltas. 689 # e.g. adding generaldelta could schedule parent redeltas.
690 690
691 return newactions 691 return newactions
692 692
693 693
694 class UpgradeOperation: 694 class BaseOperation:
695 """base class that contains the minimum for an upgrade to work
696
697 (this might need to be extended as the usage for subclass alternative to
698 UpgradeOperation extends)
699 """
700
701 def __init__(
702 self,
703 new_requirements,
704 backup_store,
705 ):
706 self.new_requirements = new_requirements
707 # should this operation create a backup of the store
708 self.backup_store = backup_store
709
710
711 class UpgradeOperation(BaseOperation):
695 """represent the work to be done during an upgrade""" 712 """represent the work to be done during an upgrade"""
696 713
697 def __init__( 714 def __init__(
698 self, 715 self,
699 ui, 716 ui,
702 upgrade_actions, 719 upgrade_actions,
703 removed_actions, 720 removed_actions,
704 revlogs_to_process, 721 revlogs_to_process,
705 backup_store, 722 backup_store,
706 ): 723 ):
724 super().__init__(
725 new_requirements,
726 backup_store,
727 )
707 self.ui = ui 728 self.ui = ui
708 self.new_requirements = new_requirements
709 self.current_requirements = current_requirements 729 self.current_requirements = current_requirements
710 # list of upgrade actions the operation will perform 730 # list of upgrade actions the operation will perform
711 self.upgrade_actions = upgrade_actions 731 self.upgrade_actions = upgrade_actions
712 self.removed_actions = removed_actions 732 self.removed_actions = removed_actions
713 self.revlogs_to_process = revlogs_to_process 733 self.revlogs_to_process = revlogs_to_process
744 764
745 # should this operation force re-delta of both parents 765 # should this operation force re-delta of both parents
746 self.force_re_delta_both_parents = ( 766 self.force_re_delta_both_parents = (
747 b're-delta-multibase' in upgrade_actions_names 767 b're-delta-multibase' in upgrade_actions_names
748 ) 768 )
749
750 # should this operation create a backup of the store
751 self.backup_store = backup_store
752 769
753 @property 770 @property
754 def upgrade_actions_names(self): 771 def upgrade_actions_names(self):
755 return set([a.name for a in self.upgrade_actions]) 772 return set([a.name for a in self.upgrade_actions])
756 773