Patchwork [2,of,9] heredoctest: do not append extra newline character to continuation line

login
register
mail settings
Submitter Yuya Nishihara
Date Sept. 28, 2014, 2:17 p.m.
Message ID <b665907351a96e88e848.1411913837@mimosa>
Download mbox | patch
Permalink /patch/5997/
State Superseded
Headers show

Comments

Yuya Nishihara - Sept. 28, 2014, 2:17 p.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1411884815 -32400
#      Sun Sep 28 15:13:35 2014 +0900
# Node ID b665907351a96e88e84841fd97b9ddceec9c476e
# Parent  62ea66130006851da1973c55c6bfcb5bfbb7f856
heredoctest: do not append extra newline character to continuation line

Trailing newline characters are kept in lines.
Mads Kiilerich - Sept. 28, 2014, 3:18 p.m.
On 09/28/2014 04:17 PM, Yuya Nishihara wrote:
> # HG changeset patch
> # User Yuya Nishihara <yuya@tcha.org>
> # Date 1411884815 -32400
> #      Sun Sep 28 15:13:35 2014 +0900
> # Node ID b665907351a96e88e84841fd97b9ddceec9c476e
> # Parent  62ea66130006851da1973c55c6bfcb5bfbb7f856
> heredoctest: do not append extra newline character to continuation line
>
> Trailing newline characters are kept in lines.

In which cases will this make a difference? When was the extra newline 
shown?

/Mads

> diff --git a/tests/heredoctest.py b/tests/heredoctest.py
> --- a/tests/heredoctest.py
> +++ b/tests/heredoctest.py
> @@ -10,7 +10,7 @@ while lines:
>           snippet = l[4:]
>           while lines and lines[0].startswith('... '):
>               l = lines.pop(0)
> -            snippet += "\n" + l[4:]
> +            snippet += l[4:]
>           c = compile(snippet, '<heredoc>', 'single')
>           try:
>               exec c in globalvars
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@selenic.com
> http://selenic.com/mailman/listinfo/mercurial-devel
Yuya Nishihara - Sept. 28, 2014, 3:32 p.m.
(resend with CC to mercurial-devel)

On Sun, 28 Sep 2014 17:18:24 +0200, Mads Kiilerich wrote:
> On 09/28/2014 04:17 PM, Yuya Nishihara wrote:
> > # HG changeset patch
> > # User Yuya Nishihara <yuya@tcha.org>
> > # Date 1411884815 -32400
> > #      Sun Sep 28 15:13:35 2014 +0900
> > # Node ID b665907351a96e88e84841fd97b9ddceec9c476e
> > # Parent  62ea66130006851da1973c55c6bfcb5bfbb7f856
> > heredoctest: do not append extra newline character to continuation line
> >
> > Trailing newline characters are kept in lines.
> 
> In which cases will this make a difference? When was the extra newline 
> shown?

The following code in PATCH 5 didn't work because patch content was corrupted
by extra newlines.

