Strange problem with Subversion - "File already exists" when trying to recreate a directory that USED to be in my repository

Viewed 117914

So - I used to have a directory called mysql a few revisions ago. I deleted it, and decided to start over - but when I try to create the new mysql directory - I keep running into the 'File Already Exists' error:

support:/etc/puppet/modules# mkdir mysql
support:/etc/puppet/modules# svn add mysql/
A         mysql
support:/etc/puppet/modules# svn commit -m " Test"
Adding         modules/mysql
svn: Commit failed (details follow):
svn: File already exists: filesystem '/var/lib/svn/puppet/db', transaction '11-r', path '/trunk/modules/mysql'
support:/etc/puppet/modules# svn delete mysql
svn: Use --force to override this restriction
svn: 'mysql' has local modifications
support:/etc/puppet/modules# svn --force delete mysql
D         mysql

I saw some other posts suggest forcing an update

support:/etc/puppet/modules# svn status
support:/etc/puppet/modules# svn update
At revision 11.
support:/etc/puppet/modules# svn mkdir mysql
A         mysql
support:/etc/puppet/modules# svn commit -m "Test"
Adding         modules/mysql
svn: Commit failed (details follow):
svn: File already exists: filesystem '/var/lib/svn/puppet/db', transaction '11-s', path '/trunk/modules/mysql'
14 Answers

This is a nasty one... mysterious error and no clear fix.

update/revert/commit did NOT work in my situation. I hadn't done anything weird - just some svn moves.

What DID work for me was:

svn remove offender
svn commit
cd ..
rm -fR parent
svn up parent
cd parent
svn remove offender again
svn commit
copy offender back in (minus .svn dirs)
svn add
svn commit

Weird to say the least. Basically, the svn remove --force offender wasn't doing completely removing for some reason. Which is sort of what the error message was saying. Only by removing the parent, then updating the parent, did this become obvious because then the offender reappeared! svn removing offender again then properly removed it.

As per Atmocreation's solution, except you don't need to re-checkout the whole project, which is useful if you have existing work in progress.

Let's say you have a working copy:

/foo/

which contains directories:

/foo/bar/baz

and you're getting the error message on commit:

svn: File already exists: filesystem '/foo/bar'

Backup the contents of bar somewhere:

mkdir -p ~/tmp/code_backup
cp -r /foo/bar ~/tmp/code_backup

Delete the .svn control directories from the backup. Make sure you get this command right, or you can do pretty serious damage!! Delete them manually if you're unsure.

find ~/tmp/code_backup/bar -name .svn -type d -exec rm -rf {} \;

Double check that the copy is identical:

diff -r -x .svn dist ~/tmp/code_backup/dist

Remove the offending directory from the working copy: cd /foo rm -rf bar

And then restore it from the repository:

cd /foo
svn update bar

Copy back the modified files from backup:

cp -r ~/tmp/code_backup/bar /foo/

You should now be able to commit without the error.

Related