svn add "already under version control"



Is there any way to force subversion to ignore the fact that a locally modified folder has been entirely replaced by something else and just tell it to save the current working copy over the repository as a new version?

For example:

mkdir directory # the real directory has several files inside it too

svn add directory

svn ci

 rm -rf directory # another program removes this directory
 
 mkdir directory # it then creates an entirely new directory with similar files to the original directory
 
 
 svn add directory 
svn: warning: 'directory' is already under version control

Subversion will not let me use the new directory because it already knows about a previous one. The only solutions I've found from this list or from google is to remove the directory and re-run svn update, but this loses any changes from the new directory.

Any suggestions appreciated.



There are two ways:
1. Just check out, overwrite with the new dir and checkin. You will have to manually take care of added/removed files.
2. Use svn_load_dirs (mentioned in the book under 'tracking vendor sources' or somesuch). This tries to automatically take care of added/deleted/moved files when replacing a folder.

It means a (invisible) folder .svn already exists with other svn data.Just (recursively) remove the .svn folder and it will work.

mv directory directory.new
svn up
svn remove directory
svn ci
mv directory.new directory
svn add directory
svn ci