Thursday, February 2, 2012

Corrrupted SVN repo and the solution

   I'm currently taking a Numerical Physics course at U. Laval. So far, it has been a really enjoyable experience. However, I would like to share some technical know-how I acquired while working on one of the projects.
   We are mostly using MATLAB (I personally use Octave, which is the open-source counterpart) to do the projects. As of the fourth project, I am working with a partner, which immediately lead to the classic problem: how do we share the code?
    Of course, this problem has been solved in thousands of ways. I chose to create an account on SourceForge (I don't have my own server, so it was the easiest way) and start a project where I could dump the all the code in an SVN repository. (By the way, all the code we write, for what it's worth, is Creative Commons.)
   Everything went well; up till yesterday. For some obscure reason, when I tried to svn up in the morning, svn returned the error 
Reading one svndiff window read beyond the end of the representation.
which I didn't know about. Some Googling informed me that the repository was corrupted.  Some more Googling revealed a SourceForge support page that gave a solution to the problem.
   Okay, so here's the complete solution. You log on to the Shell SourceForge provide and run the following commands:

adminrepo --checkout svn
svnadmin dump -r 0:92 /svnroot/projectName/ > ~/repo.dump
The adminrepo checks out the SVN repo of your project in a folder that you can modify. You then dump the repo (I used -r 0:92 because I knew the repo was sane at rev 92 and because I had manually merged the diffs of -r 93:95 in my working directory).
   Now, if you're sure you have a good backup, you can delete the repo. We will then create a new one and load the dump file into this new repo.

rm -rf /svnroot/projectName/
svnadmin create /svnroot/projectName
adminrepo --save svn
Now half the fun is done. The repo is back in the main folder (which you can't modify directly) and your DB should be un-corrupted (or whatever).
   If you're using the new SourceForge bashboard, you can't stop here. You have to tell the dashboard that you've made some drastic changes to the repo. In the SourceForge web interface, navigate to Admin → Tools. Under the SVN tool, click on Import Repo. Enter the following URL:
https://projectName.svn.sourceforge.net/svnroot/projectName

click Import and you're done! 

Please inform me in the comments is something is unclear or just plain wrong. Thanks!

No comments:

Post a Comment

I'm very sorry to put you through the CAPTCHA. I tried to remove it, but the spam comments were unbelieveable. Here's a funny website to compensate: http://craptchas.com/