SVN Tip: Overwrite Corrupted Revision: Linux

SVN Tip: Overwrite Corrupted Revision

Tags: Linux | Written on 14/7/08

Yet again I was saved from a catastrophic failure by using SVN.  If you are not using SVN or some sort of version control I highly recommend using SVN as it will save you from losing your work time and time again.

SVN Reverse Merge

The common way to roll back a change is the reverse merge. You are taking the old revision and merging it into your working directory.  For instance, here we could merge revision 117 into our working directory with this command:

Bash:
  1. svn merge -c 117 ./

In the case of a corrupt check in, this may not be possible.  SVN was essentially "stuck" for me at a revision because of some errors that occurred (don't ask me how I got to this point, lol).  So I had to come up with another solution...

"Side Steping" Latest Revisions

SVN was corrupted at revision 118+ and so I could not get anything working if I svn updated to the latest.

So, I came up with this, "side steping" method where you can roll back to an old revision without having to svn update to the latest revision.  To pull it off, we first need to delete the latest working copy, then we resurrect the old revision.

  1. Delete the current folder in SVN that contains the corrupted file folder.
    Bash:
    1. svn delete file:///svnroot/domain.com --message 'deleting corrupt revision'
  2. Resurrect the stable revision (in this case #117) with SVN copy. The -r flag allows us to enter the revision number that we want to resurrect.
    Bash:
    1. svn copy -r 117 file:///svnroot/domain.com file:///svnroot/domain.com --message 'resurrecting the old revision'
  3. Check out the latest from SVN and you are back on the road!
    Bash:
    1. svn co file:///svnroot/domain.com

If you are not sure what revision to roll back to, you can always use svn log to review your previous commits to find the stable revision number. 

This method sure has saved me from what could have been a world of coding pain.

Comments

#1. Felix Geisendörfer on 15/7/08
Use git : ).
#2. Marc Grabanski on 15/7/08
Thanks Felix, I have heard of git before and will try it when I get the chance.

Leave a Comment