comparison mercurial/localrepo.py @ 32717:19b9fc40cc51

revlog: skeleton support for version 2 revlogs There are a number of improvements we want to make to revlogs that will require a new version - version 2. It is unclear what the full set of improvements will be or when we'll be done with them. What I do know is that the process will likely take longer than a single release, will require input from various stakeholders to evaluate changes, and will have many contentious debates and bikeshedding. It is unrealistic to develop revlog version 2 up front: there are just too many uncertainties that we won't know until things are implemented and experiments are run. Some changes will also be invasive and prone to bit rot, so sitting on dozens of patches is not practical. This commit introduces skeleton support for version 2 revlogs in a way that is flexible and not bound by backwards compatibility concerns. An experimental repo requirement for denoting revlog v2 has been added. The requirement string has a sub-version component to it. This will allow us to declare multiple requirements in the course of developing revlog v2. Whenever we change the in-development revlog v2 format, we can tweak the string, creating a new requirement and locking out old clients. This will allow us to make as many backwards incompatible changes and experiments to revlog v2 as we want. In other words, we can land code and make meaningful progress towards revlog v2 while still maintaining extreme format flexibility up until the point we freeze the format and remove the experimental labels. To enable the new repo requirement, you must supply an experimental and undocumented config option. But not just any boolean flag will do: you need to explicitly use a value that no sane person should ever type. This is an additional guard against enabling revlog v2 on an installation it shouldn't be enabled on. The specific scenario I'm trying to prevent is say a user with a 4.4 client with a frozen format enabling the option but then downgrading to 4.3 and accidentally creating repos with an outdated and unsupported repo format. Requiring a "challenge" string should prevent this. Because the format is not yet finalized and I don't want to take any chances, revlog v2's version is currently 0xDEAD. I figure squatting on a value we're likely never to use as an actual revlog version to mean "internal testing only" is acceptable. And "dead" is easily recognized as something meaningful. There is a bunch of cleanup that is needed before work on revlog v2 begins in earnest. I plan on doing that work once this patch is accepted and we're comfortable with the idea of starting down this path.
author Gregory Szorc <gregory.szorc@gmail.com>
date Fri, 19 May 2017 20:29:11 -0700
parents a722c8e17363
children c8177792fef6
comparison
equal deleted inserted replaced
32716:0c09afdf5704 32717:19b9fc40cc51
242 return changegroup.changegroup(self._repo, basenodes, source) 242 return changegroup.changegroup(self._repo, basenodes, source)
243 243
244 def changegroupsubset(self, bases, heads, source): 244 def changegroupsubset(self, bases, heads, source):
245 return changegroup.changegroupsubset(self._repo, bases, heads, source) 245 return changegroup.changegroupsubset(self._repo, bases, heads, source)
246 246
247 # Increment the sub-version when the revlog v2 format changes to lock out old
248 # clients.
249 REVLOGV2_REQUIREMENT = 'exp-revlogv2.0'
250
247 class localrepository(object): 251 class localrepository(object):
248 252
249 supportedformats = { 253 supportedformats = {
250 'revlogv1', 254 'revlogv1',
251 'generaldelta', 255 'generaldelta',
252 'treemanifest', 256 'treemanifest',
253 'manifestv2', 257 'manifestv2',
258 REVLOGV2_REQUIREMENT,
254 } 259 }
255 _basesupported = supportedformats | { 260 _basesupported = supportedformats | {
256 'store', 261 'store',
257 'fncache', 262 'fncache',
258 'shared', 263 'shared',
437 self.svfs.options['lazydeltabase'] = not scmutil.gddeltaconfig(self.ui) 442 self.svfs.options['lazydeltabase'] = not scmutil.gddeltaconfig(self.ui)
438 443
439 for r in self.requirements: 444 for r in self.requirements:
440 if r.startswith('exp-compression-'): 445 if r.startswith('exp-compression-'):
441 self.svfs.options['compengine'] = r[len('exp-compression-'):] 446 self.svfs.options['compengine'] = r[len('exp-compression-'):]
447
448 # TODO move "revlogv2" to openerreqs once finalized.
449 if REVLOGV2_REQUIREMENT in self.requirements:
450 self.svfs.options['revlogv2'] = True
442 451
443 def _writerequirements(self): 452 def _writerequirements(self):
444 scmutil.writerequires(self.vfs, self.requirements) 453 scmutil.writerequires(self.vfs, self.requirements)
445 454
446 def _checknested(self, path): 455 def _checknested(self, path):
2068 if ui.configbool('experimental', 'treemanifest', False): 2077 if ui.configbool('experimental', 'treemanifest', False):
2069 requirements.add('treemanifest') 2078 requirements.add('treemanifest')
2070 if ui.configbool('experimental', 'manifestv2', False): 2079 if ui.configbool('experimental', 'manifestv2', False):
2071 requirements.add('manifestv2') 2080 requirements.add('manifestv2')
2072 2081
2082 revlogv2 = ui.config('experimental', 'revlogv2')
2083 if revlogv2 == 'enable-unstable-format-and-corrupt-my-data':
2084 requirements.remove('revlogv1')
2085 # generaldelta is implied by revlogv2.
2086 requirements.discard('generaldelta')
2087 requirements.add(REVLOGV2_REQUIREMENT)
2088
2073 return requirements 2089 return requirements