Wednesday, January 16, 2008

remove unwanted revisions in subversion

In one of those days, people committed stuff should not be in a source code repository into the subversion repository by accident, or sometimes not being disciplined and lack of understanding in source code repository…
There’s no easy button to remove the unwanted revisions in subversion. The svndumpfilter that came with subversion distribution is the tool that is able to exclude or include revisions with filename/dirname, unfortunately if there are “copies” in revisions that refers to the stuff that you wanted to filter out, svndumpfilter would break without finishing filtering the rest of revisions.
This problem can be avoided by writing a script to utilize svndumpfilter, svnlook and etc., copy path/files that has dependcies on other revisions. There are already scripts such as svndumpfilter2 and svndumpfilter3 out there. svndumpfilter2 is a python script that eliminates the copy dependencies revisions that you wanted to filter out. You can download svndumpfilter2 from: http://tartarus.org/~simon-anonsvn/viewcvs.cgi/svn-tools/svndumpfilter2

Assuming the directories that you want to keep are trunk, branches tags:

$SVN_HOME/bin/svnadmin dump /path/to/repo ./svndumpfilter2 /path/to/repo trunk branches tags > clean.dump

$SVN_HOME/bin/svnadmin load /path/to/repo < clean.dump

Your repo is now clean without those revisions taking up your HDD space.

No comments: