[Updated] D9485: upgrade: extract the checking of target requirements change
marmoute (Pierre-Yves David)
phabricator at mercurial-scm.org
Sun Dec 6 12:16:06 UTC 2020
Closed by commit rHG72b7b4bf3e65: upgrade: extract the checking of target requirements change (authored by marmoute).
This revision was automatically updated to reflect the committed changes.
REPOSITORY
rHG Mercurial
CHANGES SINCE LAST UPDATE
https://phab.mercurial-scm.org/D9485?vs=24036&id=24061
CHANGES SINCE LAST ACTION
https://phab.mercurial-scm.org/D9485/new/
REVISION DETAIL
https://phab.mercurial-scm.org/D9485
AFFECTED FILES
mercurial/upgrade.py
mercurial/upgrade_utils/actions.py
CHANGE DETAILS
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
@@ -686,3 +686,34 @@
m = _(b'cannot upgrade repository; unsupported source requirement: %s')
blockingreqs = b', '.join(sorted(blockingreqs))
raise error.Abort(m % blockingreqs)
+
+
+### Verify the validity of the planned requirement changes ####################
+
+
+def check_requirements_changes(repo, new_reqs):
+ old_reqs = repo.requirements
+
+ support_removal = supportremovedrequirements(repo)
+ no_remove_reqs = old_reqs - new_reqs - support_removal
+ if no_remove_reqs:
+ msg = _(b'cannot upgrade repository; requirement would be removed: %s')
+ no_remove_reqs = b', '.join(sorted(no_remove_reqs))
+ raise error.Abort(msg % no_remove_reqs)
+
+ support_addition = allowednewrequirements(repo)
+ no_add_reqs = new_reqs - old_reqs - support_addition
+ if no_add_reqs:
+ m = _(b'cannot upgrade repository; do not support adding requirement: ')
+ no_add_reqs = b', '.join(sorted(no_add_reqs))
+ raise error.Abort(m + no_add_reqs)
+
+ supported = supporteddestrequirements(repo)
+ unsupported_reqs = new_reqs - supported
+ if unsupported_reqs:
+ msg = _(
+ b'cannot upgrade repository; do not support destination '
+ b'requirement: %s'
+ )
+ unsupported_reqs = b', '.join(sorted(unsupported_reqs))
+ raise error.Abort(msg % unsupported_reqs)
diff --git a/mercurial/upgrade.py b/mercurial/upgrade.py
--- a/mercurial/upgrade.py
+++ b/mercurial/upgrade.py
@@ -74,48 +74,11 @@
# Ensure the repository can be upgraded.
upgrade_actions.check_source_requirements(repo)
- newreqs = localrepo.newreporequirements(
- repo.ui, localrepo.defaultcreateopts(repo.ui)
- )
+ default_options = localrepo.defaultcreateopts(repo.ui)
+ newreqs = localrepo.newreporequirements(repo.ui, default_options)
newreqs.update(upgrade_actions.preservedrequirements(repo))
- noremovereqs = (
- repo.requirements
- - newreqs
- - upgrade_actions.supportremovedrequirements(repo)
- )
- if noremovereqs:
- raise error.Abort(
- _(
- b'cannot upgrade repository; requirement would be '
- b'removed: %s'
- )
- % _(b', ').join(sorted(noremovereqs))
- )
-
- noaddreqs = (
- newreqs
- - repo.requirements
- - upgrade_actions.allowednewrequirements(repo)
- )
- if noaddreqs:
- raise error.Abort(
- _(
- b'cannot upgrade repository; do not support adding '
- b'requirement: %s'
- )
- % _(b', ').join(sorted(noaddreqs))
- )
-
- unsupportedreqs = newreqs - upgrade_actions.supporteddestrequirements(repo)
- if unsupportedreqs:
- raise error.Abort(
- _(
- b'cannot upgrade repository; do not support '
- b'destination requirement: %s'
- )
- % _(b', ').join(sorted(unsupportedreqs))
- )
+ upgrade_actions.check_requirements_changes(repo, newreqs)
# Find and validate all improvements that can be made.
alloptimizations = upgrade_actions.findoptimizations(repo)
To: marmoute, #hg-reviewers, pulkit
Cc: mercurial-patches
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mercurial-scm.org/pipermail/mercurial-patches/attachments/20201206/54126a92/attachment-0002.html>
More information about the Mercurial-patches
mailing list