mercurial/upgrade_utils/actions.py
changeset 46213 30310886d423
parent 46212 c97d8e0406a6
child 46215 82f3ee1a505f
equal deleted inserted replaced
46212:c97d8e0406a6 46213:30310886d423
    55        worded in the future tense.
    55        worded in the future tense.
    56 
    56 
    57     upgrademessage
    57     upgrademessage
    58        Message intended for humans explaining what an upgrade addressing this
    58        Message intended for humans explaining what an upgrade addressing this
    59        issue will do. Should be worded in the future tense.
    59        issue will do. Should be worded in the future tense.
       
    60 
       
    61     postupgrademessage
       
    62        Message intended for humans which will be shown post an upgrade
       
    63        operation when the improvement will be added
       
    64 
       
    65     postdowngrademessage
       
    66        Message intended for humans which will be shown post an upgrade
       
    67        operation in which this improvement was removed
    60     """
    68     """
    61 
    69 
    62     def __init__(self, name, type, description, upgrademessage):
    70     def __init__(self, name, type, description, upgrademessage):
    63         self.name = name
    71         self.name = name
    64         self.type = type
    72         self.type = type
    65         self.description = description
    73         self.description = description
    66         self.upgrademessage = upgrademessage
    74         self.upgrademessage = upgrademessage
       
    75         self.postupgrademessage = None
       
    76         self.postdowngrademessage = None
    67 
    77 
    68     def __eq__(self, other):
    78     def __eq__(self, other):
    69         if not isinstance(other, improvement):
    79         if not isinstance(other, improvement):
    70             # This is what python tell use to do
    80             # This is what python tell use to do
    71             return NotImplemented
    81             return NotImplemented
   106     # issue will do. should be worded in the future tense.
   116     # issue will do. should be worded in the future tense.
   107     upgrademessage = None
   117     upgrademessage = None
   108 
   118 
   109     # value of current Mercurial default for new repository
   119     # value of current Mercurial default for new repository
   110     default = None
   120     default = None
       
   121 
       
   122     # Message intended for humans which will be shown post an upgrade
       
   123     # operation when the improvement will be added
       
   124     postupgrademessage = None
       
   125 
       
   126     # Message intended for humans which will be shown post an upgrade
       
   127     # operation in which this improvement was removed
       
   128     postdowngrademessage = None
   111 
   129 
   112     def __init__(self):
   130     def __init__(self):
   113         raise NotImplementedError()
   131         raise NotImplementedError()
   114 
   132 
   115     @staticmethod
   133     @staticmethod
   231     )
   249     )
   232 
   250 
   233     upgrademessage = _(
   251     upgrademessage = _(
   234         b'Upgrades a repository to share-safe format so that future '
   252         b'Upgrades a repository to share-safe format so that future '
   235         b'shares of this repository share its requirements and configs.'
   253         b'shares of this repository share its requirements and configs.'
       
   254     )
       
   255 
       
   256     postdowngrademessage = _(
       
   257         b'repository downgraded to not use share safe mode, '
       
   258         b'existing shares will not work and needs to'
       
   259         b' be reshared.'
       
   260     )
       
   261 
       
   262     postupgrademessage = _(
       
   263         b'repository upgraded to share safe mode, existing'
       
   264         b' shares will still work in old non-safe mode. '
       
   265         b'Re-share existing shares to use them in safe mode'
       
   266         b' New shares will be created in safe mode.'
   236     )
   267     )
   237 
   268 
   238 
   269 
   239 @registerformatvariant
   270 @registerformatvariant
   240 class sparserevlog(requirementformatvariant):
   271 class sparserevlog(requirementformatvariant):
   583         self,
   614         self,
   584         ui,
   615         ui,
   585         new_requirements,
   616         new_requirements,
   586         current_requirements,
   617         current_requirements,
   587         upgrade_actions,
   618         upgrade_actions,
       
   619         removed_actions,
   588         revlogs_to_process,
   620         revlogs_to_process,
   589     ):
   621     ):
   590         self.ui = ui
   622         self.ui = ui
   591         self.new_requirements = new_requirements
   623         self.new_requirements = new_requirements
   592         self.current_requirements = current_requirements
   624         self.current_requirements = current_requirements
   593         # list of upgrade actions the operation will perform
   625         # list of upgrade actions the operation will perform
   594         self.upgrade_actions = upgrade_actions
   626         self.upgrade_actions = upgrade_actions
   595         self._upgrade_actions_names = set([a.name for a in upgrade_actions])
   627         self._upgrade_actions_names = set([a.name for a in upgrade_actions])
       
   628         self.removed_actions = removed_actions
   596         self.revlogs_to_process = revlogs_to_process
   629         self.revlogs_to_process = revlogs_to_process
   597         # requirements which will be added by the operation
   630         # requirements which will be added by the operation
   598         self._added_requirements = (
   631         self._added_requirements = (
   599             self.new_requirements - self.current_requirements
   632             self.new_requirements - self.current_requirements
   600         )
   633         )
   676             self.ui.status(_(b'%s\n   %s\n\n') % (i.name, i.description))
   709             self.ui.status(_(b'%s\n   %s\n\n') % (i.name, i.description))
   677 
   710 
   678     def has_upgrade_action(self, name):
   711     def has_upgrade_action(self, name):
   679         """ Check whether the upgrade operation will perform this action """
   712         """ Check whether the upgrade operation will perform this action """
   680         return name in self._upgrade_actions_names
   713         return name in self._upgrade_actions_names
       
   714 
       
   715     def print_post_op_messages(self):
       
   716         """ print post upgrade operation warning messages """
       
   717         for a in self.upgrade_actions:
       
   718             if a.postupgrademessage is not None:
       
   719                 self.ui.warn(b'%s\n' % a.postupgrademessage)
       
   720         for a in self.removed_actions:
       
   721             if a.postdowngrademessage is not None:
       
   722                 self.ui.warn(b'%s\n' % a.postdowngrademessage)
   681 
   723 
   682 
   724 
   683 ###  Code checking if a repository can got through the upgrade process at all. #
   725 ###  Code checking if a repository can got through the upgrade process at all. #
   684 
   726 
   685 
   727