What determines end of lines in IDEA/Subversion?

I need to know how end of line (EOL) sequences are determined in IDEA/Subversion. The issue here being that Windoze (all variants) uses \r\n to indicate an end of line in text files, whereas every other modern operating system uses simply \n.

Even more confusing, Subversion can be configured to muck things up by sometimes changing EOLs on a per user basis (the so-called "native" EOL option; usually, but not always, a bad idea).

I had a previous posting on a related issue
    [http://www.intellij.net/forums/thread.jspa?threadID=276738&tstart=0]
in which someone pointed out to me one way that you can specify EOL in IDEA/Subversion.

But it turns out that there is at least these ways:

1) you can edit your code style (e.g. the Global code style) to create all new files with some EOL setting

2) you can configure IDEA/Subversion to have (or lack) the global property
    svn:eol-style
across all files. Do this in IDEA by
    Version Control --> Subversion --> Edit Properties

3) you can configure Subversion to have (or lack) the "semi-global" property
    svn:eol-style
across all files of a given type (i.e. extension) by editing your Subversion config file. Mine is located in
    C:\Documents and Settings\CaptainMidnight\Application Data\Subversion\config
and the relevant section of that file currently looks like


Obviously, you can comment out or uncomment whatever lines you want to achieve whatever effect you desire.

4) you can configure IDEA/Subversion to have (or lack) the local property
    svn:eol-style
for any given file. Do this in IDEA by going to your projeect pane and right click on the target file and select
    Subversion --> Edit Properties
and then edit as desired.


Question A: is the above list the complete number of ways that EOLs can be specified?


Question B: what is the priority order if multiple EOL specifications are present?

I wrote the above list in my guess as to what would be ascending order, if I were writing IDEA, namely:
    if 4) is used (local file has svn:eol-style defined) then this trumps all
    if 4) is absent but 3) is used (config file has svn:eol-style defined for your file type) then this trumps all
    if 4) and 3) are absent but 2) is used (IDEA file has svn:eol-style defined across all files) then this trumps all
    if 4), 3), and 2) are absent then 1) is used (your IDEA code setting)
Please confirm or deny the above understanding, if you know.


Question C: is there any way that you can query Subversion and find out 4), namely, which individual files have svn:eol-style specified for them? Altho I would prefer to do this from IDEA, it is OK if I need to use a Subversion command line tool.

5 comments
Comment actions Permalink

You seem to be confusing what functionality is provided by IntelliJ and what functionality is provided by Subversion.

The svn:eol-style property simply determines what processing is required at commit time so line endings don't cause a whole bunch of diffs. Subversion itself stores all files in the repository with LF endings.

Once the files are on your disk in your working copy then I would think IntelliJ's editor settings take over as far as what is displayed/saved.

To see properties in a directory in your working copy you can do:

svn proplist *

Please note this only does the current directory. I didn't find a way to do it recursively without scripting it (but didn't look to hard). Unless someone before you has messed with that property you probably won't find many files that have it. For files that don't have that property no translation is done (i.e. on my Windows box my source files have a LF ending...cofirmed with sed -ne 'l' with cygwin)

IMHO you are doing yourself a disservice messing with that, just leave it alone and fix the line endings in your scripts at build/deploy time.

Edited by: Michael Parmeley on Aug 11, 2008 11:21 PM

0
Comment actions Permalink

You seem to be confusing what functionality is provided by IntelliJ and what functionality is provided by Subversion.


I am not sure if that is accurate--I think that I correctly delineated what comes from IDEA and what comes from Svn.


The svn:eol-style property simply determines what processing is required at commit time so line endings don't cause a whole bunch of diffs. Subversion itself stores all files in the repository with LF endings.


This is news to me, and would probably be good for my team if true.

But I am not sure that that statement is correct. For instance,
    http://svnbook.red-bean.com/en/1.4/svn.advanced.props.file-portability.html
claims that
    "...to Subversion, bytes are bytes. This means that by default, Subversion doesn't pay any attention to the type of end-of-line (EOL) markers used in your files."

