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

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'

Solution 1:

I had a problem like this when I deleted a folder (and sub-folders) and went to recreate them from scratch. You get this error from manually deleting and re-adding folders (whereas files seem to cope OK with this).

After some frustrating messing around, found I had to:
(using TortoiseSVN on Windows)

  1. Move conflicting folders out of working copy (so that I don't lose my work-in-progress)
  2. Do an svn update which added old files/folders back into working copy
  3. svn delete folder
  4. commit
  5. Copy new folder back into working copy (ensuring you delete all the .svn folders inside)
  6. commit

Unfortunately it (A) requires two commits, and (B) loses file revision history as it only tracks back to the recent re-add (unless someone can explain how to fix this). An alternative solution that works around these 2 issues is to skip steps 3 and 4, the only problem being that old/unnecessary files may still be present in your directory. You could delete these manually.

Would love to hear any additional insights others might have on this.

Simon.


[Update] OK, I had this same problem again just then, but the offending folder was NOT in the last commit, so an update didn't restore it. Instead I had to browse the repository and delete the offending folder. I could then add the folder back in and commit successfully.

Solution 2:

Had similar problem. To resolve it, updated from svn trunk with option of priority of local files.

svn update path/ --accept=mine-full

After You could commit as usual. Of course, be careful using it.

Solution 3:

already had this type of problem.

my solution was:

delete the folder from svn but keep a copy of the folder somewhere, commit the changes. in the backup-copy, delete recursively all the .svn-folders in it. for this you might run

#!/bin/bash

find -name '.svn' | while read directory;
do
    echo $directory;
    rm -rf "$directory";
done;

delete the local repository and re-check out entire project. don't know whether partial deletion/checkout are sufficient.

regards

Solution 4:

I managed to work around it by reverting back to the last version that I had the mysql directory in, then deleting the contents of the directory, putting the new contents in it, and checking the new information back in. Although I'm curious if anyone has a better explanation for what the heck was going on there.

Solution 5:

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.