diff --git a/mercurial/upgrade.py b/mercurial/upgrade.py --- a/mercurial/upgrade.py +++ b/mercurial/upgrade.py @@ -87,6 +87,7 @@ up_actions = upgrade_actions.determine_upgrade_actions( repo, format_upgrades, optimizations, repo.requirements, newreqs ) + removed_actions = upgrade_actions.find_format_downgrades(repo) removedreqs = repo.requirements - newreqs addedreqs = newreqs - repo.requirements @@ -108,6 +109,7 @@ newreqs, repo.requirements, up_actions, + removed_actions, revlogs, ) @@ -226,20 +228,4 @@ ) ) - if upgrade_actions.sharesafe.name in addedreqs: - ui.warn( - _( - b'repository upgraded to share safe mode, existing' - b' shares will still work in old non-safe mode. ' - b'Re-share existing shares to use them in safe mode' - b' New shares will be created in safe mode.\n' - ) - ) - if upgrade_actions.sharesafe.name in removedreqs: - ui.warn( - _( - b'repository downgraded to not use share safe mode, ' - b'existing shares will not work and needs to' - b' be reshared.\n' - ) - ) + upgrade_op.print_post_op_messages() diff --git a/mercurial/upgrade_utils/actions.py b/mercurial/upgrade_utils/actions.py --- a/mercurial/upgrade_utils/actions.py +++ b/mercurial/upgrade_utils/actions.py @@ -57,6 +57,14 @@ upgrademessage Message intended for humans explaining what an upgrade addressing this issue will do. Should be worded in the future tense. + + postupgrademessage + Message intended for humans which will be shown post and upgrade + operationupgrade when the improvement will be added + + postdowngrademessage + Message intended for humans which will be shown post an upgrade + operation in which this improvement was removed """ def __init__(self, name, type, description, upgrademessage): @@ -64,6 +72,8 @@ self.type = type self.description = description self.upgrademessage = upgrademessage + self.postupgrademessage = None + self.postdowngrademessage = None def __eq__(self, other): if not isinstance(other, improvement): @@ -109,6 +119,14 @@ # value of current Mercurial default for new repository default = None + # Message intended for humans which will be shown post and upgrade + # operationupgrade when the improvement will be added + postupgrademessage = None + + # Message intended for humans which will be shown post an upgrade + # operation in which this improvement was removed + postdowngrademessage = None + def __init__(self): raise NotImplementedError() @@ -235,6 +253,19 @@ b'shares of this repository share its requirements and configs.' ) + postdowngrademessage = _( + b'repository downgraded to not use share safe mode, ' + b'existing shares will not work and needs to' + b' be reshared.' + ) + + postupgrademessage = _( + b'repository upgraded to share safe mode, existing' + b' shares will still work in old non-safe mode. ' + b'Re-share existing shares to use them in safe mode' + b' New shares will be created in safe mode.' + ) + @registerformatvariant class sparserevlog(requirementformatvariant): @@ -585,6 +616,7 @@ new_requirements, current_requirements, upgrade_actions, + removed_actions, revlogs_to_process, ): self.ui = ui @@ -593,6 +625,7 @@ # list of upgrae actions the operation will perform self.upgrade_actions = upgrade_actions self._upgrade_actions_names = set([a.name for a in upgrade_actions]) + self.removed_actions = removed_actions self.revlogs_to_process = revlogs_to_process # requirements which will be added by the operation self._added_requirements = ( @@ -679,6 +712,15 @@ """ Check whether the upgrade operation will perform this action """ return name in self._upgrade_actions_names + def print_post_op_messages(self): + """ print post upgrade operation warning messages """ + for a in self.upgrade_actions: + if a.postupgrademessage is not None: + self.ui.warn(b'%s\n' % a.postupgrademessage) + for a in self.removed_actions: + if a.postdowngrademessage is not None: + self.ui.warn(b'%s\n' % a.postdowngrademessage) + ### Code checking if a repository can got through the upgrade process at all. #