my strategy on implementing line-endings (eol) support

Alexander Belchenko bialix at ukr.net
Mon Mar 31 12:06:43 BST 2008


Here is short description of what I'm doing and planning to do on the subject.

In my conviction there is 4 types of files:

1) binary files
2) text files with exact line-endings
3) text files with native/LF/CRLF/CR line-endings
4) unicode text files similar to 3.

Files of type 1 is not affected by eol at all. For files of type 2 we never do any
line-endings conversion. In this regard they are very close to type 1, except for
them we are able to do textual diff.

Files of type 3 is my primary goal. Files of type 4 is also planned to support, but
after I have workable and robust solution for type 3.

In my conviction files of type 3 is actually eol-agnostic. They should not care what
actual eol symbol is used, and eol property is just suggest what line-endings file
content should have when bzr do a checkout or update. It means that if user do
a checkout on Windows with settings of eol to LF, and then he used text editor that
force eol to CRLF, then bzr should ignore difference in eol at all. I.e. if user just
open file in editor, don't change anything but save it with different eol, then
file should not be shown as changed by status or diff commands.

This is exactly my strategy on eol support:

a) Internally bzr stores files of type 3 with LF-only eol
b) When file is created on disk bzr will use file property called 'eol' to determine
   what kind of eol user needs
c) status and diff operations should ignore eol, and treat them as LF
d) commit convert all kind of eol to LF and store file with LF eol in repository.

Today I have simple implementation of file properties. I sent preview last weekend,
but since then I made some improvements when I'm working on eol code. If you want to
play with file properties it's better to use this branch:
https://code.launchpad.net/~bialix/bzr/bzr.prop.simple

Today I have implementation of (b), and starting to work on (c). The code in bzrlib
is a bit complicated for me and I have difficulties to understand it, so I'm stepping through
it with debugger and try understand how it worked and where I should hook in my own code.
It's not very fast. If somebody willing to help it will be simply fantastic.
My development branch is:
https://code.launchpad.net/~bialix/bzr/eol




More information about the bazaar mailing list