Mercurial > public > mercurial-scm > hg-stable
diff mercurial/localrepo.py @ 46236:eec47efe219d
sharesafe: add functionality to automatically downgrade shares
Reasoning is same as previous patch which adds automatic upgrade support.
Downgrade is required as if automatic upgrade is enabled, all shares upgrade and
then source repository downgrades, shares won't work. We need to downgrade them.
Differential Revision: https://phab.mercurial-scm.org/D9680
author | Pulkit Goyal <7895pulkit@gmail.com> |
---|---|
date | Wed, 06 Jan 2021 18:31:16 +0530 |
parents | 0babe12ef35d |
children | 9796cf108e4e |
line wrap: on
line diff
--- a/mercurial/localrepo.py Wed Jan 06 16:18:06 2021 +0530 +++ b/mercurial/localrepo.py Wed Jan 06 18:31:16 2021 +0530 @@ -574,11 +574,26 @@ and requirementsmod.SHARESAFE_REQUIREMENT not in _readrequires(sharedvfs, True) ): - raise error.Abort( - _(b"share source does not support exp-sharesafe requirement") - ) - - requirements |= _readrequires(storevfs, False) + if ui.configbool( + b'experimental', b'sharesafe-auto-downgrade-shares' + ): + # prevent cyclic import localrepo -> upgrade -> localrepo + from . import upgrade + + upgrade.downgrade_share_to_non_safe( + ui, + hgvfs, + sharedvfs, + requirements, + ) + else: + raise error.Abort( + _( + b"share source does not support exp-sharesafe requirement" + ) + ) + else: + requirements |= _readrequires(storevfs, False) elif shared: sourcerequires = _readrequires(sharedvfs, False) if requirementsmod.SHARESAFE_REQUIREMENT in sourcerequires: