Mercurial > public > mercurial-scm > hg-stable
diff mercurial/localrepo.py @ 49224:2ab79873786e
auto-upgrade: introduce a way to auto-upgrade to/from share-safe
This is the first "automatic-upgrade" capability. In the following commits,
similar features are coming for other "fast to upgrade" formats.
This is different from the `safe-mismatch.source-not-safe` and
`safe-mismatch.source-safe` configuration that deal with mismatch between a
share and its share-source. Here we are dealing with mismatch between a
repository configuration and its actual format.
We will need further work for cases were the repository cannot be locked. A
basic protection is in place to avoid a infinite loop for now, but it will get
proper attention in a later changeset.
Differential Revision: https://phab.mercurial-scm.org/D12611
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Tue, 05 Apr 2022 05:19:47 +0200 |
parents | a932cad26d37 |
children | 2bcf5e14bb7e |
line wrap: on
line diff
--- a/mercurial/localrepo.py Fri Apr 15 22:02:07 2022 +0200 +++ b/mercurial/localrepo.py Tue Apr 05 05:19:47 2022 +0200 @@ -3516,11 +3516,20 @@ def instance(ui, path, create, intents=None, createopts=None): + + # prevent cyclic import localrepo -> upgrade -> localrepo + from . import upgrade + localpath = urlutil.urllocalpath(path) if create: createrepository(ui, localpath, createopts=createopts) - return makelocalrepository(ui, localpath, intents=intents) + def repo_maker(): + return makelocalrepository(ui, localpath, intents=intents) + + repo = repo_maker() + repo = upgrade.may_auto_upgrade(repo, repo_maker) + return repo def islocal(path):