diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py --- a/mercurial/localrepo.py +++ b/mercurial/localrepo.py @@ -431,8 +431,13 @@ extensions.loadall(ui) supportedrequirements = gathersupportedrequirements(ui) + + # We first validate the requirements are known. ensurerequirementsrecognized(requirements, supportedrequirements) + # Then we validate that the known set is reasonable to use together. + ensurerequirementscompatible(ui, requirements) + # At this point, we know we should be capable of opening the repository. # Now get on with doing that. @@ -494,6 +499,24 @@ hint=_(b'see https://mercurial-scm.org/wiki/MissingRequirement ' b'for more information')) +def ensurerequirementscompatible(ui, requirements): + """Validates that a set of recognized requirements is mutually compatible. + + Some requirements may not be compatible with others or require + config options that aren't enabled. This function is called during + repository opening to ensure that the set of requirements needed + to open a repository is sane and compatible with config options. + + Extensions can monkeypatch this function to perform additional + checking. + + ``error.RepoError`` should be raised on failure. + """ + if b'exp-sparse' in requirements and not sparse.enabled: + raise error.RepoError(_(b'repository is using sparse feature but ' + b'sparse is not enabled; enable the ' + b'"sparse" extensions to access')) + @interfaceutil.implementer(repository.completelocalrepository) class localrepository(object): @@ -625,11 +648,6 @@ if inst.errno != errno.ENOENT: raise - if 'exp-sparse' in self.requirements and not sparse.enabled: - raise error.RepoError(_('repository is using sparse feature but ' - 'sparse is not enabled; enable the ' - '"sparse" extensions to access')) - self.store = store.store( self.requirements, self.sharedpath, lambda base: vfsmod.vfs(base, cacheaudited=True)) diff --git a/mercurial/statichttprepo.py b/mercurial/statichttprepo.py --- a/mercurial/statichttprepo.py +++ b/mercurial/statichttprepo.py @@ -176,6 +176,7 @@ supportedrequirements = localrepo.gathersupportedrequirements(ui) localrepo.ensurerequirementsrecognized(requirements, supportedrequirements) + localrepo.ensurerequirementscompatible(ui, requirements) # setup store self.store = store.store(requirements, self.path, vfsclass)