comparison mercurial/hg.py @ 15887:12dea4d998ec

bookmarks: primarily use repo lock, not wlock Bookmarks are repository data, not working directory data. Only the current bookmark is working directory data. Some lock shuffling is required to avoid lockout between the initial mock lock and locking of the localrepo instance that is created after copying.
author Mads Kiilerich <mads@kiilerich.com>
date Fri, 13 Jan 2012 02:30:43 +0100
parents cd956049fc14
children 60cb4f381a78
comparison
equal deleted inserted replaced
15886:a5917346c72e 15887:12dea4d998ec
277 self.dir_ = None 277 self.dir_ = None
278 def cleanup(self): 278 def cleanup(self):
279 if self.dir_: 279 if self.dir_:
280 self.rmtree(self.dir_, True) 280 self.rmtree(self.dir_, True)
281 281
282 srclock = destlock = dircleanup = None 282 srclock = destwlock = destlock = dircleanup = None
283 try: 283 try:
284 abspath = origsource 284 abspath = origsource
285 if islocal(origsource): 285 if islocal(origsource):
286 abspath = os.path.abspath(util.urllocalpath(origsource)) 286 abspath = os.path.abspath(util.urllocalpath(origsource))
287 287
323 destlock = copystore(ui, srcrepo, destpath) 323 destlock = copystore(ui, srcrepo, destpath)
324 324
325 # we need to re-init the repo after manually copying the data 325 # we need to re-init the repo after manually copying the data
326 # into it 326 # into it
327 destrepo = repository(remoteui(ui, peeropts), dest) 327 destrepo = repository(remoteui(ui, peeropts), dest)
328 # we need full recursive locking of the new repo instance
329 destwlock = destrepo.wlock()
330 if destlock:
331 destlock.release() # a little race condition - but no deadlock
332 destlock = destrepo.lock()
328 srcrepo.hook('outgoing', source='clone', 333 srcrepo.hook('outgoing', source='clone',
329 node=node.hex(node.nullid)) 334 node=node.hex(node.nullid))
330 else: 335 else:
331 try: 336 try:
332 destrepo = repository(remoteui(ui, peeropts), dest, 337 destrepo = repository(remoteui(ui, peeropts), dest,
399 destrepo.ui.status(_("updating to branch %s\n") % bn) 404 destrepo.ui.status(_("updating to branch %s\n") % bn)
400 _update(destrepo, uprev) 405 _update(destrepo, uprev)
401 406
402 return srcrepo, destrepo 407 return srcrepo, destrepo
403 finally: 408 finally:
404 release(srclock, destlock) 409 release(srclock, destlock, destwlock)
405 if dircleanup is not None: 410 if dircleanup is not None:
406 dircleanup.cleanup() 411 dircleanup.cleanup()
407 412
408 def _showstats(repo, stats): 413 def _showstats(repo, stats):
409 repo.ui.status(_("%d files updated, %d files merged, " 414 repo.ui.status(_("%d files updated, %d files merged, "