2673 def _addqueue(name): |
2673 def _addqueue(name): |
2674 fh = repo.opener(_allqueues, 'a') |
2674 fh = repo.opener(_allqueues, 'a') |
2675 fh.write('%s\n' % (name,)) |
2675 fh.write('%s\n' % (name,)) |
2676 fh.close() |
2676 fh.close() |
2677 |
2677 |
|
2678 def _queuedir(name): |
|
2679 if name == 'patches': |
|
2680 return repo.join('patches') |
|
2681 else: |
|
2682 return repo.join('patches-' + name) |
|
2683 |
2678 def _validname(name): |
2684 def _validname(name): |
2679 for n in name: |
2685 for n in name: |
2680 if n in ':\\/.': |
2686 if n in ':\\/.': |
2681 return False |
2687 return False |
2682 return True |
2688 return True |
2702 raise util.Abort(_('queue "%s" already exists') % name) |
2708 raise util.Abort(_('queue "%s" already exists') % name) |
2703 if _noqueues(): |
2709 if _noqueues(): |
2704 _addqueue(_defaultqueue) |
2710 _addqueue(_defaultqueue) |
2705 _addqueue(name) |
2711 _addqueue(name) |
2706 _setactive(name) |
2712 _setactive(name) |
|
2713 elif opts.get('rename'): |
|
2714 current = _getcurrent() |
|
2715 if name == current: |
|
2716 raise util.Abort(_('can\'t rename "%s" to its current name') % name) |
|
2717 if name in existing: |
|
2718 raise util.Abort(_('queue "%s" already exists') % name) |
|
2719 |
|
2720 olddir = _queuedir(current) |
|
2721 newdir = _queuedir(name) |
|
2722 |
|
2723 if os.path.exists(newdir): |
|
2724 raise util.Abort(_('non-queue directory "%s" already exists') % |
|
2725 newdir) |
|
2726 |
|
2727 fh = repo.opener('patches.queues.new', 'w') |
|
2728 for queue in existing: |
|
2729 if queue == current: |
|
2730 fh.write('%s\n' % (name,)) |
|
2731 if os.path.exists(olddir): |
|
2732 util.rename(olddir, newdir) |
|
2733 else: |
|
2734 fh.write('%s\n' % (queue,)) |
|
2735 fh.close() |
|
2736 util.rename(repo.join('patches.queues.new'), repo.join(_allqueues)) |
|
2737 _setactivenocheck(name) |
2707 elif opts.get('delete'): |
2738 elif opts.get('delete'): |
2708 if name not in existing: |
2739 if name not in existing: |
2709 raise util.Abort(_('cannot delete queue that does not exist')) |
2740 raise util.Abort(_('cannot delete queue that does not exist')) |
2710 |
2741 |
2711 current = _getcurrent() |
2742 current = _getcurrent() |
3043 'qqueue': |
3074 'qqueue': |
3044 (qqueue, |
3075 (qqueue, |
3045 [ |
3076 [ |
3046 ('l', 'list', False, _('list all available queues')), |
3077 ('l', 'list', False, _('list all available queues')), |
3047 ('c', 'create', False, _('create new queue')), |
3078 ('c', 'create', False, _('create new queue')), |
|
3079 ('', 'rename', False, _('rename active queue')), |
3048 ('', 'delete', False, _('delete reference to queue')), |
3080 ('', 'delete', False, _('delete reference to queue')), |
3049 ], |
3081 ], |
3050 _('[OPTION] [QUEUE]')), |
3082 _('[OPTION] [QUEUE]')), |
3051 } |
3083 } |
3052 |
3084 |