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

Re: fixing files committed with wrong eol-style

From: David Weintraub <qazwart_at_gmail.com>
Date: Wed, 14 Jul 2010 10:35:24 -0400

I have a pre-commit hook that will verify that particular files have
svn:eol-style set before allowing a commit. This way, you can make
sure that the property is set before anyone can do a commit.

What IDE are you using? If you're not using an IDE, what program
editor are you using. Please, tell me, for the sake of everything we
hold dear, that your developers aren't using Notepad for editing their
files. Please tell me they're not.

Your developers on your Windows side need a good program editor. A
good program editor handles various line endings with aplomb. That
means it doesn't matter if a file has either Windows or Unix style
line endings. The text editor will handle that and there is no need to
convert from one to the other. In fact, your Linux developers should
also be working with a similar editor.

I like VIM. It is powerful, flexible, fast and is available on both
Linux and Windows. Many people don't like VIM because it can take a
while to learn to use. You can try TextPad on Windows, but it is not a
free program. If you make this the official program on your site,
please pay the licensing fee! SciTE is also nice and it is open source
and free.

Many developers simply use Eclipse which provides a full IDE for both
Windows and Linux.

If you go the pre-commit hook root, you'll need to checkout all files,
change the line endings, add the pre-commit hook, and commit the
files. This will change the line endings stored in the Subversion
repository. And unfortunately, the "svn diff" command cannot be easily
set to ignore whitespace or the change in line endings.

However, you can specify your own diff command when using "svn diff"
either through the configuration or via the --diff-cmd parameter. And,
you could set that diff command to ignore line ending differences or
white spaces. You can use a batch or shell script to make calling that
program easier. I use vimdiff when I compare only one or two files.
This gives me a visual diff, and I call it via:

$ svn diff --diff-cmd mydiff <file>

Here's what mydiff looks like:

#! /usr/bin/env perl

use strict;
use warnings;

my $DIFF = "/usr/bin/vimdiff";

my $parameters = $#ARGV;
my $file1 = $ARGV[$parameters - 1];
my $file2 = $ARGV[$parameters];
my $title1 = $ARGV[$parameters - 4];
my $title2 = $ARGV[$parameters - 2];

my $title = "$title1 - $title2";
$title =~ s/\t/ /g;
$title =~ s/ /\\ /g;
my $command = qq($DIFF -c "set titlestring=$title" "$file1" "$file2");
system qq($command);

On Mon, Jul 12, 2010 at 10:58 PM, Kitching, Simon
<Simon.Kitching_at_airnz.co.nz> wrote:
> Hi,
>
>
>
> We’ve got a repository containing a lot of text-files committed from windows
> systems without the svn:eol-style=native setting. Some developers now want
> to work on these from Linux.
>
>
>
> I would therefore like to fix the eol-style. Writing a script on linux to
> find all the relevant files and run “propset svn:eol-style native” on them
> is easy enough. However I’ve noticed that if the change is committed from
> *linux*, then the commit not only changes the file properties, but also
> *every line-ending in the file*, ie looking at diffs between files before
> and after this change is now pointless. Committing exactly the same propset
> change from *windows* just sets the property without the whitespace
> problems; checking out on both systems then works as expected, and diffs
> between repository versions are sane.
>
>
>
> However it’s much more convenient to write and run this script from linux.
> Is there any way from linux to persuade subversion to just set the eol-style
> property?
>
>
>
> Thanks,
>
> Simon
>
> Good planets are hard to find - please think of the environment before you
> print this email.
> ____________________________________________________________________
> CAUTION - This message may contain privileged and confidential
> information intended only for the use of the addressee named above.
> If you are not the intended recipient of this message you are hereby
> notified that any use, dissemination, distribution or reproduction
> of this message is prohibited. If you have received this message in
> error please notify Air New Zealand immediately. Any views expressed
> in this message are those of the individual sender and may not
> necessarily reflect the views of Air New Zealand.
> _____________________________________________________________________
> For more information on the Air New Zealand Group, visit us online
> at http://www.airnewzealand.com
> _____________________________________________________________________
>

-- 
David Weintraub
qazwart_at_gmail.com
Received on 2010-07-14 16:36:02 CEST

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.