comparison mercurial/upgrade.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
30 from .utils import compression 30 from .utils import compression
31 31
32 # list of requirements that request a clone of all revlog if added/removed 32 # list of requirements that request a clone of all revlog if added/removed
33 RECLONES_REQUIREMENTS = { 33 RECLONES_REQUIREMENTS = {
34 b'generaldelta', 34 b'generaldelta',
35 localrepo.SPARSEREVLOG_REQUIREMENT, 35 requirements.SPARSEREVLOG_REQUIREMENT,
36 } 36 }
37 37
38 38
39 def requiredsourcerequirements(repo): 39 def requiredsourcerequirements(repo):
40 """Obtain requirements required to be present to upgrade a repo. 40 """Obtain requirements required to be present to upgrade a repo.
74 If an upgrade were to create a repository that dropped a requirement, 74 If an upgrade were to create a repository that dropped a requirement,
75 the dropped requirement must appear in the returned set for the upgrade 75 the dropped requirement must appear in the returned set for the upgrade
76 to be allowed. 76 to be allowed.
77 """ 77 """
78 supported = { 78 supported = {
79 localrepo.SPARSEREVLOG_REQUIREMENT, 79 requirements.SPARSEREVLOG_REQUIREMENT,
80 localrepo.SIDEDATA_REQUIREMENT, 80 requirements.SIDEDATA_REQUIREMENT,
81 localrepo.COPIESSDC_REQUIREMENT, 81 requirements.COPIESSDC_REQUIREMENT,
82 localrepo.NODEMAP_REQUIREMENT, 82 requirements.NODEMAP_REQUIREMENT,
83 } 83 }
84 for name in compression.compengines: 84 for name in compression.compengines:
85 engine = compression.compengines[name] 85 engine = compression.compengines[name]
86 if engine.available() and engine.revlogheader(): 86 if engine.available() and engine.revlogheader():
87 supported.add(b'exp-compression-%s' % name) 87 supported.add(b'exp-compression-%s' % name)
102 b'dotencode', 102 b'dotencode',
103 b'fncache', 103 b'fncache',
104 b'generaldelta', 104 b'generaldelta',
105 b'revlogv1', 105 b'revlogv1',
106 b'store', 106 b'store',
107 localrepo.SPARSEREVLOG_REQUIREMENT, 107 requirements.SPARSEREVLOG_REQUIREMENT,
108 localrepo.SIDEDATA_REQUIREMENT, 108 requirements.SIDEDATA_REQUIREMENT,
109 localrepo.COPIESSDC_REQUIREMENT, 109 requirements.COPIESSDC_REQUIREMENT,
110 localrepo.NODEMAP_REQUIREMENT, 110 requirements.NODEMAP_REQUIREMENT,
111 } 111 }
112 for name in compression.compengines: 112 for name in compression.compengines:
113 engine = compression.compengines[name] 113 engine = compression.compengines[name]
114 if engine.available() and engine.revlogheader(): 114 if engine.available() and engine.revlogheader():
115 supported.add(b'exp-compression-%s' % name) 115 supported.add(b'exp-compression-%s' % name)
130 """ 130 """
131 supported = { 131 supported = {
132 b'dotencode', 132 b'dotencode',
133 b'fncache', 133 b'fncache',
134 b'generaldelta', 134 b'generaldelta',
135 localrepo.SPARSEREVLOG_REQUIREMENT, 135 requirements.SPARSEREVLOG_REQUIREMENT,
136 localrepo.SIDEDATA_REQUIREMENT, 136 requirements.SIDEDATA_REQUIREMENT,
137 localrepo.COPIESSDC_REQUIREMENT, 137 requirements.COPIESSDC_REQUIREMENT,
138 localrepo.NODEMAP_REQUIREMENT, 138 requirements.NODEMAP_REQUIREMENT,
139 } 139 }
140 for name in compression.compengines: 140 for name in compression.compengines:
141 engine = compression.compengines[name] 141 engine = compression.compengines[name]
142 if engine.available() and engine.revlogheader(): 142 if engine.available() and engine.revlogheader():
143 supported.add(b'exp-compression-%s' % name) 143 supported.add(b'exp-compression-%s' % name)
337 337
338 @registerformatvariant 338 @registerformatvariant
339 class sparserevlog(requirementformatvariant): 339 class sparserevlog(requirementformatvariant):
340 name = b'sparserevlog' 340 name = b'sparserevlog'
341 341
342 _requirement = localrepo.SPARSEREVLOG_REQUIREMENT 342 _requirement = requirements.SPARSEREVLOG_REQUIREMENT
343 343
344 default = True 344 default = True
345 345
346 description = _( 346 description = _(
347 b'in order to limit disk reading and memory usage on older ' 347 b'in order to limit disk reading and memory usage on older '
363 363
364 @registerformatvariant 364 @registerformatvariant
365 class sidedata(requirementformatvariant): 365 class sidedata(requirementformatvariant):
366 name = b'sidedata' 366 name = b'sidedata'
367 367
368 _requirement = localrepo.SIDEDATA_REQUIREMENT 368 _requirement = requirements.SIDEDATA_REQUIREMENT
369 369
370 default = False 370 default = False
371 371
372 description = _( 372 description = _(
373 b'Allows storage of extra data alongside a revision, ' 373 b'Allows storage of extra data alongside a revision, '
379 379
380 @registerformatvariant 380 @registerformatvariant
381 class persistentnodemap(requirementformatvariant): 381 class persistentnodemap(requirementformatvariant):
382 name = b'persistent-nodemap' 382 name = b'persistent-nodemap'
383 383
384 _requirement = localrepo.NODEMAP_REQUIREMENT 384 _requirement = requirements.NODEMAP_REQUIREMENT
385 385
386 default = False 386 default = False
387 387
388 description = _( 388 description = _(
389 b'persist the node -> rev mapping on disk to speedup lookup' 389 b'persist the node -> rev mapping on disk to speedup lookup'
394 394
395 @registerformatvariant 395 @registerformatvariant
396 class copiessdc(requirementformatvariant): 396 class copiessdc(requirementformatvariant):
397 name = b'copies-sdc' 397 name = b'copies-sdc'
398 398
399 _requirement = localrepo.COPIESSDC_REQUIREMENT 399 _requirement = requirements.COPIESSDC_REQUIREMENT
400 400
401 default = False 401 default = False
402 402
403 description = _(b'Stores copies information alongside changesets.') 403 description = _(b'Stores copies information alongside changesets.')
404 404
724 724
725 def getsidedatacompanion(srcrepo, dstrepo): 725 def getsidedatacompanion(srcrepo, dstrepo):
726 sidedatacompanion = None 726 sidedatacompanion = None
727 removedreqs = srcrepo.requirements - dstrepo.requirements 727 removedreqs = srcrepo.requirements - dstrepo.requirements
728 addedreqs = dstrepo.requirements - srcrepo.requirements 728 addedreqs = dstrepo.requirements - srcrepo.requirements
729 if localrepo.SIDEDATA_REQUIREMENT in removedreqs: 729 if requirements.SIDEDATA_REQUIREMENT in removedreqs:
730 730
731 def sidedatacompanion(rl, rev): 731 def sidedatacompanion(rl, rev):
732 rl = getattr(rl, '_revlog', rl) 732 rl = getattr(rl, '_revlog', rl)
733 if rl.flags(rev) & revlog.REVIDX_SIDEDATA: 733 if rl.flags(rev) & revlog.REVIDX_SIDEDATA:
734 return True, (), {} 734 return True, (), {}
735 return False, (), {} 735 return False, (), {}
736 736
737 elif localrepo.COPIESSDC_REQUIREMENT in addedreqs: 737 elif requirements.COPIESSDC_REQUIREMENT in addedreqs:
738 sidedatacompanion = metadata.getsidedataadder(srcrepo, dstrepo) 738 sidedatacompanion = metadata.getsidedataadder(srcrepo, dstrepo)
739 elif localrepo.COPIESSDC_REQUIREMENT in removedreqs: 739 elif requirements.COPIESSDC_REQUIREMENT in removedreqs:
740 sidedatacompanion = metadata.getsidedataremover(srcrepo, dstrepo) 740 sidedatacompanion = metadata.getsidedataremover(srcrepo, dstrepo)
741 return sidedatacompanion 741 return sidedatacompanion
742 742
743 743
744 def matchrevlog(revlogfilter, entry): 744 def matchrevlog(revlogfilter, entry):