##// END OF EJS Templates
mq: fix naming issues for qqueue directories
Henrik Stuart -
r11270:457813cb default
parent child Browse files
Show More
@@ -238,8 +238,12 b' class queue(object):'
238 def __init__(self, ui, path, patchdir=None):
238 def __init__(self, ui, path, patchdir=None):
239 self.basepath = path
239 self.basepath = path
240 try:
240 try:
241 fh = open(os.path.join(path, '.queue'))
241 fh = open(os.path.join(path, 'patches.queue'))
242 curpath = os.path.join(path, fh.read().rstrip())
242 cur = fh.read().rstrip()
243 if not cur:
244 curpath = os.path.join(path, 'patches')
245 else:
246 curpath = os.path.join(path, 'patches-' + cur)
243 except IOError:
247 except IOError:
244 curpath = os.path.join(path, 'patches')
248 curpath = os.path.join(path, 'patches')
245 self.path = patchdir or curpath
249 self.path = patchdir or curpath
@@ -2562,11 +2566,14 b' def qqueue(ui, repo, name=None, **opts):'
2562 q = repo.mq
2566 q = repo.mq
2563
2567
2564 _defaultqueue = 'patches'
2568 _defaultqueue = 'patches'
2565 _allqueues = '.queues'
2569 _allqueues = 'patches.queues'
2566 _activequeue = '.queue'
2570 _activequeue = 'patches.queue'
2567
2571
2568 def _getcurrent():
2572 def _getcurrent():
2569 return os.path.basename(q.path)
2573 cur = os.path.basename(q.path)
2574 if cur.startswith('patches-'):
2575 cur = cur[8:]
2576 return cur
2570
2577
2571 def _noqueues():
2578 def _noqueues():
2572 try:
2579 try:
@@ -2595,7 +2602,8 b' def qqueue(ui, repo, name=None, **opts):'
2595 raise util.Abort(_('patches applied - cannot set new queue active'))
2602 raise util.Abort(_('patches applied - cannot set new queue active'))
2596
2603
2597 fh = repo.opener(_activequeue, 'w')
2604 fh = repo.opener(_activequeue, 'w')
2598 fh.write(name)
2605 if name != 'patches':
2606 fh.write(name)
2599 fh.close()
2607 fh.close()
2600
2608
2601 def _addqueue(name):
2609 def _addqueue(name):
@@ -2603,6 +2611,12 b' def qqueue(ui, repo, name=None, **opts):'
2603 fh.write('%s\n' % (name,))
2611 fh.write('%s\n' % (name,))
2604 fh.close()
2612 fh.close()
2605
2613
2614 def _validname(name):
2615 for n in name:
2616 if n in ':\\/.':
2617 return False
2618 return True
2619
2606 if not name or opts.get('list'):
2620 if not name or opts.get('list'):
2607 current = _getcurrent()
2621 current = _getcurrent()
2608 for queue in _getqueues():
2622 for queue in _getqueues():
@@ -2613,6 +2627,10 b' def qqueue(ui, repo, name=None, **opts):'
2613 ui.write('\n')
2627 ui.write('\n')
2614 return
2628 return
2615
2629
2630 if not _validname(name):
2631 raise util.Abort(
2632 _('invalid queue name, may not contain the characters ":\\/."'))
2633
2616 existing = _getqueues()
2634 existing = _getqueues()
2617
2635
2618 if name not in existing and opts.get('delete'):
2636 if name not in existing and opts.get('delete'):
@@ -2631,13 +2649,13 b' def qqueue(ui, repo, name=None, **opts):'
2631 if name == current:
2649 if name == current:
2632 raise util.Abort(_('cannot delete currently active queue'))
2650 raise util.Abort(_('cannot delete currently active queue'))
2633
2651
2634 fh = repo.opener('.queues.new', 'w')
2652 fh = repo.opener('patches.queues.new', 'w')
2635 for queue in existing:
2653 for queue in existing:
2636 if queue == name:
2654 if queue == name:
2637 continue
2655 continue
2638 fh.write('%s\n' % (queue,))
2656 fh.write('%s\n' % (queue,))
2639 fh.close()
2657 fh.close()
2640 util.rename(repo.join('.queues.new'), repo.join(_allqueues))
2658 util.rename(repo.join('patches.queues.new'), repo.join(_allqueues))
2641 else:
2659 else:
2642 _setactive(name)
2660 _setactive(name)
2643
2661
@@ -44,4 +44,17 b' hg qpop -a'
44 hg qqueue patches
44 hg qqueue patches
45 hg qqueue foo --delete
45 hg qqueue foo --delete
46 hg qqueue
46 hg qqueue
47
48 echo %% tricky cases
49 hg qqueue store --create
50 hg qnew test
51 hg qqueue
52 hg qpop -a
53 hg qqueue patches
54 hg qun
55
56 echo %% invalid names
57 hg qqueue test/../../bar --create
58 hg qqueue . --create
59
47 cd ..
60 cd ..
@@ -21,3 +21,12 b' abort: cannot delete currently active qu'
21 popping otherstuff
21 popping otherstuff
22 patch queue now empty
22 patch queue now empty
23 patches (active)
23 patches (active)
24 %% tricky cases
25 patches
26 store (active)
27 popping test
28 patch queue now empty
29 somestuff
30 %% invalid names
31 abort: invalid queue name, may not contain the characters ":\/."
32 abort: invalid queue name, may not contain the characters ":\/."
General Comments 0
You need to be logged in to leave comments. Login now