A dilemma at the end of the line?

Retweet Share on Facebook

I have a technical choice to make, and I don’t know the right answer – perhaps you can help me?

I apologise in advance for a long and technical posting – it will doubtless be “dumbed down” in the opinion of those who already understand the problem, and “full of mind-numbing details” for those who don’t.

The Line Endings Problem

Symbian has millions of lines of source code, stored in text files. We want that code to be accessible to people who have PCs running Windows, and we’d also like it to be accessible to people running Linux, but those systems use different sequences of characters in a file to indicate the end of a line of text. It’s a standard problem faced by any programming project which expects to work with both Windows and Linux, and it’s usually solved by having your source code control system automatically convert text files into the appropriate format for each user.

Symbian is using Mercurial to store the files, but a fundamental Mercurial design decision is not to associate a “type” with each file. Another design decision is to leave the content of the files unaltered – there is no automatic translation in core Mercurial.

The standard Mercurial solution to the line endings problem is to ask all Windows users to enable a Mercurial extension which recognises text files, converts them from Windows format to Linux format before storing them in the repository, and converts them from Linux format back into Windows format when extracting them onto your local disk.

All of the Symbian Platform code has been added into Mercurial from Windows using the Mercurial extension, so they are stored internally in the Linux format.: that’s spread over 100+ repositories. The Tools code has not been handled in that way, so a further 30+ repositories store files in the Windows format.

So What’s Your Dilemma?

At present, anyone working on the Symbian platform will be using Windows. Enabling the Mercurial extension has to be done by each user changing either their global Mercurial settings, or by altering the settings in individual local copies of the repositories. If you have the extension enabled and read from a repository in the Linux format, you will get warnings about line endings for every file that you extract.  If you have the extension enabled and commit changes into a repository which doesn’t use the Linux format internally, then Mercurial will think that you are changing all of the files, even the ones you haven’t altered.

Clearly, I need to decide on a policy and apply it to all of the Symbian repositories. Equally clearly, the sooner the decision is made, the less disruption it will cause.

I can see two choices (which I will call Red and Blue because I don’t know which one is better than the other).

Red Choice – Linux format

Insist on using the Linux format for the internal storage in all repositories, requiring all Windows users to enable the extension.

This ought to make the files look right for all systems, regardless of how simple your compiler or text editor program is. A small snag is that there are some text files which are just data for use on the Symbian devices, and where the code currently has to have the Windows line-endings. The estart.txt file used to configure the Symbian file server is the one we’ve uncovered so far, and we would probably need to change the code to make it work with Linux line endings as well.

This solution forces all Windows users to enable the extension, and as there are 130+ repositories that’s probably something they would do in their global settings. Some other Open Source projects have taken this approach, e.g. NetBeans, but not very many, and could be very annoying for developers if they also work with code that has a different policy.

Blue Choice – No translation

Insist that Windows users do not use the extension, and instead require everyone to deal with the files in the format that they find them.

This is likely to mean that all text files are in the Windows format, and we just have to hope that Linux compilers and text editors will respect that and behave nicely.

It avoids making Windows users change anything, but if they have enabled the extension we could still get the whole repository changing “accidentally” unless they explicitly disable the extension for the Symbian Foundation repositories.

Help…!

What is the “common practice” for other projects which use Mercurial and support development on Windows?

Do you favour the Red choice over the Blue choice? Is there a Green choice which I haven’t considered?

Please let me know what you think I should do….

Thanks,

William

Posted: May 13, 2009 at 9:07 pm

Last updated: February 8, 2010 at 4:15 pm

Categories: Dialogue, Tech Themes

Tags: ,

Short Link: http://wp.me/pqgpU-g2