Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I fix the SVN import line endings error?

I have to import an huge SVN repository that I have to transfer from one server to another. So I exported it from the old server:

svnadmin dump . > archive.svn

and imported it on the new one:

svnadmin load . < archive.svn

In the middle of the import process I got this error:

Cannot accept non-LF line endings in 'svn:ignore' property

How can I fix this? I have full control of both servers.

like image 334
xsl Avatar asked Apr 23 '12 10:04

xsl


People also ask

What SVN import does?

The svn import command is a quick way to copy an unversioned tree of files into a repository, creating intermediate directories as necessary. svn import doesn't require a working copy, and your files are immediately committed to the repository.


2 Answers

With a little gymnastics you can work around this using svnsync, which has the ability to fix the EOLs. Let's say that your repository is dumped in archive.svn.

First create the repository to load the repo back, ignoring the EOL problems:

svnadmin create repo
svnadmin load repo < archive.svn --bypass-prop-validation

Now create a new repository for copying into:

svnadmin create repo-fixed

svnsync requires some pre-commit hook, even if you don't use it, so just use your editor to create an empty one in repo-fixed/hooks/pre-revprop-change:

#!/bin/sh
exit 0

Initialize the destination repository for svnsync:

svnsync init file:///path/to/repo-fixed file:///path/to/repo

Now copy the entire repository over:

svnsync sync file:///path/to/repo-fixed

Whew! svnsync will even give you good news: NOTE: Normalized svn:* properties to LF line endings (Why the Subversion team didn't update svnadmin to do the same normalization is a mystery to me.)

Once that's done, dump the new repository:

svnadmin dump repo-fixed > archive-fixed.svn

You now have archive-fixed.svn, which should be identical to archive.svn except the EOLs have been fixed as needed.

(Optional) You can now remove the temporary repository you used for svnsync:

rm -rf repo-fixed

Update It turns out if you load this new dump, your Subversion client gets an error: Repository UUID does not match expected UUID. You'll have to use svnadmin setuuid ... to change the UUID ID to what it used to be.

(This post is a culmination of a multitude of snippets and partial solutions I found around the web. Thanks to all the people who knew more than I did; I just put it all together.)

See also:

  • Copying subversion repositories with history using svnsync
  • https://stackoverflow.com/a/28472420/421049
  • https://svn.apache.org/repos/asf/subversion/trunk/notes/svnsync.txt
like image 89
Garret Wilson Avatar answered Oct 21 '22 22:10

Garret Wilson


You have 2 options, repair the source or disable prop validation.

Repairing the source (svn:log and svn:ignore):

sed -e '/^svn:log$/,/^K / s/^M/ /' -e '/^svn:ignore$/,/^PROPS-END$/ s/^M/\n/' archive.svn > repaired-archive.svn

svnadmin load . < repaired-archive.svn

Where ^M is a control character, that means 0D in hex. To get it use ^V^M (control V control M) instead ^M (circumflex M or control M)

Disabling prop validation:

svnadmin load --bypass-prop-validation . < archive.svn
like image 23
ventura10 Avatar answered Oct 21 '22 23:10

ventura10