+  ...     patch = """
+  ... # HG changeset patch
+  ... # User test
+  ... # Date 0 0
+  ... # Node ID c103a3dec114d882c98382d684d8af798d09d857
+  ... # Parent  0000000000000000000000000000000000000000
+  ... 1
+  ... 
+  ... diff -r 000000000000 -r c103a3dec114 a
+  ... --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+  ... +++ b/a	Thu Jan 01 00:00:00 1970 +0000
+  ... @@ -0,0 +1,1 @@
+  ... +1
+  ... """
+  ...     runcommand(server, ['import', '-'], input=cStringIO.StringIO(patch))
Idan Kamara - Sept. 28, 2014, 7:44 p.m.
On Sun, Sep 28, 2014 at 8:32 AM, Yuya Nishihara <yuya@tcha.org> wrote:
>
> (resend with CC to mercurial-devel)
>
> On Sun, 28 Sep 2014 17:18:24 +0200, Mads Kiilerich wrote:
> > On 09/28/2014 04:17 PM, Yuya Nishihara wrote:
> > > # HG changeset patch
> > > # User Yuya Nishihara <yuya@tcha.org>
> > > # Date 1411884815 -32400
> > > #      Sun Sep 28 15:13:35 2014 +0900
> > > # Node ID b665907351a96e88e84841fd97b9ddceec9c476e
> > > # Parent  62ea66130006851da1973c55c6bfcb5bfbb7f856
> > > heredoctest: do not append extra newline character to continuation line
> > >
> > > Trailing newline characters are kept in lines.
> >
> > In which cases will this make a difference? When was the extra newline
> > shown?
>
> The following code in PATCH 5 didn't work because patch content was corrupted
> by extra newlines.
>
> +  ...     patch = """
> +  ... # HG changeset patch
> +  ... # User test
> +  ... # Date 0 0
> +  ... # Node ID c103a3dec114d882c98382d684d8af798d09d857
> +  ... # Parent  0000000000000000000000000000000000000000
> +  ... 1
> +  ...
> +  ... diff -r 000000000000 -r c103a3dec114 a
> +  ... --- /dev/null    Thu Jan 01 00:00:00 1970 +0000
> +  ... +++ b/a  Thu Jan 01 00:00:00 1970 +0000
> +  ... @@ -0,0 +1,1 @@
> +  ... +1
> +  ... """
> +  ...     runcommand(server, ['import', '-'], input=cStringIO.StringIO(patch))

Might be worth to add a small test for heredoctest.py as you fixed two
bugs in this series.
Yuya Nishihara - Sept. 29, 2014, 12:18 p.m.
On Sun, 28 Sep 2014 12:44:21 -0700, Idan Kamara wrote:
> On Sun, Sep 28, 2014 at 8:32 AM, Yuya Nishihara <yuya@tcha.org> wrote:
> > On Sun, 28 Sep 2014 17:18:24 +0200, Mads Kiilerich wrote:
> > > On 09/28/2014 04:17 PM, Yuya Nishihara wrote:
> > > > # HG changeset patch
> > > > # User Yuya Nishihara <yuya@tcha.org>
> > > > # Date 1411884815 -32400
> > > > #      Sun Sep 28 15:13:35 2014 +0900
> > > > # Node ID b665907351a96e88e84841fd97b9ddceec9c476e
> > > > # Parent  62ea66130006851da1973c55c6bfcb5bfbb7f856
> > > > heredoctest: do not append extra newline character to continuation line
> > > >
> > > > Trailing newline characters are kept in lines.
> > >
> > > In which cases will this make a difference? When was the extra newline
> > > shown?
> >
> > The following code in PATCH 5 didn't work because patch content was corrupted
> > by extra newlines.
> >
> > +  ...     patch = """
> > +  ... # HG changeset patch
> > +  ... # User test
> > +  ... # Date 0 0
> > +  ... # Node ID c103a3dec114d882c98382d684d8af798d09d857
> > +  ... # Parent  0000000000000000000000000000000000000000
> > +  ... 1
> > +  ...
> > +  ... diff -r 000000000000 -r c103a3dec114 a
> > +  ... --- /dev/null    Thu Jan 01 00:00:00 1970 +0000
> > +  ... +++ b/a  Thu Jan 01 00:00:00 1970 +0000
> > +  ... @@ -0,0 +1,1 @@
> > +  ... +1
> > +  ... """
> > +  ...     runcommand(server, ['import', '-'], input=cStringIO.StringIO(patch))
> 
> Might be worth to add a small test for heredoctest.py as you fixed two
> bugs in this series.

Sure.  I made V2 of PATCH 1 and 2.

Patch

diff --git a/tests/heredoctest.py b/tests/heredoctest.py
--- a/tests/heredoctest.py
+++ b/tests/heredoctest.py
@@ -10,7 +10,7 @@  while lines:
         snippet = l[4:]
         while lines and lines[0].startswith('... '):
             l = lines.pop(0)
-            snippet += "\n" + l[4:]
+            snippet += l[4:]
         c = compile(snippet, '<heredoc>', 'single')
         try:
             exec c in globalvars