Recovering from the dreaded "Checksum mismatch while reading representation" subversion error
There are a number of hits when you go searching for this problem, some of those workarounds may work better for you - this is just what worked for me.
Disclaimer and brief soapbox rant
If you screw up your repository by following these steps, don't blame me. This worked for me, if it doesn't work for you, try one of the other links above. Back up all your data before you touch any files.
If you're paranoid enough, getting into this situation in the first place (most likely a corrupted block on your drive) won't be that scary because you keep your tree checked out on multiple machines. I've got mine on my laptop, dev server, and production server, and all are (generally) up-to-date. If the repository gets corrupted you shouldn't hyperventilate knowing at least the latest rev of your data is in multiple places. An adage you'll hear from snotty slashdotters is "if you only have one backup, your data's not that important." and if you believe dire predictions there's no substitute for multiple, geo-redundant backups.
Okay, enough ranting.
The error I ran into specifically when doing a checkout recently was this:
$ svn update
svn: Checksum mismatch while reading representation:
In my examples I'm going to use abcd1234 for subversion's expected checksum and 1234abcd for the actual, and corrupted.txt to indicate the corrupted file.
It's not immediately clear when you see that error which file specifically is causing the problem. I had to do some digging, but the db/revs directory in your repository is where to look. You can do a grep (inadvisable) to find the expected (abcd1234) checksum string in revs, or do the following:
svnadmin verify /path/to/repository
The last version where the verification fails (you should see the same checksum mismatch error) is the file you want to edit. For this example I'll use the version 1967.
Step 1: Backup
Verify that the checksum string abcd1234 appears in 1967. Check 1966 or 1968 if you don't see it, but it should be in the file that was displayed when you ran svnadmin verify.
The string should appear on a line starting with "text:"
Just underneath this line is the path to the corrupted.txt causing the problem, remember the path to this file.
Copy the 1967 file to your /tmp directory or someplace safe, in case things go awry.
Step 2: Rejiggering
On one of your other servers, find a pristine version of corrupted.txt and verify it's correctness
Copy the uncorrupted version locally to /tmp/uncorrupted.txt
Check the md5sum of uncorrupted.txt, it should be abcd1234, the mismatch that svn complained about.
Note If the md5sum of the uncorrupted version is NOT abcd1234 then you're probably looking at a different problem than I encountered, and might want to stop here, lest you corrupt your data.
Copy the 'actual' checksum 1234abcd from the svn error message into your clipboard.
Edit the repository/db/revs/1967 file, and replace abcd1234 with the actual reported checksum, 1234abcd.
Step 3: Restoration
Return to your local copy and do another svn update. You should proceed past the error now.
Once the update is complete, check the md5sum of the corrupted.txt file, it should be 1234abcd.
Copy the /tmp/uncorrupted.txt over corrupted.txt, and check it in.
Again, this is just what *I* did, and if you're not comfortable doing it, try one of the other links for alternatives.
h o m e
b l o g
s o f t w a r e
t h i n g s