[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Default eol styles

From: Casper Hornstrup <chorns_at_users.sourceforge.net>
Date: 2004-01-10 15:36:04 CET

Even though Subversion's svn:eol-style property makes it easier to
control eol styles than CVS, it can still be pretty difficult to do.
I have my code checked out onto a Windows machine, I'm using the
TortoiseSVN client on that machine and I do my editing using a
Windows IDE, but since I'm developing some partly unix-centric
software, I build it on a linux machine. Some files (like shell
scripts) need to have svn:eol-style=LF in order for them to be run
on linux. Now, for files added during normal development this may
be a small problem, but when doing vendor imports it is really a
pain to set the svn:eol-style property on the needed files. I would
prefer a server-side solution or a solution where the logic is
completely hidden in the Subversion client-side libraries since I
don't want to restict developers to be using a particular kind of
client. I have the following idea for a solution and would like
your opinion on it.

A new svn:eol-default (I'm not sure if the policy is to use plural
here, eg. "svn:eol-defaults") property that kan only be applied to
directories is created. It's value is a list of pattens (like for
the svn:ignore property) and eol styles. Eg.

<pattern>: <eol-style>
<pattern>: <eol-style>

<pattern> can for instance be configure, or *.sh.

<eol-style> can be native, CRLF, LF, or CR like for the svn:eol-style
property, but also none, so it can cancel an inherited (see below)

Patterns that are located closer to the top of the list have higher
priority than patterns closer to the bottom of the list. When a
filename is matched by a pattern the processing of the value list of
the svn:eol-default property stops. Eg. the following list:

*: native
*.sh: none

will result in the default eol style for all new files being native
(even for files with filenames that matches the pattern *.sh). If you
wanted to make the default eol style native for all new files except
files with filenames matching the pattern *.sh, and make the default
eol style none for files with filenames matching the pattern *.sh
then change the order of the list to:

*.sh: none
*: native

The svn:eol-default property can be inherited. When it is to be
decided what the default eol style for files in a specific directory
should be, first a combined list of patterns and eol styles is
created. The combined list is created from the values of the
svn:eol-default properties in all parent directories of the file all
the way to the repository root. svn:eol-default properties of
directories that are located lower in the directory hierarchy have
higher priority than svn:eol-default properties of directories that
are located higher in the directory hierarchy. The value of a
lower-level svn:eol-default property is located before the value of a
higher-level svn:eol-default property in the combined list. To find
the default eol style, the combined list is scanned from top to
bottom, searching for a pattern that will match the filename of the
file that is to be added to the repository. If the filename matches
a pattern, then the default eol style is determined by this entry. If
no pattern that matches the filename is found, then the default eol
style is none. The following is an example of use:

/repos (A)
/repos/vendor (B)
/repos/vendor/project1 (C)
/repos/vendor/project1/current (D)

svn:eol-default property values:

*: native

configure: LF
*.sh: LF

*.sh: none

(D) (has no svn:eol-default property)

A: All new files in this repository default to having the
   svn:eol-style with value native (unless overridden by a
   svn:eol-default property on a subdirectory).

B: New files that are added below the vendor directory that are named
   configure or have a .sh extension default to having the
   svn:eol-style with value LF.

C: Inherited from B and A we have the list (configure: LF),
   (*.sh: LF), (*: native). Now we add (*.sh: none) from C to the top
   of the list and we get the complete list: (*.sh: none),
   (configure: LF), (*.sh: LF), (*: native). So new files that are
   added below the vendor/project1 directory with filenames matching
   the pattern *.sh has no default eol style. Files named configure
   default to having svn:eol-style with value LF. All other files
   default to having svn:eol-style with value native.

D: The rules for default eol style are the same as for C.

When the user adds a file to a directory using svn add or svn import,
the svn:eol-style property is set according to the svn:eol-default
properties of the parent directories (unless it is a binary file). Of
course, if the user explicitly sets the svn:eol-style on a file, then
it will override the default eol style set for the directory in which
the file is added.

Casper Hornstrup

To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Sat Jan 10 15:40:02 2004

This is an archived mail posted to the Subversion Dev mailing list.