changeset 11966:22f1994fb669

mq/qqueue: commonalise the queue deletion code
author "Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
date Wed, 18 Aug 2010 23:34:28 +0200
parents 79bd860b8eb7
children 6e3875a80533
files hgext/mq.py
diffstat 1 files changed, 18 insertions(+), 15 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/mq.py	Thu Aug 19 16:34:12 2010 +0200
+++ b/hgext/mq.py	Wed Aug 18 23:34:28 2010 +0200
@@ -2695,6 +2695,23 @@
                 return False
         return True
 
+    def _delete(name):
+        if name not in existing:
+            raise util.Abort(_('cannot delete queue that does not exist'))
+
+        current = _getcurrent()
+
+        if name == current:
+            raise util.Abort(_('cannot delete currently active queue'))
+
+        fh = repo.opener('patches.queues.new', 'w')
+        for queue in existing:
+            if queue == name:
+                continue
+            fh.write('%s\n' % (queue,))
+        fh.close()
+        util.rename(repo.join('patches.queues.new'), repo.join(_allqueues))
+
     if not name or opts.get('list'):
         current = _getcurrent()
         for queue in _getqueues():
@@ -2744,21 +2761,7 @@
         util.rename(repo.join('patches.queues.new'), repo.join(_allqueues))
         _setactivenocheck(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:
-            raise util.Abort(_('cannot delete currently active queue'))
-
-        fh = repo.opener('patches.queues.new', 'w')
-        for queue in existing:
-            if queue == name:
-                continue
-            fh.write('%s\n' % (queue,))
-        fh.close()
-        util.rename(repo.join('patches.queues.new'), repo.join(_allqueues))
+        _delete(name)
     else:
         if name not in existing:
             raise util.Abort(_('use --create to create a new queue'))