mirror of
https://github.com/facebook/sapling.git
synced 2024-10-07 15:27:13 +03:00
mq: prevent the creation of a queue whose name is already taken
Each check is moved under the code handling the relevant option, and a new one is added for --create. This fixes duplicated entries being added to the queues list.
This commit is contained in:
parent
ac61fc4db1
commit
06eedc4b82
12
hgext/mq.py
12
hgext/mq.py
@ -2633,17 +2633,17 @@ def qqueue(ui, repo, name=None, **opts):
|
||||
|
||||
existing = _getqueues()
|
||||
|
||||
if name not in existing and opts.get('delete'):
|
||||
raise util.Abort(_('cannot delete queue that does not exist'))
|
||||
elif name not in existing and not opts.get('create'):
|
||||
raise util.Abort(_('use --create to create a new queue'))
|
||||
|
||||
if opts.get('create'):
|
||||
if name in existing:
|
||||
raise util.Abort(_('queue "%s" already exists') % name)
|
||||
if _noqueues():
|
||||
_addqueue(_defaultqueue)
|
||||
_addqueue(name)
|
||||
_setactive(name)
|
||||
elif opts.get('delete'):
|
||||
if name not in existing:
|
||||
raise util.Abort(_('cannot delete queue that does not exist'))
|
||||
|
||||
current = _getcurrent()
|
||||
|
||||
if name == current:
|
||||
@ -2657,6 +2657,8 @@ def qqueue(ui, repo, name=None, **opts):
|
||||
fh.close()
|
||||
util.rename(repo.join('patches.queues.new'), repo.join(_allqueues))
|
||||
else:
|
||||
if name not in existing:
|
||||
raise util.Abort(_('use --create to create a new queue'))
|
||||
_setactive(name)
|
||||
|
||||
def reposetup(ui, repo):
|
||||
|
@ -28,6 +28,10 @@ echo %% switch queue
|
||||
hg qqueue foo
|
||||
hg qqueue
|
||||
|
||||
echo %% fail creating queue with already existing name
|
||||
hg qqueue --create foo
|
||||
hg qqueue
|
||||
|
||||
echo %% unapplied patches
|
||||
hg qun
|
||||
echo c > a
|
||||
|
@ -12,6 +12,10 @@ patch queue now empty
|
||||
%% switch queue
|
||||
foo (active)
|
||||
patches
|
||||
%% fail creating queue with already existing name
|
||||
abort: queue "foo" already exists
|
||||
foo (active)
|
||||
patches
|
||||
%% unapplied patches
|
||||
%% fail switching back
|
||||
abort: patches applied - cannot set new queue active
|
||||
|
Loading…
Reference in New Issue
Block a user