Mercurial > hg
changeset 46239:d159d0fafa78
sharesafe: introduce config to disallow outdated shares if upgrade fails
After this patch, we have config option to control all aspects of shares
when share source is upgraded or downgraded.
Differential Revision: https://phab.mercurial-scm.org/D9692
author | Pulkit Goyal <7895pulkit@gmail.com> |
---|---|
date | Fri, 08 Jan 2021 21:47:31 +0530 |
parents | 9796cf108e4e |
children | a42502e9ae6d |
files | mercurial/configitems.py mercurial/upgrade.py tests/test-share-safe.t |
diffstat | 3 files changed, 15 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/configitems.py Fri Jan 08 21:34:16 2021 +0530 +++ b/mercurial/configitems.py Fri Jan 08 21:47:31 2021 +0530 @@ -1084,6 +1084,11 @@ ) coreconfigitem( b'experimental', + b'sharesafe-auto-upgrade-fail-error', + default=False, +) +coreconfigitem( + b'experimental', b'sharesafe-warn-outdated-shares', default=True, )
--- a/mercurial/upgrade.py Fri Jan 08 21:34:16 2021 +0530 +++ b/mercurial/upgrade.py Fri Jan 08 21:47:31 2021 +0530 @@ -257,7 +257,12 @@ current_requirements.add(requirementsmod.SHARESAFE_REQUIREMENT) ui.warn(_(b'repository upgraded to use share-safe mode\n')) except error.LockError as e: - if ui.configbool(b'experimental', b'sharesafe-warn-outdated-shares'): + if ui.configbool(b'experimental', b'sharesafe-auto-upgrade-fail-error'): + raise error.Abort( + _(b'failed to upgrade share, got error: %s') + % stringutil.forcebytestr(e.strerror) + ) + elif ui.configbool(b'experimental', b'sharesafe-warn-outdated-shares'): ui.warn( _(b'failed to upgrade share, got error: %s\n') % stringutil.forcebytestr(e.strerror)
--- a/tests/test-share-safe.t Fri Jan 08 21:34:16 2021 +0530 +++ b/tests/test-share-safe.t Fri Jan 08 21:47:31 2021 +0530 @@ -557,6 +557,10 @@ o f3ba8b99bb6f897c87bbc1c07b75c6ddf43a4f77: added foo + $ hg log -GT "{node}: {desc}\n" -R ../nss-share --config experimental.sharesafe-auto-upgrade-shares=true --config experimental.sharesafe-auto-upgrade-fail-error=true + abort: failed to upgrade share, got error: Lock held + [255] + $ rm ../nss-share/.hg/wlock $ hg log -GT "{node}: {desc}\n" -R ../nss-share --config experimental.sharesafe-auto-upgrade-shares=true repository upgraded to use share-safe mode