##// END OF EJS Templates
mq: take wlock when 'qqueue' is doing write operations...
Pierre-Yves David -
r29752:8a8c1c4b default
parent child Browse files
Show More
@@ -3354,53 +3354,54 b' def qqueue(ui, repo, name=None, **opts):'
3354 raise error.Abort(
3354 raise error.Abort(
3355 _('invalid queue name, may not contain the characters ":\\/."'))
3355 _('invalid queue name, may not contain the characters ":\\/."'))
3356
3356
3357 existing = _getqueues()
3357 with repo.wlock():
3358
3358 existing = _getqueues()
3359 if opts.get('create'):
3359
3360 if name in existing:
3360 if opts.get('create'):
3361 raise error.Abort(_('queue "%s" already exists') % name)
3361 if name in existing:
3362 if _noqueues():
3362 raise error.Abort(_('queue "%s" already exists') % name)
3363 _addqueue(_defaultqueue)
3363 if _noqueues():
3364 _addqueue(name)
3364 _addqueue(_defaultqueue)
3365 _setactive(name)
3365 _addqueue(name)
3366 elif opts.get('rename'):
3366 _setactive(name)
3367 current = _getcurrent()
3367 elif opts.get('rename'):
3368 if name == current:
3368 current = _getcurrent()
3369 raise error.Abort(_('can\'t rename "%s" to its current name')
3369 if name == current:
3370 % name)
3370 raise error.Abort(_('can\'t rename "%s" to its current name')
3371 if name in existing:
3371 % name)
3372 raise error.Abort(_('queue "%s" already exists') % name)
3372 if name in existing:
3373
3373 raise error.Abort(_('queue "%s" already exists') % name)
3374 olddir = _queuedir(current)
3374
3375 newdir = _queuedir(name)
3375 olddir = _queuedir(current)
3376
3376 newdir = _queuedir(name)
3377 if os.path.exists(newdir):
3377
3378 raise error.Abort(_('non-queue directory "%s" already exists') %
3378 if os.path.exists(newdir):
3379 newdir)
3379 raise error.Abort(_('non-queue directory "%s" already exists') %
3380
3380 newdir)
3381 fh = repo.vfs('patches.queues.new', 'w')
3381
3382 for queue in existing:
3382 fh = repo.vfs('patches.queues.new', 'w')
3383 if queue == current:
3383 for queue in existing:
3384 fh.write('%s\n' % (name,))
3384 if queue == current:
3385 if os.path.exists(olddir):
3385 fh.write('%s\n' % (name,))
3386 util.rename(olddir, newdir)
3386 if os.path.exists(olddir):
3387 else:
3387 util.rename(olddir, newdir)
3388 fh.write('%s\n' % (queue,))
3388 else:
3389 fh.close()
3389 fh.write('%s\n' % (queue,))
3390 util.rename(repo.join('patches.queues.new'), repo.join(_allqueues))
3390 fh.close()
3391 _setactivenocheck(name)
3391 util.rename(repo.join('patches.queues.new'), repo.join(_allqueues))
3392 elif opts.get('delete'):
3392 _setactivenocheck(name)
3393 _delete(name)
3393 elif opts.get('delete'):
3394 elif opts.get('purge'):
3395 if name in existing:
3396 _delete(name)
3394 _delete(name)
3397 qdir = _queuedir(name)
3395 elif opts.get('purge'):
3398 if os.path.exists(qdir):
3396 if name in existing:
3399 shutil.rmtree(qdir)
3397 _delete(name)
3400 else:
3398 qdir = _queuedir(name)
3401 if name not in existing:
3399 if os.path.exists(qdir):
3402 raise error.Abort(_('use --create to create a new queue'))
3400 shutil.rmtree(qdir)
3403 _setactive(name)
3401 else:
3402 if name not in existing:
3403 raise error.Abort(_('use --create to create a new queue'))
3404 _setactive(name)
3404
3405
3405 def mqphasedefaults(repo, roots):
3406 def mqphasedefaults(repo, roots):
3406 """callback used to set mq changeset as secret when no phase data exists"""
3407 """callback used to set mq changeset as secret when no phase data exists"""
General Comments 0
You need to be logged in to leave comments. Login now