SVN obliterate

Print Friendly, PDF & Email

Had a problem today which is worth documenting for future use. I have a number of files held in various places throughout an SVN repo which I need to get rid of permanently. Just an svn delete is not enough, they need to go from the history and from the disk. Several copies and moves have been made of the files so a standard svn dump, svndumpfilter and load didn’t work for me. However, the svndumpfilter3 command found at furius.ca sorted out the problem nicely.

First of all make a list of directories you need to delete:

svn list -R file:///path/to/the/svn/repo | egrep '/repo/path/ends/with/this/$' >delete-list

Then make a dump of the repo (which also acts as a backup)

svnadmin dump /path/to/the/svn/repo >repo-dump

Download the svndumpfilter3 script from the site above.

wget http://furius.ca/pubcode/pub/conf/bin/svndumpfilter3

I had to add a line at the top to stop this encoding message:

  File "./svndumpfilter3", line 132
SyntaxError: Non-ASCII character '\xc3' in file ./svndumpfilter3 on line 133, but no encoding declared; see http://www.python.org/peps/pep-0263.html for details

The line was:

# -*- coding: iso-8859-15 -*-

The run the script to remove all references of the entries in the delete file. Use the existing live repo as a source to copy files which were moved from places you are deleting. Take the dump as the input file.

./svndumpfilter3 --exclude --untangle=/path/to/the/svn/repo $(cat cfgman-delete-list) <repo-dump >repo-cleaned

The resultant repo-cleaned file can then be used to load into a fresh repo.

svnadmin create /path/to/the/new/svn/repo
 svnadmin load /path/to/the/new/svn/repo <repo-cleaned

Finally, look through your new repo and check that it’s all there as expected and the deleted files have really gone.

svn list file:///path/to/the/new/svn/repo/.../repo/path/ends/with/this/