Show More
@@ -245,6 +245,7 b' def upgrade_share_to_safe(ui, hgvfs, sto' | |||||
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) |
|
247 | store_requirements = localrepo._readrequires(storevfs, False) | |
|
248 | original_crequirements = current_requirements.copy() | |||
248 | # after upgrade, store requires will be shared, so lets find |
|
249 | # after upgrade, store requires will be shared, so lets find | |
249 | # the requirements which are not present in store and |
|
250 | # the requirements which are not present in store and | |
250 | # write them to share's .hg/requires |
|
251 | # write them to share's .hg/requires | |
@@ -254,6 +255,19 b' def upgrade_share_to_safe(ui, hgvfs, sto' | |||||
254 | current_requirements.add(requirementsmod.SHARESAFE_REQUIREMENT) |
|
255 | current_requirements.add(requirementsmod.SHARESAFE_REQUIREMENT) | |
255 | try: |
|
256 | try: | |
256 | wlock = lockmod.trylock(ui, hgvfs, b'wlock', 0, 0) |
|
257 | wlock = lockmod.trylock(ui, hgvfs, b'wlock', 0, 0) | |
|
258 | # some process might change the requirement in between, re-read | |||
|
259 | # and update current_requirements | |||
|
260 | locked_requirements = localrepo._readrequires(hgvfs, True) | |||
|
261 | if locked_requirements != original_crequirements: | |||
|
262 | removed = current_requirements - locked_requirements | |||
|
263 | # update current_requirements in place because it's passed | |||
|
264 | # as reference | |||
|
265 | current_requirements -= removed | |||
|
266 | current_requirements |= locked_requirements | |||
|
267 | diffrequires = current_requirements - store_requirements | |||
|
268 | # add share-safe requirement as it will mark the share as share-safe | |||
|
269 | diffrequires.add(requirementsmod.SHARESAFE_REQUIREMENT) | |||
|
270 | current_requirements.add(requirementsmod.SHARESAFE_REQUIREMENT) | |||
257 | scmutil.writerequires(hgvfs, diffrequires) |
|
271 | scmutil.writerequires(hgvfs, diffrequires) | |
258 | ui.warn(_(b'repository upgraded to use share-safe mode\n')) |
|
272 | ui.warn(_(b'repository upgraded to use share-safe mode\n')) | |
259 | except error.LockError as e: |
|
273 | except error.LockError as e: | |
@@ -281,6 +295,7 b' def downgrade_share_to_non_safe(' | |||||
281 | """Downgrades a share which use share-safe to not use it""" |
|
295 | """Downgrades a share which use share-safe to not use it""" | |
282 | wlock = None |
|
296 | wlock = None | |
283 | source_requirements = localrepo._readrequires(sharedvfs, True) |
|
297 | source_requirements = localrepo._readrequires(sharedvfs, True) | |
|
298 | original_crequirements = current_requirements.copy() | |||
284 | # we cannot be 100% sure on which requirements were present in store when |
|
299 | # 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 |
|
300 | # the source supported share-safe. However, we do know that working | |
286 | # directory requirements were not there. Hence we remove them |
|
301 | # directory requirements were not there. Hence we remove them | |
@@ -290,6 +305,17 b' def downgrade_share_to_non_safe(' | |||||
290 |
|
305 | |||
291 | try: |
|
306 | try: | |
292 | wlock = lockmod.trylock(ui, hgvfs, b'wlock', 0, 0) |
|
307 | wlock = lockmod.trylock(ui, hgvfs, b'wlock', 0, 0) | |
|
308 | # some process might change the requirement in between, re-read | |||
|
309 | # and update current_requirements | |||
|
310 | locked_requirements = localrepo._readrequires(hgvfs, True) | |||
|
311 | if locked_requirements != original_crequirements: | |||
|
312 | removed = current_requirements - locked_requirements | |||
|
313 | # update current_requirements in place because it's passed | |||
|
314 | # as reference | |||
|
315 | current_requirements -= removed | |||
|
316 | current_requirements |= locked_requirements | |||
|
317 | current_requirements |= source_requirements | |||
|
318 | current_requirements -= set(requirementsmod.SHARESAFE_REQUIREMENT) | |||
293 | scmutil.writerequires(hgvfs, current_requirements) |
|
319 | scmutil.writerequires(hgvfs, current_requirements) | |
294 | ui.warn(_(b'repository downgraded to not use share-safe mode\n')) |
|
320 | ui.warn(_(b'repository downgraded to not use share-safe mode\n')) | |
295 | except error.LockError as e: |
|
321 | except error.LockError as e: |
General Comments 0
You need to be logged in to leave comments.
Login now