##// END OF EJS Templates
localrepo: move requirements reasonability testing to own function...
Gregory Szorc -
r39731:cb2dcfa5 default
parent child Browse files
Show More
@@ -431,8 +431,13 b' def makelocalrepository(baseui, path, in'
431 extensions.loadall(ui)
431 extensions.loadall(ui)
432
432
433 supportedrequirements = gathersupportedrequirements(ui)
433 supportedrequirements = gathersupportedrequirements(ui)
434
435 # We first validate the requirements are known.
434 ensurerequirementsrecognized(requirements, supportedrequirements)
436 ensurerequirementsrecognized(requirements, supportedrequirements)
435
437
438 # Then we validate that the known set is reasonable to use together.
439 ensurerequirementscompatible(ui, requirements)
440
436 # At this point, we know we should be capable of opening the repository.
441 # At this point, we know we should be capable of opening the repository.
437 # Now get on with doing that.
442 # Now get on with doing that.
438
443
@@ -494,6 +499,24 b' def ensurerequirementsrecognized(require'
494 hint=_(b'see https://mercurial-scm.org/wiki/MissingRequirement '
499 hint=_(b'see https://mercurial-scm.org/wiki/MissingRequirement '
495 b'for more information'))
500 b'for more information'))
496
501
502 def ensurerequirementscompatible(ui, requirements):
503 """Validates that a set of recognized requirements is mutually compatible.
504
505 Some requirements may not be compatible with others or require
506 config options that aren't enabled. This function is called during
507 repository opening to ensure that the set of requirements needed
508 to open a repository is sane and compatible with config options.
509
510 Extensions can monkeypatch this function to perform additional
511 checking.
512
513 ``error.RepoError`` should be raised on failure.
514 """
515 if b'exp-sparse' in requirements and not sparse.enabled:
516 raise error.RepoError(_(b'repository is using sparse feature but '
517 b'sparse is not enabled; enable the '
518 b'"sparse" extensions to access'))
519
497 @interfaceutil.implementer(repository.completelocalrepository)
520 @interfaceutil.implementer(repository.completelocalrepository)
498 class localrepository(object):
521 class localrepository(object):
499
522
@@ -625,11 +648,6 b' class localrepository(object):'
625 if inst.errno != errno.ENOENT:
648 if inst.errno != errno.ENOENT:
626 raise
649 raise
627
650
628 if 'exp-sparse' in self.requirements and not sparse.enabled:
629 raise error.RepoError(_('repository is using sparse feature but '
630 'sparse is not enabled; enable the '
631 '"sparse" extensions to access'))
632
633 self.store = store.store(
651 self.store = store.store(
634 self.requirements, self.sharedpath,
652 self.requirements, self.sharedpath,
635 lambda base: vfsmod.vfs(base, cacheaudited=True))
653 lambda base: vfsmod.vfs(base, cacheaudited=True))
@@ -176,6 +176,7 b' class statichttprepository(localrepo.loc'
176 supportedrequirements = localrepo.gathersupportedrequirements(ui)
176 supportedrequirements = localrepo.gathersupportedrequirements(ui)
177 localrepo.ensurerequirementsrecognized(requirements,
177 localrepo.ensurerequirementsrecognized(requirements,
178 supportedrequirements)
178 supportedrequirements)
179 localrepo.ensurerequirementscompatible(ui, requirements)
179
180
180 # setup store
181 # setup store
181 self.store = store.store(requirements, self.path, vfsclass)
182 self.store = store.store(requirements, self.path, vfsclass)
General Comments 0
You need to be logged in to leave comments. Login now