You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@subversion.apache.org by Kamesh Jayachandran <ka...@collab.net> on 2006/06/21 13:58:22 UTC

Re: svn commit: r20191 - trunk/subversion/tests/cmdline

lgo@tigris.org wrote:
> Author: lgo
> Date: Tue Jun 20 11:06:49 2006
> New Revision: 20191
>
> Modified:
>    trunk/subversion/tests/cmdline/import_tests.py
>
> Log:
> * Followup to r17321 : Add a new test to validate the import handles the 
> eol style correctly, reported as issue 2433.
> Followup to r20179: make sure the import test also works on
> non-Windows platforms.
>
> * subversion/tests/cmdline/import_tests.py
>   (import_eol_style): add definition of CRLF for all 
>    platforms and use it to validate the diff output.
>
> Modified: trunk/subversion/tests/cmdline/import_tests.py
> URL: http://svn.collab.net/viewvc/svn/trunk/subversion/tests/cmdline/import_tests.py?pathrev=20191&r1=20190&r2=20191
> ==============================================================================
> --- trunk/subversion/tests/cmdline/import_tests.py	(original)
> +++ trunk/subversion/tests/cmdline/import_tests.py	Tue Jun 20 11:06:49 2006
> @@ -337,14 +337,21 @@
>    # -This is file test.dsp.
>    # +This is file test.dsp.
>    # +Extra line
> +  
> +  # eol styl of test.dsp is CRLF, so diff will use that too. Make sure we 
> +  # define CRLF in a platform independent way.
> +  if os.name == 'nt':
> +    crlf = '\n'
> +  else:
> +    crlf = '\r\n'
>   
Should it not be(Or my eyes are wrong!!),  windows  line endings are  
'\r\n' and unix(posix) ones are '\n' .

+  if os.name == 'nt':
+    crlf = '\r\n'
+  else:
+    crlf = '\n'

In anycase why not use os.linesep?

With regards
Kamesh Jayachandran

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org

Re: svn commit: r20191 - trunk/subversion/tests/cmdline

Posted by Kamesh Jayachandran <ka...@collab.net>.
May be for Mac we might have to put '\r' :)

Why not use open in binary mode to ensure this integerity so that we 
need not do all such juggling.
i.e
-open(imp_file_path, 'w').write("This is file test.dsp.\n")
+open(imp_file_path, 'wb').write("This is file test.dsp.\n")
I had verified the behaviour with Windows and Linux 'wb' works alike.

With regards
Kamesh Jayachandran
Malcolm Rowe wrote:
> On Wed, Jun 21, 2006 at 07:28:22PM +0530, Kamesh Jayachandran wrote:
>   
>>> +  # eol styl of test.dsp is CRLF, so diff will use that too. Make sure we 
>>> +  # define CRLF in a platform independent way.
>>> +  if os.name == 'nt':
>>> +    crlf = '\n'
>>> +  else:
>>> +    crlf = '\r\n'
>>>  
>>>       
>> Should it not be(Or my eyes are wrong!!),  windows  line endings are  
>> '\r\n' and unix(posix) ones are '\n' .
>>
>>     
>
> That's right, so I assume that in Python on Windows, '\n' expands to
> CR LF, while on saner platforms, it expands to LF.  The code above will
> therefore assign CR LF to the crlf variable on all platforms.
>
>   
>> In anycase why not use os.linesep?
>>
>>     
>
> Possibly because we want CRLF in all cases?
>
> Regards,
> Malcolm
>
>   

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org

Re: svn commit: r20191 - trunk/subversion/tests/cmdline

Posted by Malcolm Rowe <ma...@farside.org.uk>.
On Wed, Jun 21, 2006 at 07:28:22PM +0530, Kamesh Jayachandran wrote:
> >+  # eol styl of test.dsp is CRLF, so diff will use that too. Make sure we 
> >+  # define CRLF in a platform independent way.
> >+  if os.name == 'nt':
> >+    crlf = '\n'
> >+  else:
> >+    crlf = '\r\n'
> >  
> Should it not be(Or my eyes are wrong!!),  windows  line endings are  
> '\r\n' and unix(posix) ones are '\n' .
> 

