##// END OF EJS Templates
mq/qqueue: enable renaming of active queue
"Yann E. MORIN" -
r11939:7d2ea5ce default
parent child Browse files
Show More
@@ -2675,6 +2675,12 b' def qqueue(ui, repo, name=None, **opts):'
2675 2675 fh.write('%s\n' % (name,))
2676 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 2684 def _validname(name):
2679 2685 for n in name:
2680 2686 if n in ':\\/.':
@@ -2704,6 +2710,31 b' def qqueue(ui, repo, name=None, **opts):'
2704 2710 _addqueue(_defaultqueue)
2705 2711 _addqueue(name)
2706 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 2738 elif opts.get('delete'):
2708 2739 if name not in existing:
2709 2740 raise util.Abort(_('cannot delete queue that does not exist'))
@@ -3045,6 +3076,7 b' cmdtable = {'
3045 3076 [
3046 3077 ('l', 'list', False, _('list all available queues')),
3047 3078 ('c', 'create', False, _('create new queue')),
3079 ('', 'rename', False, _('rename active queue')),
3048 3080 ('', 'delete', False, _('delete reference to queue')),
3049 3081 ],
3050 3082 _('[OPTION] [QUEUE]')),
@@ -35,6 +35,25 b' echo %% fail creating queue with already'
35 35 hg qqueue --create foo
36 36 hg qqueue
37 37
38 echo %% create new queue for rename
39 hg qqueue --create bar
40 hg qqueue
41
42 echo %% rename queue, same name
43 hg qqueue --rename bar
44
45 echo %% rename queue to existing
46 hg qqueue --rename foo
47
48 echo %% rename queue
49 hg qqueue --rename buz
50 hg qqueue
51
52 echo %% switch back to previous queue
53 hg qqueue foo
54 hg qqueue --delete buz
55 hg qqueue
56
38 57 echo %% unapplied patches
39 58 hg qun
40 59 echo c > a
@@ -19,6 +19,21 b' patches'
19 19 abort: queue "foo" already exists
20 20 foo (active)
21 21 patches
22 %% create new queue for rename
23 bar (active)
24 foo
25 patches
26 %% rename queue, same name
27 abort: can't rename "bar" to its current name
28 %% rename queue to existing
29 abort: queue "foo" already exists
30 %% rename queue
31 buz (active)
32 foo
33 patches
34 %% switch back to previous queue
35 foo (active)
36 patches
22 37 %% unapplied patches
23 38 %% fail switching back
24 39 abort: patches applied - cannot set new queue active
General Comments 0
You need to be logged in to leave comments. Login now