Show More
@@ -244,17 +244,17 b' def upgraderepo(' | |||||
244 | def upgrade_share_to_safe(ui, hgvfs, storevfs, current_requirements): |
|
244 | def upgrade_share_to_safe(ui, hgvfs, storevfs, current_requirements): | |
245 | """Upgrades a share to use share-safe mechanism""" |
|
245 | """Upgrades a share to use share-safe mechanism""" | |
246 | wlock = None |
|
246 | wlock = None | |
|
247 | store_requirements = localrepo._readrequires(storevfs, False) | |||
|
248 | # after upgrade, store requires will be shared, so lets find | |||
|
249 | # the requirements which are not present in store and | |||
|
250 | # write them to share's .hg/requires | |||
|
251 | diffrequires = current_requirements - store_requirements | |||
|
252 | # add share-safe requirement as it will mark the share as share-safe | |||
|
253 | diffrequires.add(requirementsmod.SHARESAFE_REQUIREMENT) | |||
|
254 | current_requirements.add(requirementsmod.SHARESAFE_REQUIREMENT) | |||
247 | try: |
|
255 | try: | |
248 | wlock = lockmod.trylock(ui, hgvfs, b'wlock', 0, 0) |
|
256 | wlock = lockmod.trylock(ui, hgvfs, b'wlock', 0, 0) | |
249 | store_requirements = localrepo._readrequires(storevfs, False) |
|
|||
250 | # after upgrade, store requires will be shared, so lets find |
|
|||
251 | # the requirements which are not present in store and |
|
|||
252 | # write them to share's .hg/requires |
|
|||
253 | diffrequires = current_requirements - store_requirements |
|
|||
254 | # add share-safe requirement as it will mark the share as share-safe |
|
|||
255 | diffrequires.add(requirementsmod.SHARESAFE_REQUIREMENT) |
|
|||
256 | scmutil.writerequires(hgvfs, diffrequires) |
|
257 | scmutil.writerequires(hgvfs, diffrequires) | |
257 | current_requirements.add(requirementsmod.SHARESAFE_REQUIREMENT) |
|
|||
258 | ui.warn(_(b'repository upgraded to use share-safe mode\n')) |
|
258 | ui.warn(_(b'repository upgraded to use share-safe mode\n')) | |
259 | except error.LockError as e: |
|
259 | except error.LockError as e: | |
260 | if ui.configbool(b'experimental', b'sharesafe-auto-upgrade-fail-error'): |
|
260 | if ui.configbool(b'experimental', b'sharesafe-auto-upgrade-fail-error'): | |
@@ -280,15 +280,16 b' def downgrade_share_to_non_safe(' | |||||
280 | ): |
|
280 | ): | |
281 | """Downgrades a share which use share-safe to not use it""" |
|
281 | """Downgrades a share which use share-safe to not use it""" | |
282 | wlock = None |
|
282 | wlock = None | |
|
283 | source_requirements = localrepo._readrequires(sharedvfs, True) | |||
|
284 | # we cannot be 100% sure on which requirements were present in store when | |||
|
285 | # the source supported share-safe. However, we do know that working | |||
|
286 | # directory requirements were not there. Hence we remove them | |||
|
287 | source_requirements -= requirementsmod.WORKING_DIR_REQUIREMENTS | |||
|
288 | current_requirements |= source_requirements | |||
|
289 | current_requirements.remove(requirementsmod.SHARESAFE_REQUIREMENT) | |||
|
290 | ||||
283 | try: |
|
291 | try: | |
284 | wlock = lockmod.trylock(ui, hgvfs, b'wlock', 0, 0) |
|
292 | wlock = lockmod.trylock(ui, hgvfs, b'wlock', 0, 0) | |
285 | source_requirements = localrepo._readrequires(sharedvfs, True) |
|
|||
286 | # we cannot be 100% sure on which requirements were present in store when |
|
|||
287 | # the source supported share-safe. However, we do know that working |
|
|||
288 | # directory requirements were not there. Hence we remove them |
|
|||
289 | source_requirements -= requirementsmod.WORKING_DIR_REQUIREMENTS |
|
|||
290 | current_requirements |= source_requirements |
|
|||
291 | current_requirements.remove(requirementsmod.SHARESAFE_REQUIREMENT) |
|
|||
292 | scmutil.writerequires(hgvfs, current_requirements) |
|
293 | scmutil.writerequires(hgvfs, current_requirements) | |
293 | ui.warn(_(b'repository downgraded to not use share-safe mode\n')) |
|
294 | ui.warn(_(b'repository downgraded to not use share-safe mode\n')) | |
294 | except error.LockError as e: |
|
295 | except error.LockError as e: |
General Comments 0
You need to be logged in to leave comments.
Login now