mq: disallow # (and : on Windows) in patch names (issue2065) stable
authorSune Foldager <cryo@cyanite.org>
Thu, 04 Mar 2010 14:23:54 +0100
branchstable
changeset 10588 b0b19d61d79a
parent 10587 a48d256cc7d9
child 10589 92b8c79b34c2
mq: disallow # (and : on Windows) in patch names (issue2065)
hgext/mq.py
tests/test-mq-qnew
tests/test-mq-qnew.out
--- a/hgext/mq.py	Thu Mar 04 13:11:29 2010 +0100
+++ b/hgext/mq.py	Thu Mar 04 14:23:54 2010 +0100
@@ -813,7 +813,8 @@
     _reserved = ('series', 'status', 'guards')
     def check_reserved_name(self, name):
         if (name in self._reserved or name.startswith('.hg')
-            or name.startswith('.mq')):
+            or name.startswith('.mq') or '#' in name
+            or (os.name == 'nt' and ':' in name)):
             raise util.Abort(_('"%s" cannot be used as the name of a patch')
                              % name)
 
--- a/tests/test-mq-qnew	Thu Mar 04 13:11:29 2010 +0100
+++ b/tests/test-mq-qnew	Thu Mar 04 14:23:54 2010 +0100
@@ -19,6 +19,8 @@
     hg qnew status
     hg qnew guards
     hg qnew .hgignore
+    hg qnew .mqfoo
+    hg qnew 'foo#bar'
 
     hg qinit -c
 
--- a/tests/test-mq-qnew.out	Thu Mar 04 13:11:29 2010 +0100
+++ b/tests/test-mq-qnew.out	Thu Mar 04 14:23:54 2010 +0100
@@ -5,6 +5,8 @@
 abort: "status" cannot be used as the name of a patch
 abort: "guards" cannot be used as the name of a patch
 abort: ".hgignore" cannot be used as the name of a patch
+abort: ".mqfoo" cannot be used as the name of a patch
+abort: "foo#bar" cannot be used as the name of a patch
 % qnew with uncommitted changes
 uncommitted.patch
 % qnew implies add
@@ -52,6 +54,8 @@
 abort: "status" cannot be used as the name of a patch
 abort: "guards" cannot be used as the name of a patch
 abort: ".hgignore" cannot be used as the name of a patch
+abort: ".mqfoo" cannot be used as the name of a patch
+abort: "foo#bar" cannot be used as the name of a patch
 % qnew with uncommitted changes
 uncommitted.patch
 % qnew implies add