EOL end-of-line style fixer

Tags: python

A couple of years ago I got a script from Guido Wesdorp for cleaning up EOL styles in svn. I’ve long kept a private (modified) copy of that file and only later found out that it was from the pypy project: http://codespeak.net/pypy/dist/pypy/tool/fixeol (made by Holger Krekel).

The script fixes two things.

First fix: The script goes through a directory structure and fixes non-native EOL endings in non-binary files. So the windows line endings are gone if you work on linux (and probably vice versa, though I didn’t try).

When you use svn and you work with programmers both on windows and unix, you can get EOL differences. Windows uses \r\n, unix/osx only \n. There’s a simple fix to prevent any problems: use subversion’s native EOL style support, see for instance zope’s svn explanation on how to do it and why it is a good idea.

If you don’t have it set (mostly programmers working on linux) and you add a file, it doesn’t get the svn eol-style=native setting automatically. Once a windows programmer makes a checkout and saves it with his windows lineendings and you re-open it on unix, you get unneeded extras at the end of your line.

Second fix: The script goes through an svn directory structure and sets an svn eol-style=native property on every file that does not yet have it.

I’ve now packaged up the script with a setup.py and released it on pypi. The source code is on bitbucket.

 
vanrees.org logo

About me

My name is Reinout van Rees and I work a lot with Python (programming language) and Django (website framework). I live in The Netherlands and I'm happily married to Annie van Rees-Kooiman.

Weblog feeds

Most of my website content is in my weblog. You can keep up to date by subscribing to the automatic feeds (for instance with Google reader):