Mercurial > public > mercurial-scm > hg-stable
diff hgext/mq.py @ 11271:d1aca0863a9d
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.
author | C?dric Duval <cedricduval@free.fr> |
---|---|
date | Thu, 03 Jun 2010 20:40:23 +0200 |
parents | 457813cb3024 |
children | d1908cb95a82 |
line wrap: on
line diff
--- a/hgext/mq.py Wed Jun 02 19:39:45 2010 +0200 +++ b/hgext/mq.py Thu Jun 03 20:40:23 2010 +0200 @@ -2633,17 +2633,17 @@ 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 @@ 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):