mercurial/upgrade_utils/actions.py
changeset 46376 a83e1496d943
parent 46375 2e8a844d0ae0
child 46377 60ea95471b83
equal deleted inserted replaced
46375:2e8a844d0ae0 46376:a83e1496d943
    64        operation when the improvement will be added
    64        operation when the improvement will be added
    65 
    65 
    66     postdowngrademessage
    66     postdowngrademessage
    67        Message intended for humans which will be shown post an upgrade
    67        Message intended for humans which will be shown post an upgrade
    68        operation in which this improvement was removed
    68        operation in which this improvement was removed
       
    69 
       
    70     touches_filelogs (bool)
       
    71         Whether this improvement touches filelogs
       
    72 
       
    73     touches_manifests (bool)
       
    74         Whether this improvement touches manifests
       
    75 
       
    76     touches_changelog (bool)
       
    77         Whether this improvement touches changelog
       
    78 
       
    79     touches_requirements (bool)
       
    80         Whether this improvement changes repository requirements
    69     """
    81     """
    70 
    82 
    71     def __init__(self, name, type, description, upgrademessage):
    83     def __init__(self, name, type, description, upgrademessage):
    72         self.name = name
    84         self.name = name
    73         self.type = type
    85         self.type = type
    74         self.description = description
    86         self.description = description
    75         self.upgrademessage = upgrademessage
    87         self.upgrademessage = upgrademessage
    76         self.postupgrademessage = None
    88         self.postupgrademessage = None
    77         self.postdowngrademessage = None
    89         self.postdowngrademessage = None
       
    90         # By default for now, we assume every improvement touches
       
    91         # all the things
       
    92         self.touches_filelogs = True
       
    93         self.touches_manifests = True
       
    94         self.touches_changelog = True
       
    95         self.touches_requirements = True
    78 
    96 
    79     def __eq__(self, other):
    97     def __eq__(self, other):
    80         if not isinstance(other, improvement):
    98         if not isinstance(other, improvement):
    81             # This is what python tell use to do
    99             # This is what python tell use to do
    82             return NotImplemented
   100             return NotImplemented
   125     postupgrademessage = None
   143     postupgrademessage = None
   126 
   144 
   127     # Message intended for humans which will be shown post an upgrade
   145     # Message intended for humans which will be shown post an upgrade
   128     # operation in which this improvement was removed
   146     # operation in which this improvement was removed
   129     postdowngrademessage = None
   147     postdowngrademessage = None
       
   148 
       
   149     # By default for now, we assume every improvement touches all the things
       
   150     touches_filelogs = True
       
   151     touches_manifests = True
       
   152     touches_changelog = True
       
   153     touches_requirements = True
   130 
   154 
   131     def __init__(self):
   155     def __init__(self):
   132         raise NotImplementedError()
   156         raise NotImplementedError()
   133 
   157 
   134     @staticmethod
   158     @staticmethod
   672         )
   696         )
   673 
   697 
   674         # should this operation create a backup of the store
   698         # should this operation create a backup of the store
   675         self.backup_store = backup_store
   699         self.backup_store = backup_store
   676 
   700 
       
   701         # whether the operation touches different revlogs at all or not
       
   702         self.touches_filelogs = self._touches_filelogs()
       
   703         self.touches_manifests = self._touches_manifests()
       
   704         self.touches_changelog = self._touches_changelog()
       
   705         # whether the operation touches requirements file or not
       
   706         self.touches_requirements = self._touches_requirements()
       
   707         self.touches_store = (
       
   708             self.touches_filelogs
       
   709             or self.touches_manifests
       
   710             or self.touches_changelog
       
   711         )
       
   712         # does the operation only touches repository requirement
       
   713         self.requirements_only = (
       
   714             self.touches_requirements and not self.touches_store
       
   715         )
       
   716 
       
   717     def _touches_filelogs(self):
       
   718         for a in self.upgrade_actions:
       
   719             # in optimisations, we re-process the revlogs again
       
   720             if a.type == OPTIMISATION:
       
   721                 return True
       
   722             elif a.touches_filelogs:
       
   723                 return True
       
   724         for a in self.removed_actions:
       
   725             if a.touches_filelogs:
       
   726                 return True
       
   727         return False
       
   728 
       
   729     def _touches_manifests(self):
       
   730         for a in self.upgrade_actions:
       
   731             # in optimisations, we re-process the revlogs again
       
   732             if a.type == OPTIMISATION:
       
   733                 return True
       
   734             elif a.touches_manifests:
       
   735                 return True
       
   736         for a in self.removed_actions:
       
   737             if a.touches_manifests:
       
   738                 return True
       
   739         return False
       
   740 
       
   741     def _touches_changelog(self):
       
   742         for a in self.upgrade_actions:
       
   743             # in optimisations, we re-process the revlogs again
       
   744             if a.type == OPTIMISATION:
       
   745                 return True
       
   746             elif a.touches_changelog:
       
   747                 return True
       
   748         for a in self.removed_actions:
       
   749             if a.touches_changelog:
       
   750                 return True
       
   751         return False
       
   752 
       
   753     def _touches_requirements(self):
       
   754         for a in self.upgrade_actions:
       
   755             # optimisations are used to re-process revlogs and does not result
       
   756             # in a requirement being added or removed
       
   757             if a.type == OPTIMISATION:
       
   758                 pass
       
   759             elif a.touches_requirements:
       
   760                 return True
       
   761         for a in self.removed_actions:
       
   762             if a.touches_requirements:
       
   763                 return True
       
   764 
       
   765         return False
       
   766 
   677     def _write_labeled(self, l, label):
   767     def _write_labeled(self, l, label):
   678         """
   768         """
   679         Utility function to aid writing of a list under one label
   769         Utility function to aid writing of a list under one label
   680         """
   770         """
   681         first = True
   771         first = True