##// END OF EJS Templates
upgrade: introduce post upgrade and downgrade message for improvements...
Pulkit Goyal -
r46830:30310886 default
parent child Browse files
Show More
@@ -87,6 +87,7 b' def upgraderepo('
87 up_actions = upgrade_actions.determine_upgrade_actions(
87 up_actions = upgrade_actions.determine_upgrade_actions(
88 repo, format_upgrades, optimizations, repo.requirements, newreqs
88 repo, format_upgrades, optimizations, repo.requirements, newreqs
89 )
89 )
90 removed_actions = upgrade_actions.find_format_downgrades(repo)
90
91
91 removedreqs = repo.requirements - newreqs
92 removedreqs = repo.requirements - newreqs
92 addedreqs = newreqs - repo.requirements
93 addedreqs = newreqs - repo.requirements
@@ -108,6 +109,7 b' def upgraderepo('
108 newreqs,
109 newreqs,
109 repo.requirements,
110 repo.requirements,
110 up_actions,
111 up_actions,
112 removed_actions,
111 revlogs,
113 revlogs,
112 )
114 )
113
115
@@ -226,20 +228,4 b' def upgraderepo('
226 )
228 )
227 )
229 )
228
230
229 if upgrade_actions.sharesafe.name in addedreqs:
231 upgrade_op.print_post_op_messages()
230 ui.warn(
231 _(
232 b'repository upgraded to share safe mode, existing'
233 b' shares will still work in old non-safe mode. '
234 b'Re-share existing shares to use them in safe mode'
235 b' New shares will be created in safe mode.\n'
236 )
237 )
238 if upgrade_actions.sharesafe.name in removedreqs:
239 ui.warn(
240 _(
241 b'repository downgraded to not use share safe mode, '
242 b'existing shares will not work and needs to'
243 b' be reshared.\n'
244 )
245 )
@@ -57,6 +57,14 b' class improvement(object):'
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):
@@ -64,6 +72,8 b' class improvement(object):'
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):
@@ -109,6 +119,14 b' class formatvariant(improvement):'
109 # value of current Mercurial default for new repository
119 # value of current Mercurial default for new repository
110 default = None
120 default = None
111
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
129
112 def __init__(self):
130 def __init__(self):
113 raise NotImplementedError()
131 raise NotImplementedError()
114
132
@@ -235,6 +253,19 b' class sharesafe(requirementformatvariant'
235 b'shares of this repository share its requirements and configs.'
253 b'shares of this repository share its requirements and configs.'
236 )
254 )
237
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.'
267 )
268
238
269
239 @registerformatvariant
270 @registerformatvariant
240 class sparserevlog(requirementformatvariant):
271 class sparserevlog(requirementformatvariant):
@@ -585,6 +616,7 b' class UpgradeOperation(object):'
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
@@ -593,6 +625,7 b' class UpgradeOperation(object):'
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 = (
@@ -679,6 +712,15 b' class UpgradeOperation(object):'
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
681
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)
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
General Comments 0
You need to be logged in to leave comments. Login now