Mercurial > hg
comparison mercurial/localrepo.py @ 45373:d7dcc75a3eae
localrepo: move requirements constant to requirements module
We now have a dedicated module for requirements constant, let's move the ones in
localrepo there.
Differential Revision: https://phab.mercurial-scm.org/D8918
author | Pulkit Goyal <7895pulkit@gmail.com> |
---|---|
date | Sat, 08 Aug 2020 16:37:59 +0530 |
parents | 77b8588dd84e |
children | 034d94f8761b |
comparison
equal
deleted
inserted
replaced
45372:77b8588dd84e | 45373:d7dcc75a3eae |
---|---|
424 return changegroup.makechangegroup(self._repo, outgoing, b'01', source) | 424 return changegroup.makechangegroup(self._repo, outgoing, b'01', source) |
425 | 425 |
426 # End of baselegacywirecommands interface. | 426 # End of baselegacywirecommands interface. |
427 | 427 |
428 | 428 |
429 # Increment the sub-version when the revlog v2 format changes to lock out old | |
430 # clients. | |
431 REVLOGV2_REQUIREMENT = b'exp-revlogv2.1' | |
432 | |
433 # A repository with the sparserevlog feature will have delta chains that | |
434 # can spread over a larger span. Sparse reading cuts these large spans into | |
435 # pieces, so that each piece isn't too big. | |
436 # Without the sparserevlog capability, reading from the repository could use | |
437 # huge amounts of memory, because the whole span would be read at once, | |
438 # including all the intermediate revisions that aren't pertinent for the chain. | |
439 # This is why once a repository has enabled sparse-read, it becomes required. | |
440 SPARSEREVLOG_REQUIREMENT = b'sparserevlog' | |
441 | |
442 # A repository with the sidedataflag requirement will allow to store extra | |
443 # information for revision without altering their original hashes. | |
444 SIDEDATA_REQUIREMENT = b'exp-sidedata-flag' | |
445 | |
446 # A repository with the the copies-sidedata-changeset requirement will store | |
447 # copies related information in changeset's sidedata. | |
448 COPIESSDC_REQUIREMENT = b'exp-copies-sidedata-changeset' | |
449 | |
450 # The repository use persistent nodemap for the changelog and the manifest. | |
451 NODEMAP_REQUIREMENT = b'persistent-nodemap' | |
452 | |
453 # Functions receiving (ui, features) that extensions can register to impact | 429 # Functions receiving (ui, features) that extensions can register to impact |
454 # the ability to load repositories with custom requirements. Only | 430 # the ability to load repositories with custom requirements. Only |
455 # functions defined in loaded extensions are called. | 431 # functions defined in loaded extensions are called. |
456 # | 432 # |
457 # The function receives a set of requirement strings that the repository | 433 # The function receives a set of requirement strings that the repository |
861 # In the absence of another requirement superseding a revlog-related | 837 # In the absence of another requirement superseding a revlog-related |
862 # requirement, we have to assume the repo is using revlog version 0. | 838 # requirement, we have to assume the repo is using revlog version 0. |
863 # This revlog format is super old and we don't bother trying to parse | 839 # This revlog format is super old and we don't bother trying to parse |
864 # opener options for it because those options wouldn't do anything | 840 # opener options for it because those options wouldn't do anything |
865 # meaningful on such old repos. | 841 # meaningful on such old repos. |
866 if b'revlogv1' in requirements or REVLOGV2_REQUIREMENT in requirements: | 842 if ( |
843 b'revlogv1' in requirements | |
844 or requirementsmod.REVLOGV2_REQUIREMENT in requirements | |
845 ): | |
867 options.update(resolverevlogstorevfsoptions(ui, requirements, features)) | 846 options.update(resolverevlogstorevfsoptions(ui, requirements, features)) |
868 else: # explicitly mark repo as using revlogv0 | 847 else: # explicitly mark repo as using revlogv0 |
869 options[b'revlogv0'] = True | 848 options[b'revlogv0'] = True |
870 | 849 |
871 if COPIESSDC_REQUIREMENT in requirements: | 850 if requirementsmod.COPIESSDC_REQUIREMENT in requirements: |
872 options[b'copies-storage'] = b'changeset-sidedata' | 851 options[b'copies-storage'] = b'changeset-sidedata' |
873 else: | 852 else: |
874 writecopiesto = ui.config(b'experimental', b'copies.write-to') | 853 writecopiesto = ui.config(b'experimental', b'copies.write-to') |
875 copiesextramode = (b'changeset-only', b'compatibility') | 854 copiesextramode = (b'changeset-only', b'compatibility') |
876 if writecopiesto in copiesextramode: | 855 if writecopiesto in copiesextramode: |
885 options = {} | 864 options = {} |
886 options[b'flagprocessors'] = {} | 865 options[b'flagprocessors'] = {} |
887 | 866 |
888 if b'revlogv1' in requirements: | 867 if b'revlogv1' in requirements: |
889 options[b'revlogv1'] = True | 868 options[b'revlogv1'] = True |
890 if REVLOGV2_REQUIREMENT in requirements: | 869 if requirementsmod.REVLOGV2_REQUIREMENT in requirements: |
891 options[b'revlogv2'] = True | 870 options[b'revlogv2'] = True |
892 | 871 |
893 if b'generaldelta' in requirements: | 872 if b'generaldelta' in requirements: |
894 options[b'generaldelta'] = True | 873 options[b'generaldelta'] = True |
895 | 874 |
929 srmingapsize = ui.configbytes(b'experimental', b'sparse-read.min-gap-size') | 908 srmingapsize = ui.configbytes(b'experimental', b'sparse-read.min-gap-size') |
930 options[b'with-sparse-read'] = withsparseread | 909 options[b'with-sparse-read'] = withsparseread |
931 options[b'sparse-read-density-threshold'] = srdensitythres | 910 options[b'sparse-read-density-threshold'] = srdensitythres |
932 options[b'sparse-read-min-gap-size'] = srmingapsize | 911 options[b'sparse-read-min-gap-size'] = srmingapsize |
933 | 912 |
934 sparserevlog = SPARSEREVLOG_REQUIREMENT in requirements | 913 sparserevlog = requirementsmod.SPARSEREVLOG_REQUIREMENT in requirements |
935 options[b'sparse-revlog'] = sparserevlog | 914 options[b'sparse-revlog'] = sparserevlog |
936 if sparserevlog: | 915 if sparserevlog: |
937 options[b'generaldelta'] = True | 916 options[b'generaldelta'] = True |
938 | 917 |
939 sidedata = SIDEDATA_REQUIREMENT in requirements | 918 sidedata = requirementsmod.SIDEDATA_REQUIREMENT in requirements |
940 options[b'side-data'] = sidedata | 919 options[b'side-data'] = sidedata |
941 | 920 |
942 maxchainlen = None | 921 maxchainlen = None |
943 if sparserevlog: | 922 if sparserevlog: |
944 maxchainlen = revlogconst.SPARSE_REVLOG_MAX_CHAIN_LENGTH | 923 maxchainlen = revlogconst.SPARSE_REVLOG_MAX_CHAIN_LENGTH |
970 if requirementsmod.NARROW_REQUIREMENT in requirements: | 949 if requirementsmod.NARROW_REQUIREMENT in requirements: |
971 options[b'enableellipsis'] = True | 950 options[b'enableellipsis'] = True |
972 | 951 |
973 if ui.configbool(b'experimental', b'rust.index'): | 952 if ui.configbool(b'experimental', b'rust.index'): |
974 options[b'rust.index'] = True | 953 options[b'rust.index'] = True |
975 if NODEMAP_REQUIREMENT in requirements: | 954 if requirementsmod.NODEMAP_REQUIREMENT in requirements: |
976 options[b'persistent-nodemap'] = True | 955 options[b'persistent-nodemap'] = True |
977 if ui.configbool(b'storage', b'revlog.nodemap.mmap'): | 956 if ui.configbool(b'storage', b'revlog.nodemap.mmap'): |
978 options[b'persistent-nodemap.mmap'] = True | 957 options[b'persistent-nodemap.mmap'] = True |
979 epnm = ui.config(b'storage', b'revlog.nodemap.mode') | 958 epnm = ui.config(b'storage', b'revlog.nodemap.mode') |
980 options[b'persistent-nodemap.mode'] = epnm | 959 options[b'persistent-nodemap.mode'] = epnm |
1056 # chains), and the code was deleted in 4.6. | 1035 # chains), and the code was deleted in 4.6. |
1057 supportedformats = { | 1036 supportedformats = { |
1058 b'revlogv1', | 1037 b'revlogv1', |
1059 b'generaldelta', | 1038 b'generaldelta', |
1060 requirementsmod.TREEMANIFEST_REQUIREMENT, | 1039 requirementsmod.TREEMANIFEST_REQUIREMENT, |
1061 COPIESSDC_REQUIREMENT, | 1040 requirementsmod.COPIESSDC_REQUIREMENT, |
1062 REVLOGV2_REQUIREMENT, | 1041 requirementsmod.REVLOGV2_REQUIREMENT, |
1063 SIDEDATA_REQUIREMENT, | 1042 requirementsmod.SIDEDATA_REQUIREMENT, |
1064 SPARSEREVLOG_REQUIREMENT, | 1043 requirementsmod.SPARSEREVLOG_REQUIREMENT, |
1065 NODEMAP_REQUIREMENT, | 1044 requirementsmod.NODEMAP_REQUIREMENT, |
1066 bookmarks.BOOKMARKS_IN_STORE_REQUIREMENT, | 1045 bookmarks.BOOKMARKS_IN_STORE_REQUIREMENT, |
1067 } | 1046 } |
1068 _basesupported = supportedformats | { | 1047 _basesupported = supportedformats | { |
1069 b'store', | 1048 b'store', |
1070 b'fncache', | 1049 b'fncache', |
1239 self._sparsematchercache = {} | 1218 self._sparsematchercache = {} |
1240 | 1219 |
1241 self._extrafilterid = repoview.extrafilter(ui) | 1220 self._extrafilterid = repoview.extrafilter(ui) |
1242 | 1221 |
1243 self.filecopiesmode = None | 1222 self.filecopiesmode = None |
1244 if COPIESSDC_REQUIREMENT in self.requirements: | 1223 if requirementsmod.COPIESSDC_REQUIREMENT in self.requirements: |
1245 self.filecopiesmode = b'changeset-sidedata' | 1224 self.filecopiesmode = b'changeset-sidedata' |
1246 | 1225 |
1247 def _getvfsward(self, origfunc): | 1226 def _getvfsward(self, origfunc): |
1248 """build a ward for self.vfs""" | 1227 """build a ward for self.vfs""" |
1249 rref = weakref.ref(self) | 1228 rref = weakref.ref(self) |
3306 requirements.add(b'exp-compression-%s' % compengine) | 3285 requirements.add(b'exp-compression-%s' % compengine) |
3307 | 3286 |
3308 if scmutil.gdinitconfig(ui): | 3287 if scmutil.gdinitconfig(ui): |
3309 requirements.add(b'generaldelta') | 3288 requirements.add(b'generaldelta') |
3310 if ui.configbool(b'format', b'sparse-revlog'): | 3289 if ui.configbool(b'format', b'sparse-revlog'): |
3311 requirements.add(SPARSEREVLOG_REQUIREMENT) | 3290 requirements.add(requirementsmod.SPARSEREVLOG_REQUIREMENT) |
3312 | 3291 |
3313 # experimental config: format.exp-use-side-data | 3292 # experimental config: format.exp-use-side-data |
3314 if ui.configbool(b'format', b'exp-use-side-data'): | 3293 if ui.configbool(b'format', b'exp-use-side-data'): |
3315 requirements.add(SIDEDATA_REQUIREMENT) | 3294 requirements.add(requirementsmod.SIDEDATA_REQUIREMENT) |
3316 # experimental config: format.exp-use-copies-side-data-changeset | 3295 # experimental config: format.exp-use-copies-side-data-changeset |
3317 if ui.configbool(b'format', b'exp-use-copies-side-data-changeset'): | 3296 if ui.configbool(b'format', b'exp-use-copies-side-data-changeset'): |
3318 requirements.add(SIDEDATA_REQUIREMENT) | 3297 requirements.add(requirementsmod.SIDEDATA_REQUIREMENT) |
3319 requirements.add(COPIESSDC_REQUIREMENT) | 3298 requirements.add(requirementsmod.COPIESSDC_REQUIREMENT) |
3320 if ui.configbool(b'experimental', b'treemanifest'): | 3299 if ui.configbool(b'experimental', b'treemanifest'): |
3321 requirements.add(requirementsmod.TREEMANIFEST_REQUIREMENT) | 3300 requirements.add(requirementsmod.TREEMANIFEST_REQUIREMENT) |
3322 | 3301 |
3323 revlogv2 = ui.config(b'experimental', b'revlogv2') | 3302 revlogv2 = ui.config(b'experimental', b'revlogv2') |
3324 if revlogv2 == b'enable-unstable-format-and-corrupt-my-data': | 3303 if revlogv2 == b'enable-unstable-format-and-corrupt-my-data': |
3325 requirements.remove(b'revlogv1') | 3304 requirements.remove(b'revlogv1') |
3326 # generaldelta is implied by revlogv2. | 3305 # generaldelta is implied by revlogv2. |
3327 requirements.discard(b'generaldelta') | 3306 requirements.discard(b'generaldelta') |
3328 requirements.add(REVLOGV2_REQUIREMENT) | 3307 requirements.add(requirementsmod.REVLOGV2_REQUIREMENT) |
3329 # experimental config: format.internal-phase | 3308 # experimental config: format.internal-phase |
3330 if ui.configbool(b'format', b'internal-phase'): | 3309 if ui.configbool(b'format', b'internal-phase'): |
3331 requirements.add(requirementsmod.INTERNAL_PHASE_REQUIREMENT) | 3310 requirements.add(requirementsmod.INTERNAL_PHASE_REQUIREMENT) |
3332 | 3311 |
3333 if createopts.get(b'narrowfiles'): | 3312 if createopts.get(b'narrowfiles'): |
3338 | 3317 |
3339 if ui.configbool(b'format', b'bookmarks-in-store'): | 3318 if ui.configbool(b'format', b'bookmarks-in-store'): |
3340 requirements.add(bookmarks.BOOKMARKS_IN_STORE_REQUIREMENT) | 3319 requirements.add(bookmarks.BOOKMARKS_IN_STORE_REQUIREMENT) |
3341 | 3320 |
3342 if ui.configbool(b'format', b'use-persistent-nodemap'): | 3321 if ui.configbool(b'format', b'use-persistent-nodemap'): |
3343 requirements.add(NODEMAP_REQUIREMENT) | 3322 requirements.add(requirementsmod.NODEMAP_REQUIREMENT) |
3344 | 3323 |
3345 return requirements | 3324 return requirements |
3346 | 3325 |
3347 | 3326 |
3348 def checkrequirementscompat(ui, requirements): | 3327 def checkrequirementscompat(ui, requirements): |