Mercurial > public > mercurial-scm > hg
comparison mercurial/upgrade_utils/actions.py @ 46049:a2a59cde9b9f
upgrade: gather code about source checking together
They just moved in the same file, now they are grouped together and documented.
Differential Revision: https://phab.mercurial-scm.org/D9483
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Tue, 01 Dec 2020 15:54:38 +0100 |
parents | f4f956342cf1 |
children | 72b7b4bf3e65 |
comparison
equal
deleted
inserted
replaced
46048:f4f956342cf1 | 46049:a2a59cde9b9f |
---|---|
20 # list of requirements that request a clone of all revlog if added/removed | 20 # list of requirements that request a clone of all revlog if added/removed |
21 RECLONES_REQUIREMENTS = { | 21 RECLONES_REQUIREMENTS = { |
22 b'generaldelta', | 22 b'generaldelta', |
23 requirements.SPARSEREVLOG_REQUIREMENT, | 23 requirements.SPARSEREVLOG_REQUIREMENT, |
24 } | 24 } |
25 | |
26 | |
27 def requiredsourcerequirements(repo): | |
28 """Obtain requirements required to be present to upgrade a repo. | |
29 | |
30 An upgrade will not be allowed if the repository doesn't have the | |
31 requirements returned by this function. | |
32 """ | |
33 return { | |
34 # Introduced in Mercurial 0.9.2. | |
35 b'revlogv1', | |
36 # Introduced in Mercurial 0.9.2. | |
37 b'store', | |
38 } | |
39 | |
40 | |
41 def blocksourcerequirements(repo): | |
42 """Obtain requirements that will prevent an upgrade from occurring. | |
43 | |
44 An upgrade cannot be performed if the source repository contains a | |
45 requirements in the returned set. | |
46 """ | |
47 return { | |
48 # The upgrade code does not yet support these experimental features. | |
49 # This is an artificial limitation. | |
50 requirements.TREEMANIFEST_REQUIREMENT, | |
51 # This was a precursor to generaldelta and was never enabled by default. | |
52 # It should (hopefully) not exist in the wild. | |
53 b'parentdelta', | |
54 # Upgrade should operate on the actual store, not the shared link. | |
55 requirements.SHARED_REQUIREMENT, | |
56 } | |
57 | 25 |
58 | 26 |
59 def supportremovedrequirements(repo): | 27 def supportremovedrequirements(repo): |
60 """Obtain requirements that can be removed during an upgrade. | 28 """Obtain requirements that can be removed during an upgrade. |
61 | 29 |
665 # e.g. adding generaldelta could schedule parent redeltas. | 633 # e.g. adding generaldelta could schedule parent redeltas. |
666 | 634 |
667 return newactions | 635 return newactions |
668 | 636 |
669 | 637 |
638 ### Code checking if a repository can got through the upgrade process at all. # | |
639 | |
640 | |
641 def requiredsourcerequirements(repo): | |
642 """Obtain requirements required to be present to upgrade a repo. | |
643 | |
644 An upgrade will not be allowed if the repository doesn't have the | |
645 requirements returned by this function. | |
646 """ | |
647 return { | |
648 # Introduced in Mercurial 0.9.2. | |
649 b'revlogv1', | |
650 # Introduced in Mercurial 0.9.2. | |
651 b'store', | |
652 } | |
653 | |
654 | |
655 def blocksourcerequirements(repo): | |
656 """Obtain requirements that will prevent an upgrade from occurring. | |
657 | |
658 An upgrade cannot be performed if the source repository contains a | |
659 requirements in the returned set. | |
660 """ | |
661 return { | |
662 # The upgrade code does not yet support these experimental features. | |
663 # This is an artificial limitation. | |
664 requirements.TREEMANIFEST_REQUIREMENT, | |
665 # This was a precursor to generaldelta and was never enabled by default. | |
666 # It should (hopefully) not exist in the wild. | |
667 b'parentdelta', | |
668 # Upgrade should operate on the actual store, not the shared link. | |
669 requirements.SHARED_REQUIREMENT, | |
670 } | |
671 | |
672 | |
670 def check_source_requirements(repo): | 673 def check_source_requirements(repo): |
671 """Ensure that no existing requirements prevent the repository upgrade""" | 674 """Ensure that no existing requirements prevent the repository upgrade""" |
672 | 675 |
673 required = requiredsourcerequirements(repo) | 676 required = requiredsourcerequirements(repo) |
674 missingreqs = required - repo.requirements | 677 missingreqs = required - repo.requirements |