##// END OF EJS Templates
mq/qqueue: commonalise the queue deletion code
"Yann E. MORIN" -
r11966:22f1994f default
parent child Browse files
Show More
@@ -2695,6 +2695,23 b' def qqueue(ui, repo, name=None, **opts):'
2695 2695 return False
2696 2696 return True
2697 2697
2698 def _delete(name):
2699 if name not in existing:
2700 raise util.Abort(_('cannot delete queue that does not exist'))
2701
2702 current = _getcurrent()
2703
2704 if name == current:
2705 raise util.Abort(_('cannot delete currently active queue'))
2706
2707 fh = repo.opener('patches.queues.new', 'w')
2708 for queue in existing:
2709 if queue == name:
2710 continue
2711 fh.write('%s\n' % (queue,))
2712 fh.close()
2713 util.rename(repo.join('patches.queues.new'), repo.join(_allqueues))
2714
2698 2715 if not name or opts.get('list'):
2699 2716 current = _getcurrent()
2700 2717 for queue in _getqueues():
@@ -2744,21 +2761,7 b' def qqueue(ui, repo, name=None, **opts):'
2744 2761 util.rename(repo.join('patches.queues.new'), repo.join(_allqueues))
2745 2762 _setactivenocheck(name)
2746 2763 elif opts.get('delete'):
2747 if name not in existing:
2748 raise util.Abort(_('cannot delete queue that does not exist'))
2749
2750 current = _getcurrent()
2751
2752 if name == current:
2753 raise util.Abort(_('cannot delete currently active queue'))
2754
2755 fh = repo.opener('patches.queues.new', 'w')
2756 for queue in existing:
2757 if queue == name:
2758 continue
2759 fh.write('%s\n' % (queue,))
2760 fh.close()
2761 util.rename(repo.join('patches.queues.new'), repo.join(_allqueues))
2764 _delete(name)
2762 2765 else:
2763 2766 if name not in existing:
2764 2767 raise util.Abort(_('use --create to create a new queue'))
General Comments 0
You need to be logged in to leave comments. Login now