comparison mercurial/upgrade_utils/actions.py @ 48779:17eaeb06562c

upgrade: prepare code (and output) for the idea of upgrading share This would work for a subset of action only. Our first target is dirstate-v2. Differential Revision: https://phab.mercurial-scm.org/D12196
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Tue, 15 Feb 2022 23:09:07 +0100
parents 7ee07e1a25c0
children 6e77083683a7
comparison
equal deleted inserted replaced
48778:c4149a110b5f 48779:17eaeb06562c
34 requirements.CHANGELOGV2_REQUIREMENT, 34 requirements.CHANGELOGV2_REQUIREMENT,
35 } 35 }
36 36
37 37
38 def preservedrequirements(repo): 38 def preservedrequirements(repo):
39 return set() 39 preserved = {
40 requirements.SHARED_REQUIREMENT,
41 }
42 return preserved & repo.requirements
40 43
41 44
42 FORMAT_VARIANT = b'deficiency' 45 FORMAT_VARIANT = b'deficiency'
43 OPTIMISATION = b'optimization' 46 OPTIMISATION = b'optimization'
44 47
94 # Whether this improvement changes repository requirements 97 # Whether this improvement changes repository requirements
95 touches_requirements = True 98 touches_requirements = True
96 99
97 # Whether this improvement touches the dirstate 100 # Whether this improvement touches the dirstate
98 touches_dirstate = False 101 touches_dirstate = False
102
103 # Can this action be run on a share instead of its mains repository
104 compatible_with_share = False
99 105
100 106
101 allformatvariant = [] # type: List[Type['formatvariant']] 107 allformatvariant = [] # type: List[Type['formatvariant']]
102 108
103 109
897 # This is an artificial limitation. 903 # This is an artificial limitation.
898 requirements.TREEMANIFEST_REQUIREMENT, 904 requirements.TREEMANIFEST_REQUIREMENT,
899 # This was a precursor to generaldelta and was never enabled by default. 905 # This was a precursor to generaldelta and was never enabled by default.
900 # It should (hopefully) not exist in the wild. 906 # It should (hopefully) not exist in the wild.
901 b'parentdelta', 907 b'parentdelta',
902 # Upgrade should operate on the actual store, not the shared link.
903 requirements.SHARED_REQUIREMENT,
904 } 908 }
905 909
906 910
907 def check_revlog_version(reqs): 911 def check_revlog_version(reqs):
908 """Check that the requirements contain at least one Revlog version""" 912 """Check that the requirements contain at least one Revlog version"""
930 blockingreqs = blocking & repo.requirements 934 blockingreqs = blocking & repo.requirements
931 if blockingreqs: 935 if blockingreqs:
932 m = _(b'cannot upgrade repository; unsupported source requirement: %s') 936 m = _(b'cannot upgrade repository; unsupported source requirement: %s')
933 blockingreqs = b', '.join(sorted(blockingreqs)) 937 blockingreqs = b', '.join(sorted(blockingreqs))
934 raise error.Abort(m % blockingreqs) 938 raise error.Abort(m % blockingreqs)
939 # Upgrade should operate on the actual store, not the shared link.
940
941 bad_share = (
942 requirements.SHARED_REQUIREMENT in repo.requirements
943 and requirements.SHARESAFE_REQUIREMENT not in repo.requirements
944 )
945 if bad_share:
946 m = _(b'cannot upgrade repository; share repository without share-safe')
947 h = _(b'check :hg:`help config.format.use-share-safe`')
948 raise error.Abort(m, hint=h)
935 949
936 950
937 ### Verify the validity of the planned requirement changes #################### 951 ### Verify the validity of the planned requirement changes ####################
938 952
939 953
970 the upgrade is disallowed. 984 the upgrade is disallowed.
971 985
972 Extensions should monkeypatch this to add their custom requirements. 986 Extensions should monkeypatch this to add their custom requirements.
973 """ 987 """
974 supported = { 988 supported = {
989 requirements.CHANGELOGV2_REQUIREMENT,
990 requirements.COPIESSDC_REQUIREMENT,
991 requirements.DIRSTATE_V2_REQUIREMENT,
975 requirements.DOTENCODE_REQUIREMENT, 992 requirements.DOTENCODE_REQUIREMENT,
976 requirements.FNCACHE_REQUIREMENT, 993 requirements.FNCACHE_REQUIREMENT,
977 requirements.GENERALDELTA_REQUIREMENT, 994 requirements.GENERALDELTA_REQUIREMENT,
995 requirements.NODEMAP_REQUIREMENT,
978 requirements.REVLOGV1_REQUIREMENT, # allowed in case of downgrade 996 requirements.REVLOGV1_REQUIREMENT, # allowed in case of downgrade
997 requirements.REVLOGV2_REQUIREMENT,
998 requirements.SHARED_REQUIREMENT,
999 requirements.SHARESAFE_REQUIREMENT,
1000 requirements.SPARSEREVLOG_REQUIREMENT,
979 requirements.STORE_REQUIREMENT, 1001 requirements.STORE_REQUIREMENT,
980 requirements.SPARSEREVLOG_REQUIREMENT,
981 requirements.COPIESSDC_REQUIREMENT,
982 requirements.NODEMAP_REQUIREMENT,
983 requirements.SHARESAFE_REQUIREMENT,
984 requirements.REVLOGV2_REQUIREMENT,
985 requirements.CHANGELOGV2_REQUIREMENT,
986 requirements.DIRSTATE_V2_REQUIREMENT,
987 } 1002 }
988 for name in compression.compengines: 1003 for name in compression.compengines:
989 engine = compression.compengines[name] 1004 engine = compression.compengines[name]
990 if engine.available() and engine.revlogheader(): 1005 if engine.available() and engine.revlogheader():
991 supported.add(b'exp-compression-%s' % name) 1006 supported.add(b'exp-compression-%s' % name)