[PATCH 2 of 3] mq: be more explicit on invalid patch name message

Idan Kamara idankk86 at gmail.com
Fri Apr 29 14:32:44 CDT 2011


# HG changeset patch
# User Idan Kamara <idankk86 at gmail.com>
# Date 1304104873 -10800
# Node ID 72f1f40451cb4ec16a268f233c0ceaee98f61de7
# Parent  4c3cbfdd055c611192b9bbed1086b4a78e3c42e8
mq: be more explicit on invalid patch name message

diff -r 4c3cbfdd055c -r 72f1f40451cb hgext/mq.py
--- a/hgext/mq.py	Fri Apr 29 22:21:13 2011 +0300
+++ b/hgext/mq.py	Fri Apr 29 22:21:13 2011 +0300
@@ -854,10 +854,18 @@
 
     _reserved = ('series', 'status', 'guards', '.', '..')
     def check_reserved_name(self, name):
-        if (name in self._reserved or name.startswith('.hg')
-            or name.startswith('.mq') or '#' in name or ':' in name):
+        if name in self._reserved:
             raise util.Abort(_('"%s" cannot be used as the name of a patch')
                              % name)
+        for prefix in ('.hg', '.mq'):
+            if name.startswith(prefix):
+                raise util.Abort(_('patch name cannot begin with "%s"')
+                                 % prefix)
+        for c in ('#', ':'):
+            if c in name:
+                raise util.Abort(_('"%s" cannot be used in the name of a patch')
+                                 % c)
+
 
     def new(self, repo, patchfn, *pats, **opts):
         """options:
diff -r 4c3cbfdd055c -r 72f1f40451cb tests/test-mq-qnew.t
--- a/tests/test-mq-qnew.t	Fri Apr 29 22:21:13 2011 +0300
+++ b/tests/test-mq-qnew.t	Fri Apr 29 22:21:13 2011 +0300
@@ -106,10 +106,10 @@
   abort: "guards" cannot be used as the name of a patch
   abort: "." cannot be used as the name of a patch
   abort: ".." 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
-  abort: "foo:bar" cannot be used as the name of a patch
+  abort: patch name cannot begin with ".hg"
+  abort: patch name cannot begin with ".mq"
+  abort: "#" cannot be used in the name of a patch
+  abort: ":" cannot be used in the name of a patch
   % qnew with name containing slash
   abort: path ends in directory separator: foo/
   abort: "foo" already exists as a directory
@@ -173,10 +173,10 @@
   abort: "guards" cannot be used as the name of a patch
   abort: "." cannot be used as the name of a patch
   abort: ".." 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
-  abort: "foo:bar" cannot be used as the name of a patch
+  abort: patch name cannot begin with ".hg"
+  abort: patch name cannot begin with ".mq"
+  abort: "#" cannot be used in the name of a patch
+  abort: ":" cannot be used in the name of a patch
   % qnew with name containing slash
   abort: path ends in directory separator: foo/
   abort: "foo" already exists as a directory


More information about the Mercurial-devel mailing list