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

Re: EOL problems in cvs2svn converted repository

From: Ryan Schmidt <subversion-2018_at_ryandesign.com>
Date: Fri, 9 Feb 2018 15:19:08 -0600

On Feb 9, 2018, at 13:04, Bo Berglund wrote:

> OK, I think I will be OK with only setting the trunk version files
> correctly, if possible. After all this is what the consultants will
> use.
> And the development IDE:s seem to be able to cope fine with UNIX style
> source files (at least those I have tested with).
>
> Someone suggested that this would do it, but I am not sure:
>
> svn propset svn:eol-style 'native' -R *
>
> And he did not say how to do it, for example if I have to do that
> inside a working copy or if it is possible directly against the
> repository.

Like most nontrivial changes, you stage the changes in a working copy, examine the result and make sure everything looks ok, then you commit.

> In any case it seems like a dangerous proposition using * as file
> spec, since there are binary files also in the repo (icons, images,
> Windows executables, dll's etc).

Right, if you have binary files in the working copy, you don't want Subversion to corrupt them by performing eol translation on them, so you should not use "*"; you should be more selective about what types of files you apply the property to.

> So maybe a script like this (executed at the top of a working copy):
>
> svn propset svn:eol-style 'native' -R *.txt
> svn propset svn:eol-style 'native' -R *.c
> svn propset svn:eol-style 'native' -R *.h
> svn propset svn:eol-style 'native' -R *.pas
> svn propset svn:eol-style 'native' -R *.dpr
> svn propset svn:eol-style 'native' -R *.ini
> svn propset svn:eol-style 'native' -R *.conf
> svn propset svn:eol-style 'native' -R *.py
> svn propset svn:eol-style 'native' -R *.cpp
> svn propset svn:eol-style 'native' -R *.lpr
> svn propset svn:eol-style 'native' -R *.lpi
> svn propset svn:eol-style 'native' -R *.bat
> svn propset svn:eol-style 'native' -R *.iss
> svn propset svn:eol-style 'native' -R *.xml
> svn propset svn:eol-style 'native' -R *.gld
> svn propset svn:eol-style 'native' -R *.inc
> svn propset svn:eol-style 'native' -R *.dsp
> svn propset svn:eol-style 'native' -R *.dsw
>
> And then a svn commit
>
> Would this work?
> What would happen if a file already has the requested property?

Whether or not the file had the "svn:eol-style" property to begin with, running "svn propset svn:eol-style native" on it will set the "svn:eol-style" property to the value "native".

Your above proposal won't work, unless you don't have subdirectories. This is because your shell, not Subversion, expands globs like "*.txt", and only in the current directory.

For example, if your directory contains:

a.txt
b.txt
c/
c/d.txt

Then "svn propset svn:eol-style 'native' -R *.txt" will be expanded by the shell to "svn propset svn:eol-style 'native' -R a.txt b.txt" before Subversion ever sees the command. Then Subversion will set the property of a.txt and b.txt. The "-R" flag means "recursively process directories" but you didn't specify any directories, so no recursive directory processing occurs.

What you may want to do instead is use the "find" command to recursively locate the files you want to modify. (I'm presuming you're running these commands on a UNIX-like operating system; I don't know what the equivalent Windows commands might be.) For example, in your working copy:

find -E . -iregex '^.*\.(bat|c|conf|cpp|dpr|dsp|dsw|gld|h|inc|ini|iss|lpi|lpr|pas|py|txt|xml)$' -print0 | xargs -0 svn propset svn:eol-style native

Now you can use "svn status" and "svn diff" to inspect the staged changes in the working copy, and either commit them if satisfied, or "svn revert -R ." if you want to discard the changes.

This presumes that you can identify all of the files by extension. If your repository users use Windows, this might be the case. But on other operating systems, it's not unusual to find files with names like "README", with no ".txt" extension, which are nevertheless text files that you might want to apply the svn:eol-style property to. In that case, you may have to use a criterion other than extension to identify your files. For example, you could inspect the MIME type, and modify all files whose MIME type begins with "text/":

find . -type f | file --mime-type --no-pad --separator :: --files-from - | sed -n 's,:: text/.*$,,p' | tr '\n' '\0' | xargs -0 svn propset svn:eol-style native
Received on 2018-02-09 22:19:24 CET

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

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.