[PATCH 1 of 2 issue4711] mq: use %r to format illegal characters instead of manually quoting

Augie Fackler raf at durin42.com
Fri Jun 5 13:44:40 CDT 2015


# HG changeset patch
# User Augie Fackler <augie at google.com>
# Date 1433529112 14400
#      Fri Jun 05 14:31:52 2015 -0400
# Node ID 382ae2f4b576568a1542944565b1f3f3db9dae53
# Parent  a459d4e026c817bc0702470cd99bc06b40ac956e
mq: use %r to format illegal characters instead of manually quoting

This will make it easier to ban \r and \n in the next patch and still
have a sensible error message.

diff --git a/hgext/mq.py b/hgext/mq.py
--- a/hgext/mq.py
+++ b/hgext/mq.py
@@ -1104,7 +1104,7 @@ class queue(object):
                                  % prefix)
         for c in ('#', ':'):
             if c in name:
-                raise util.Abort(_('"%s" cannot be used in the name of a patch')
+                raise util.Abort(_('%r cannot be used in the name of a patch')
                                  % c)
 
     def checkpatchname(self, name, force=False):
diff --git a/tests/test-mq-qnew.t b/tests/test-mq-qnew.t
--- a/tests/test-mq-qnew.t
+++ b/tests/test-mq-qnew.t
@@ -108,8 +108,8 @@ plain headers
   abort: ".." 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
+  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/ (glob)
   abort: "foo" already exists as a directory
@@ -176,8 +176,8 @@ hg headers
   abort: ".." 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
+  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/ (glob)
   abort: "foo" already exists as a directory


More information about the Mercurial-devel mailing list