On Fri, Sep 5, 2008 at 8:37 AM, Julian Foad <julianfoad_at_btopenworld.com> wrote:
> On Fri, 2008-09-05 at 12:08 +0100, Julian Foad wrote:
>> Thanks, David. This makes my test pass. Committed in 32913.
>
> But my test (merge_tests.py 107) is now failing on Windows.
>
> Can anyone help me figure out why "propset svn:eol-style native" fails
> on Windows? The file content is supposed to have CR-LF line separators,
> as I think this is what Python's "os.linesep" is supposed to give.
>
> This is the code sequence (and it is before the part of the test where
> the bug fixed in r32913 manifested itself):
>
> [[[
> content1 = 'Line1\nLine2\r\n'
> content2 = 'Line1' + os.linesep + 'Line2' + os.linesep
>
> # In the source branch, create initial state and two successive
> changes
> svntest.main.file_write('A/mu', content1)
On Windows this creates a file like this:
[[[
Line1<CR><LF>
Line2<CR><CR><LF>
]]]
From the ActivePython 2.5.2 docs for os.linesep:
The string used to separate (or, rather, terminate) lines on the
current platform. This may be a single character, such as '\n' for
POSIX or '\r' for Mac OS, or multiple characters, for example, '\r\n'
for Windows. Do not use os.linesep as a line terminator when writing
files opened in text mode (the default); use a single '\n' instead, on
all platforms.
> rev1 = svn_commit('A/mu')
> svntest.main.file_write('A/mu', content2)
This creates a file like this:
[[[
Line1<CR><CR><LF>
Line2<CR><CR><LF>
]]]
Because os.linesep -> '\r\n' -> written as '\r\r\n' to a file opened
in text mode.
To fix the first file just call svntest.main.file_write() usings mode
'w' to open the file. This causes the explicit '\n' and '\r\n' to get
written without any conversion. To fix the second file just change
the content2 string to have explicit '\n's which get converted by
Python to the native eol:
[[[
Index: subversion/tests/cmdline/merge_tests.py
===================================================================
--- subversion/tests/cmdline/merge_tests.py (revision 32923)
+++ subversion/tests/cmdline/merge_tests.py (working copy)
@@ -12612,12 +12612,13 @@
wc_status.wc_dir = ''
content1 = 'Line1\nLine2\r\n'
- content2 = 'Line1' + os.linesep + 'Line2' + os.linesep
+ content2 = 'Line1\nLine2\n'
- # In the source branch, create initial state and two successive changes
- svntest.main.file_write('A/mu', content1)
+ # In the source branch, create initial state and two successive changes.
+ # Use binary mode to write the first file so no newline conversion occurs.
+ svntest.main.file_write('A/mu', content1, 'wb')
rev1 = svn_commit('A/mu')
- svntest.main.file_write('A/mu', content2)
+ svntest.main.file_write('A/mu', content2,)
rev2 = svn_commit('A/mu')
svn_propset('svn:eol-style', 'native', 'A/mu')
rev3 = svn_commit('A/mu')
]]]
Paul
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe_at_subversion.tigris.org
For additional commands, e-mail: dev-help_at_subversion.tigris.org
Received on 2008-09-05 15:42:27 CEST