To me, that quote reads that svn does NOT automatically do any EOL conversion (e.g. to \n) at all. That reference goes on to explain that you can modify the default approach (e.g. via the means mentioned in my original posting), but there seems to be no default translation at all.

Once the files are on your disk in your working copy then I would think IntelliJ's editor settings take over as far as what is displayed/saved.


Sounds right.

To see properties in a directory in your working copy you can do:

svn proplist *

Please note this only does the current directory. I didn't find a way to do it recursively without scripting it (but didn't look to hard). Unless someone before you has messed with that property you probably won't find many files that have it. For files that don't have that property no translation is done (i.e. on my Windows box my source files have a LF ending...cofirmed with sed -ne 'l' with cygwin)


Thats helpful.

IMHO you are doing yourself a disservice messing with that, just leave it alone and fix the line endings in your scripts at build/deploy time.


I respectfully disagree. Your tip to correct line ends at build time is educational, but I do not think that it is a good idea to have to depend on a (often enormous and complicated) build process to guarantee that you can test, say, some shell file. You should simply be able to directly eecute the shell file and expect it to work.

What prompted my postings was a unix shell script file that kept on getting turned into PC format on my system. Ultimately, I found out that somehow it had gotten the svn:eol-style property set to native on that individual file, which is just wrong: a unix shell script should always be of \n format, even if you are using a windows box. Likewise, dos .bat files should always be in PC format even if you are on a unix box. All other text files are probably not too important, but your team might decide on a standard (unix probably best) and uniformly apply it.

0
Comment actions Permalink

From:

http://svnbook.red-bean.com/en/1.1/ch07s02.html

native

This causes the file to contain the EOL markers that are native to the operating system on which Subversion was run. In other words, if a user on a Windows machine checks out a working copy that contains a file with an svn:eol-style property set to native, that file will contain CRLF EOL markers. A Unix user checking out a working copy which contains the same file will see LF EOL markers in his copy of the file.

Note that Subversion will actually store the file in the repository using normalized LF EOL markers regardless of the operating system. This is basically transparent to the user, though.

I understand the problem you are having now, you were having an issue running a shell script you obtained from the repository. My "leave it alone" advice was based on the misunderstanding of the problem you were having. I thought you were having a problem running a shell script on a unix box that you wrote on a windows box in IntelliJ (I have had this issue before and I fix it at build time with ANT's fixcrlf task).

You should just beat whoever set native eol property on that shell script:-)

0
Comment actions Permalink

That is correct;
IDEA and Subversion have independent settings related to end of line characters;

I have few comments more;
concerning "Set Property" and "Edit Properties" options - they are always applied to concrete files; with them, you can set property for file or subtree (selecting "Update properties recursively")

concerning Subversion "config" file - it allows to configure Subversion properties to be set automatically for new files. It is used by IDEA and you can use this ability.

So, 4 items menthioned above is actually 3 (2 and 4 is the same);
and all options are not related to each other, so the question about priority of them is not correct.

0
Comment actions Permalink

concerning "Set Property" and "Edit Properties" options - they are always applied to concrete files; with them, you can set property for file or subtree (selecting "Update properties recursively")


Thats good to know.

Also, the functionality between IDEA'S Subversion "Set Property" and "Edit Properties" options is slightly different. For example, that "Update properties recursively" functionality only seems to be present in the "Set Property" option.

concerning Subversion "config" file - it allows to configure Subversion properties to be set automatically for new files.


OK, so it only applies for new files, just like the IDEA code style setting 1). I assume that it takes precedence over 1)?

So, 4 items menthioned above is actually 3 (2 and 4 is the same);


You are right, I confused those two.

and all options are not related to each other, so the question about priority of them is not correct.


Almost.

I think that this is now the correct summary: there are three possible ways to spcify EOLs in files. Two of them, methods 1) and 3) in my original post, only apply to new file creation with 3) taking precedence over 1). The final method, 2)/4) in my original post, applies only to existing files and it will trump the original EOL policy in place when the file was created. This final method can also be used not only on individual files, but also recursively on an entire directory.

0

Please sign in to leave a comment.