hgext/mq.py
changeset 11270 457813cb3024
parent 11234 1ebe048902d9
child 11271 d1aca0863a9d
--- a/hgext/mq.py	Wed Jun 02 14:54:25 2010 +0200
+++ b/hgext/mq.py	Wed Jun 02 19:39:45 2010 +0200
@@ -238,8 +238,12 @@
     def __init__(self, ui, path, patchdir=None):
         self.basepath = path
         try:
-            fh = open(os.path.join(path, '.queue'))
-            curpath = os.path.join(path, fh.read().rstrip())
+            fh = open(os.path.join(path, 'patches.queue'))
+            cur = fh.read().rstrip()
+            if not cur:
+                curpath = os.path.join(path, 'patches')
+            else:
+                curpath = os.path.join(path, 'patches-' + cur)
         except IOError:
             curpath = os.path.join(path, 'patches')
         self.path = patchdir or curpath
@@ -2562,11 +2566,14 @@
     q = repo.mq
 
     _defaultqueue = 'patches'
-    _allqueues = '.queues'
-    _activequeue = '.queue'
+    _allqueues = 'patches.queues'
+    _activequeue = 'patches.queue'
 
     def _getcurrent():
-        return os.path.basename(q.path)
+        cur = os.path.basename(q.path)
+        if cur.startswith('patches-'):
+            cur = cur[8:]
+        return cur
 
     def _noqueues():
         try:
@@ -2595,7 +2602,8 @@
             raise util.Abort(_('patches applied - cannot set new queue active'))
 
         fh = repo.opener(_activequeue, 'w')
-        fh.write(name)
+        if name != 'patches':
+            fh.write(name)
         fh.close()
 
     def _addqueue(name):
@@ -2603,6 +2611,12 @@
         fh.write('%s\n' % (name,))
         fh.close()
 
+    def _validname(name):
+        for n in name:
+            if n in ':\\/.':
+                return False
+        return True
+
     if not name or opts.get('list'):
         current = _getcurrent()
         for queue in _getqueues():
@@ -2613,6 +2627,10 @@
                 ui.write('\n')
         return
 
+    if not _validname(name):
+        raise util.Abort(
+                _('invalid queue name, may not contain the characters ":\\/."'))
+
     existing = _getqueues()
 
     if name not in existing and opts.get('delete'):
@@ -2631,13 +2649,13 @@
         if name == current:
             raise util.Abort(_('cannot delete currently active queue'))
 
-        fh = repo.opener('.queues.new', 'w')
+        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('.queues.new'), repo.join(_allqueues))
+        util.rename(repo.join('patches.queues.new'), repo.join(_allqueues))
     else:
         _setactive(name)