Patchwork [2,of,2,issue4711] mq: ban \r and \n in patch names (issue4711)

login
register
mail settings
Submitter Augie Fackler
Date June 5, 2015, 6:44 p.m.
Message ID <3386861c6b3ce4847c38.1433529881@arthedain.pit.corp.google.com>
Download mbox | patch
Permalink /patch/9526/
State Accepted
Headers show

Comments

Augie Fackler - June 5, 2015, 6:44 p.m.
# HG changeset patch
# User Augie Fackler <augie@google.com>
# Date 1433529298 14400
#      Fri Jun 05 14:34:58 2015 -0400
# Node ID 3386861c6b3ce4847c38168f5612c23f1bc38514
# Parent  382ae2f4b576568a1542944565b1f3f3db9dae53
mq: ban \r and \n in patch names (issue4711)

This is at best crazy, and at worst will break things like the series
file. Let's just stop the madness.
Matt Mackall - June 5, 2015, 7:54 p.m.
On Fri, 2015-06-05 at 14:44 -0400, Augie Fackler wrote:
> # HG changeset patch
> # User Augie Fackler <augie@google.com>
> # Date 1433529298 14400
> #      Fri Jun 05 14:34:58 2015 -0400
> # Node ID 3386861c6b3ce4847c38168f5612c23f1bc38514
> # Parent  382ae2f4b576568a1542944565b1f3f3db9dae53
> mq: ban \r and \n in patch names (issue4711)
> 
> This is at best crazy, and at worst will break things like the series
> file. Let's just stop the madness.

These are queued for default, thanks.

Patch

diff --git a/hgext/mq.py b/hgext/mq.py
--- a/hgext/mq.py
+++ b/hgext/mq.py
@@ -1102,7 +1102,7 @@  class queue(object):
             if name.startswith(prefix):
                 raise util.Abort(_('patch name cannot begin with "%s"')
                                  % prefix)
-        for c in ('#', ':'):
+        for c in ('#', ':', '\r', '\n'):
             if c in name:
                 raise util.Abort(_('%r cannot be used in the name of a patch')
                                  % c)
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
@@ -21,6 +21,7 @@ 
   >     hg qnew .mqfoo
   >     hg qnew 'foo#bar'
   >     hg qnew 'foo:bar'
+  >     hg qnew "`echo foo; echo bar`"
   > 
   >     hg qinit -c
   > 
@@ -110,6 +111,7 @@  plain headers
   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: '\n' 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
@@ -178,6 +180,7 @@  hg headers
   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: '\n' 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