##// END OF EJS Templates
unshare: use context manager for locks...
Martin von Zweigbergk -
r41436:bc843e25 default
parent child Browse files
Show More
@@ -282,25 +282,20 b' def unshare(ui, repo):'
282 called.
282 called.
283 """
283 """
284
284
285 destlock = None
285 with repo.lock():
286 lock = repo.lock()
287 try:
288 # we use locks here because if we race with commit, we
286 # we use locks here because if we race with commit, we
289 # can end up with extra data in the cloned revlogs that's
287 # can end up with extra data in the cloned revlogs that's
290 # not pointed to by changesets, thus causing verify to
288 # not pointed to by changesets, thus causing verify to
291 # fail
289 # fail
292
293 destlock = copystore(ui, repo, repo.path)
290 destlock = copystore(ui, repo, repo.path)
294
291 with destlock or util.nullcontextmanager():
295 sharefile = repo.vfs.join('sharedpath')
296 util.rename(sharefile, sharefile + '.old')
297
292
298 repo.requirements.discard('shared')
293 sharefile = repo.vfs.join('sharedpath')
299 repo.requirements.discard('relshared')
294 util.rename(sharefile, sharefile + '.old')
300 repo._writerequirements()
295
301 finally:
296 repo.requirements.discard('shared')
302 destlock and destlock.release()
297 repo.requirements.discard('relshared')
303 lock and lock.release()
298 repo._writerequirements()
304
299
305 # Removing share changes some fundamental properties of the repo instance.
300 # Removing share changes some fundamental properties of the repo instance.
306 # So we instantiate a new repo object and operate on it rather than
301 # So we instantiate a new repo object and operate on it rather than
General Comments 0
You need to be logged in to leave comments. Login now