line endings and Cygwin

Martin Pool mbp at sourcefrog.net
Wed Apr 13 13:05:28 BST 2005


On Wed, 2005-04-13 at 10:05 +0200, Fredrik Lundh wrote:
> Martin Pool wrote:
> 
> > > May I suggest that all files below .bzr should be opened in binary mode
> > > only - readlines() and friends under win32 handle this just fine, and
> > > this way it is easy to copy files around. This is also especially
> > > important if your repo is on a FAT mounted partion and gets accessed
> > > from multiple operating systems.
> >
> > Just to be clear, do you mean that readlines() on Windows will do the
> > right thing on a file with only \n markers, even if it's opened in
> > binary mode?
> 
> yes.  opening files with the "b" flag switches off \r\n <=> \n conversion, but all
> text-oriented methods will still work properly (i.e. treat \n as a line break).

So readlines() will just naively split on \n, and any code that cares
will need to strip off the \r\n to get the text alone.

I guess no one has files with only \r anymore(?)

> I suggest sticking to
> 
>     "rb" and "wb" for all binary files, and for files with "opaque" contents
>     "rb" and "wb" for text files that are created and maintained by bzr itself
>     "rU" and "wU" (or maybe just "r" and "w"), for text files from external sources

OK.

I think people will eventually want bzr to write out working copies in
wierd formats but I hope to defer that for a bit longer.

(Why oh why did Microsoft ever think CRLF was a good idea?...)

-- 
Martin

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
Url : https://lists.ubuntu.com/archives/bazaar/attachments/20050413/9c09828a/attachment.pgp 


More information about the bazaar mailing list