[Updated] D9783: upgrade: take lock only for part where it's required
pulkit (Pulkit Goyal)
phabricator at mercurial-scm.org
Tue Jan 19 02:12:07 UTC 2021
Closed by commit rHG17176f64a03d: upgrade: take lock only for part where it's required (authored by pulkit).
This revision was automatically updated to reflect the committed changes.
REPOSITORY
rHG Mercurial
CHANGES SINCE LAST UPDATE
https://phab.mercurial-scm.org/D9783?vs=24881&id=25145
CHANGES SINCE LAST ACTION
https://phab.mercurial-scm.org/D9783/new/
REVISION DETAIL
https://phab.mercurial-scm.org/D9783
AFFECTED FILES
mercurial/upgrade.py
CHANGE DETAILS
diff --git a/mercurial/upgrade.py b/mercurial/upgrade.py
--- a/mercurial/upgrade.py
+++ b/mercurial/upgrade.py
@@ -244,17 +244,17 @@
def upgrade_share_to_safe(ui, hgvfs, storevfs, current_requirements):
"""Upgrades a share to use share-safe mechanism"""
wlock = None
+ store_requirements = localrepo._readrequires(storevfs, False)
+ # after upgrade, store requires will be shared, so lets find
+ # the requirements which are not present in store and
+ # write them to share's .hg/requires
+ diffrequires = current_requirements - store_requirements
+ # add share-safe requirement as it will mark the share as share-safe
+ diffrequires.add(requirementsmod.SHARESAFE_REQUIREMENT)
+ current_requirements.add(requirementsmod.SHARESAFE_REQUIREMENT)
try:
wlock = lockmod.trylock(ui, hgvfs, b'wlock', 0, 0)
- store_requirements = localrepo._readrequires(storevfs, False)
- # after upgrade, store requires will be shared, so lets find
- # the requirements which are not present in store and
- # write them to share's .hg/requires
- diffrequires = current_requirements - store_requirements
- # add share-safe requirement as it will mark the share as share-safe
- diffrequires.add(requirementsmod.SHARESAFE_REQUIREMENT)
scmutil.writerequires(hgvfs, diffrequires)
- 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-auto-upgrade-fail-error'):
@@ -280,15 +280,16 @@
):
"""Downgrades a share which use share-safe to not use it"""
wlock = None
+ source_requirements = localrepo._readrequires(sharedvfs, True)
+ # we cannot be 100% sure on which requirements were present in store when
+ # the source supported share-safe. However, we do know that working
+ # directory requirements were not there. Hence we remove them
+ source_requirements -= requirementsmod.WORKING_DIR_REQUIREMENTS
+ current_requirements |= source_requirements
+ current_requirements.remove(requirementsmod.SHARESAFE_REQUIREMENT)
+
try:
wlock = lockmod.trylock(ui, hgvfs, b'wlock', 0, 0)
- source_requirements = localrepo._readrequires(sharedvfs, True)
- # we cannot be 100% sure on which requirements were present in store when
- # the source supported share-safe. However, we do know that working
- # directory requirements were not there. Hence we remove them
- source_requirements -= requirementsmod.WORKING_DIR_REQUIREMENTS
- current_requirements |= source_requirements
- current_requirements.remove(requirementsmod.SHARESAFE_REQUIREMENT)
scmutil.writerequires(hgvfs, current_requirements)
ui.warn(_(b'repository downgraded to not use share-safe mode\n'))
except error.LockError as e:
To: pulkit, #hg-reviewers, marmoute, mharbison72
Cc: marmoute, mercurial-patches
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mercurial-scm.org/pipermail/mercurial-patches/attachments/20210119/6941f38b/attachment-0002.html>
More information about the Mercurial-patches
mailing list