That's right, so I assume that in Python on Windows, '\n' expands to
CR LF, while on saner platforms, it expands to LF.  The code above will
therefore assign CR LF to the crlf variable on all platforms.

> In anycase why not use os.linesep?
> 

Possibly because we want CRLF in all cases?

Regards,
Malcolm

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org

Re: svn commit: r20191 - trunk/subversion/tests/cmdline

Posted by Paul Burba <pa...@softlanding.com>.
Blair Zajac <bl...@orcaware.com> wrote on 06/21/2006 12:33:31 PM:

> Kamesh Jayachandran wrote:
> Not being an expert, is there any preference to os.name or sys.platform.
> 
> With cygwin's Python, what are the two values?  I don't have a Windows 
box to 
> test here.

$ python
Python 2.4.3 (#1, May 18 2006, 07:40:45)
[GCC 3.3.3 (cygwin special)] on cygwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys, os
>>> sys.platform
'cygwin'
>>> os.name
'posix'
>>>

Paul B.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org

Re: svn commit: r20191 - trunk/subversion/tests/cmdline

Posted by Blair Zajac <bl...@orcaware.com>.
Kamesh Jayachandran wrote:
> lgo@tigris.org wrote:
>> Author: lgo
>> Date: Tue Jun 20 11:06:49 2006
>> New Revision: 20191
>>
>> Modified:
>>    trunk/subversion/tests/cmdline/import_tests.py
>>
>> Log:
>> * Followup to r17321 : Add a new test to validate the import handles 
>> the eol style correctly, reported as issue 2433.
>> Followup to r20179: make sure the import test also works on
>> non-Windows platforms.
>>
>> * subversion/tests/cmdline/import_tests.py
>>   (import_eol_style): add definition of CRLF for all    platforms and 
>> use it to validate the diff output.
>>
>> Modified: trunk/subversion/tests/cmdline/import_tests.py
>> URL: 
>> http://svn.collab.net/viewvc/svn/trunk/subversion/tests/cmdline/import_tests.py?pathrev=20191&r1=20190&r2=20191 
>>
>> ============================================================================== 
>>
>> --- trunk/subversion/tests/cmdline/import_tests.py    (original)
>> +++ trunk/subversion/tests/cmdline/import_tests.py    Tue Jun 20 
>> 11:06:49 2006
>> @@ -337,14 +337,21 @@
>>    # -This is file test.dsp.
>>    # +This is file test.dsp.
>>    # +Extra line
>> +  +  # eol styl of test.dsp is CRLF, so diff will use that too. Make 
>> sure we +  # define CRLF in a platform independent way.
>> +  if os.name == 'nt':
>> +    crlf = '\n'
>> +  else:
>> +    crlf = '\r\n'
>>   
> Should it not be(Or my eyes are wrong!!),  windows  line endings are  
> '\r\n' and unix(posix) ones are '\n' .
> 
> +  if os.name == 'nt':
> +    crlf = '\r\n'
> +  else:
> +    crlf = '\n'
> 
> In anycase why not use os.linesep?

Another question is why os.name instead of sys.platform?

It appears that we use both throughout the code

svn-trunk$ find -name .svn -prune -o -type f | xargs grep 'os\.name' | wc
      24     126    2201
svn-trunk$ find -name .svn -prune -o -type f | xargs grep 'sys\.platform' | wc
      15      81    1200

Not being an expert, is there any preference to os.name or sys.platform.

With cygwin's Python, what are the two values?  I don't have a Windows box to 
test here.

Regards,
Blair

-- 
Blair Zajac, Ph.D.
<bl...@orcaware.com>
Subversion training, consulting and support
http://www.orcaware.com/svn/

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org