[Updated] D9482: upgrade: move requirements checking in a dedicated function
marmoute (Pierre-Yves David)
phabricator at mercurial-scm.org
Sun Dec 6 12:15:55 UTC 2020
Closed by commit rHGf4f956342cf1: upgrade: move requirements checking in a dedicated function (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/D9482?vs=24033&id=24058
CHANGES SINCE LAST ACTION
https://phab.mercurial-scm.org/D9482/new/
REVISION DETAIL
https://phab.mercurial-scm.org/D9482
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
@@ -9,6 +9,7 @@
from ..i18n import _
from .. import (
+ error,
localrepo,
requirements,
util,
@@ -664,3 +665,21 @@
# e.g. adding generaldelta could schedule parent redeltas.
return newactions
+
+
+def check_source_requirements(repo):
+ """Ensure that no existing requirements prevent the repository upgrade"""
+
+ required = requiredsourcerequirements(repo)
+ missingreqs = required - repo.requirements
+ if missingreqs:
+ msg = _(b'cannot upgrade repository; requirement missing: %s')
+ missingreqs = b', '.join(sorted(missingreqs))
+ raise error.Abort(msg % missingreqs)
+
+ blocking = blocksourcerequirements(repo)
+ blockingreqs = blocking & repo.requirements
+ if blockingreqs:
+ m = _(b'cannot upgrade repository; unsupported source requirement: %s')
+ blockingreqs = b', '.join(sorted(blockingreqs))
+ raise error.Abort(m % blockingreqs)
diff --git a/mercurial/upgrade.py b/mercurial/upgrade.py
--- a/mercurial/upgrade.py
+++ b/mercurial/upgrade.py
@@ -72,26 +72,7 @@
revlogs.discard(upgrade)
# Ensure the repository can be upgraded.
- missingreqs = (
- upgrade_actions.requiredsourcerequirements(repo) - repo.requirements
- )
- if missingreqs:
- raise error.Abort(
- _(b'cannot upgrade repository; requirement missing: %s')
- % _(b', ').join(sorted(missingreqs))
- )
-
- blockedreqs = (
- upgrade_actions.blocksourcerequirements(repo) & repo.requirements
- )
- if blockedreqs:
- raise error.Abort(
- _(
- b'cannot upgrade repository; unsupported source '
- b'requirement: %s'
- )
- % _(b', ').join(sorted(blockedreqs))
- )
+ upgrade_actions.check_source_requirements(repo)
# FUTURE there is potentially a need to control the wanted requirements via
# command arguments or via an extension hook point.
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/e9aff61d/attachment-0002.html>
More information about the Mercurial-patches
mailing list