Vianney Lecroart - acemtp Playground
How to remove permanently a file from subversion (SVN) repository

When you do a svn delete, in fact the file stays in the repository history and can be restored.

I had to remove some directories from a repository because they were too big so I’ll share you the process I used:

First, you need to connect to the server where the svn repository is.

We dump the repository into a file called svn_full. It’s a text file that contains all information of the repository :
svnadmin dump /PATH/TO/THE/REPOSITORY > svn_full

Then we have to filter the dumped file to remove directories you want to remove. Read this page to understand the parameters.
cat svn_full | svndumpfilter exclude --drop-empty-revs --renumber-revs /trunk/PATH1/ /trunk/PATH2/ > svn_filtered 2>log

Now the svn_filtered files is the dump files without the paths trunk/PATH1/ and /trunk/PATH2/. Check the log file that was generated to see if all files was removed as you wanted.

We have to remove the old repository:
mv /PATH/TO/THE/REPOSITORY /PATH/TO/THE/REPOSITORY_BACKUP

Create a new empty repository:
svnadmin create /PATH/TO/THE/REPOSITORY

Fill the repository with the new files:
svnadmin load /PATH/TO/THE/REPOSITORY log

Check the generated log file to see if everything want right.

You should finally copy the old config and hook files from old repository to the new one:
cp /PATH/TO/THE/REPOSITORY_BACKUP/conf/* /PATH/TO/THE/REPOSITORY/conf/
cp /PATH/TO/THE/REPOSITORY_BACKUP/hook/* /PATH/TO/THE/REPOSITORY/hook/

All your users have to checkout the new repository with a svn checkout command.

That’s all :-)

Finally, if you use redmine like me, you want redmine to update the new repository. You just have to clear (not drop) the following sql tables:
changes, changesets and changesets_issues. The next time someone will click on the “Repository” tab in redmine, it’ll regenerate all entries. If it’s too long and you have a timeout, go to the redmine directory and run the following command line to force the generation of the changes:
ruby script/runner "Repository.fetch_changesets" -e production

Les commentaires de ce blog sont propulsés par Disqus