Wednesday, April 7, 2010

Remove Unwanted Text from Repository Files

You may find that you need to delete content from a file that was committed to a Subversion repository.  If so, your options are limited.  Especially since Subversion does not support this kind of “malicious” activity.  The only option you have is to edit the dump file with a text editor like Vim and load the clean dump file.

First you need to dump your Subversion repository to a file:
>svnadmin dump live_repos > repos.dmp

Next you will open the file with Vim and replace the text with a mask of equal length.  It is important to keep the length the same. Otherwise you face more complications.

After you save your changes you can load the dump file into a temporary repository:
>svnadmin create temp_repos
>svnadmin load temp_repos < repos.dmp

Unfortunately this is not all there is to do. Eventually your load will stop with an error like :
 errormsg

Each file has a checksum in the dump file. The message above states that the load found a checksum for Web.Config other than the expected one. This is perfect because it tells us what to look for and what to replace it with.  In your dump file you will search for the hash that is shown after the expected: with the hash that follows the actual: Depending on how many times the text you want replaced occurs, you might have to do this more than once.

After you have a complete load you need to verify that your temp_repos ends with the same revision as your live_repos. If it does then you need to load the clean dump file into your live_repos.

0 comments:

Post a Comment