SubversionConfigurationForLineEndings
By default, subversion doesn't take client system line-endings into account. For example, if someone creates and checks in a file on a Unix-like system and someone checks out the file on Windows, the file will have Unix line endings. The Windows users' editing tools may not be able to make sense of the checked out file. If someone creates and checks in a file on a Windows system and someone checks out the file on a Unix-like system, the file will have Windows line endings. The Unix user may see extra control-M characters at the end of each line, which is pretty annoying.
A property can be set on files to indicate that native line endings should be used when a file is checked out:
svn propset svn:eol-style native foo.py
With this property set, Windows line endings will be used when the file is checked out on Windows and Unix line endings will be used when the file is checked out on Unix-like systems. The file is stored with Unix line endings in the repository.
Generally, this property should be set for text files, and only text files. The property can be set manually for each new files, but that's a lot of work. The setting of the property can be automated by editing your (the user's) subversion configuration file (http://svnbook.red-bean.com/svnbook/ch07.html#svn-ch-7-sect-1 ).
On Unix-like systems, the configuration file is
~/.subversion/config
. This is a "ini" style file. The recommended
way to get the eol-style property set is to include lines like this:
[miscellany] enable-auto-props = yes [auto-props] *.c = svn:eol-style=native *.cfg = svn:eol-style=native *.cpp = svn:eol-style=native *.h = svn:eol-style=native *.dsp = svn:eol-style=CRLF *.dsw = svn:eol-style=CRLF *.sh = svn:eol-style=native;svn:executable *.txt = svn:eol-style=native *.png = svn:mime-type=image/png *.jpg = svn:mime-type=image/jpeg Makefile = svn:eol-style=native
This is a bit problematic, because the file needs a line for each
suffix used. For example, we'd need to add entries for *.py
,
*.pt
, *.zcml
, and so on.
I prefer a simpler approach:
[miscellany] enable-auto-props = yes [auto-props] * = svn:eol-style=native
This tells subversion to set the property for all files. Remember that I said that the property should only be set for text files. It turns out that when a file is added, subversion detects whether the file is binary and sets a mime-type property that captures the fact that it is binary (in a slightly round-about way). This happens before the eol-style property is set. If you attempt to set the eol-style on a binary file, subversion will print an error and refuse to set the property. This means that it's harmless to automatically set the property for all files, because it won't be set if a file is binary. A problem with this approach is that, when adding multiple files, the add will stop after the first binary file, due to the error in setting the property.
For a longer discussion of this, see:
http://mail.zope.org/pipermail/zope-coders/2004-April/004815.html
(Note that the page of links lined to in that page is bogus, see: http://mail.zope.org/pipermail/zope-coders/2004-April/004817.html)
On Windows Subversion registers system-wide configuration values under the key HKEY_LOCAL_MACHINE\Software\Tigris.org\Subversion\Config, per-user configuration values should be stored under HKEY_CURRENT_USER\Software\Tigris.org\Subversion\Config. In the chapter Advanced Topics of the Subversion documentation there is a sample registration (reg) file.
In the user's application area there is a directory Subversion where you can have a config file. It has the same format like UNIX.
With the Tortoise SVN Client you can see the svn properties. Click on a svn file with your right mouse key. The property menu item has an additional register Tortoise Subversion. Here you can not only see the properties but also set properties for the file.