How-to recover from checksum mismatch errors in SVN

January 25, 2009, 5:17 pm · 4 comments · Filed under: Coda, Subversion (SVN), Web Development

You know Coda, the text editor I sometimes rave about? Like many text editors, it has this handy feature for doing global searches and replaces. But, unlike any other I’ve ever seen, it will happily, and without prompting for an administrator password, let you replace text in files for which you don’t have permission to write. You know, like Subversion repo copies. D’oh!

andrew.hedges.name



Can your web browser do this?

You’ll never get rich digging a ditch, nor building Dashboard widgets.

A Kryptonite™ lock can be defeated in 11 seconds, but you still lock your bike, right?

Gaining Twitter followers is a little like losing weight. You have to try.

Over or under? It’s the age-old question when it comes to the orientation of toilet paper rolls.

Subscribe


Meta Me

I am a web developer, recently returned to the States after 3 years in New Zealand. I’m into my family, photography and frisbee sports.

Blip.fm Digg Facebook LinkedIn Stack Overflow Twitter Zooomr

Nothing will benefit human health and increase chances for survival of life on earth as much as the evolution to a vegetarian diet.
Albert Einstein


Topics

Apple · AppleScript · Business · Coda · CSS · Dashboard · Design · Google · InSTEDD · JavaScript · jQuery · Life · Marketing · Music · New Mexico · New Zealand · Open Source Software · Photography · PHP · Politics · Ruby on Rails · Scree · Subversion (SVN) · Twitter · Usability · Web Development · Widgets


Archives


Most Popular

CSS Fast Nav: Because (perception of) speed matters! · Personal Branding for Introverts · Stupid WebKit Tricks · Add an interactive legend to a MarkerManager managed Google Map · Dude. Mikeyy can’t even spell his own name. · Dashboard Widgets for Fun and Profit · Animating your iPhone web application · How-to recover from checksum mismatch errors in SVN · Why Apple can afford to charge so little for Snow Leopard · When is a global variable not a variable?


Most Recent

CSS Fast Nav: Because (perception of) speed matters! · When is a global variable not a variable? · Our misguided culture of cool · InSTEDD: Open Source Software that saves lives · Add an interactive legend to a MarkerManager managed Google Map · Personal Branding for Introverts · Moments of Rangitoto · Some Twitter conventions · Why Apple can afford to charge so little for Snow Leopard · Stupid WebKit Tricks


Twitshirt

Twitshirt is a tweet on a shirt. Buy the one below or check out my most recent tweets.

I wonder if the engineers from the IE6 team leave that little project off their CVs?

See a random Twitshirt-worthy tweet.


Friends

80/20 · 90 Seven Design · Alyson Hurt · Andrew Nimick · Apps & Hats · Ben Young · Brian Arnold · Brian Warren · Carl Bolter · Chris Burgess · Christine Morris · Cristina Stoian · Daniel Lyons · Daniel Schwartz · David Hedges · Hamish Campbell · Jochen Daum · John Visser · Joseph McLaughlin · Joshua Sallach · Julian Pistorius · Justine Sanderson · Kalena Jordan · Katie Graham · Kelly Green · Kevin Potis · Mark Bixby · Matt Henry · Method Arts · Morgan Pyne · Peter Michaux · Philip Tellis · Piers Harding · Rebecca Murphey · Reid Givens · Rey Bango · Rhett Anderson · Richard Paul · Rob Pongsajapan · Robin Taylor · Ryan Park · Shaun Lee · Simon Young · Su Yin Khoo · Toni Barrett · Vaughan Rowsell · Vincent Thomé · Voom Studio


Recommended Books on
Web Development

My bias is for references over “cookbooks.” I want to know all of my options, not just one way to do something. Show me the why as well as the how and I am happy.

JavaScript: The Good Parts · Object-Oriented JavaScript: Create scalable, reusable high-quality JavaScript applications and libraries · JavaScript: The Definitive Guide · Designing with Web Standards · CSS: The Definitive Guide · Prioritizing Web Usability · The Elements of User Experience · Web ReDesign: Workflow that Works · Don't Make Me Think: A Common Sense Approach to Web Usability


Contact Info

Contact info for Andrew Hedges


I’ve hosted this website with pair Networks since 1997. They rock.

This blog is powered by…software I wrote.

Feeling generous? Knock yourself out!

Don’t get me wrong. I love Coda. I love it enough to choose to spend most of every day with it front-and-center on my screen. But, for the life of me, I can’t imagine why it allows me to replace, without prompting me for an administrator password, text in a file with the following permissions:

-r--r--r--

For the uninitiated, the distinct lack of w’s in that line is supposed to mean that the file is read-only.

Enough, already! Show me how to fix it!

Whatever the reason, Coda changed the files, which just happened to be the Subversion (SVN) reference versions of some of my repository files. The next time I tried to commit changes to my repository, I got an error message something like the following:

svn: Checksum mismatch for '.svn/text-base/blah.ext'; 
expected: 'f8d45250f7df5561635854165862fdd8', 
actual: '644f85c4befa671150c5c6ec5fad9885'

The above is actually taken straight from an article called “subversion checksum mismatch - easy workaround.” I’m glad I found the article because it helped me fix the problem. Contrary to the title of the blog post, however, I didn’t find Chris’s instructions all that clear, so I thought I’d take a shot at explaining it in a way that is maybe a little easier to follow.

A side trip down Background Lane

Feel free to skip this section if you are familiar with how SVN works or are just in a hurry to fix your issue and get on with life!

SVN is software that helps you track revisions to files. As such, it is very important for SVN to know when a file changes. SVN stores information about every change made to files under its control locally in plain text files inside hidden .svn directories. Trust me, you don’t want to edit those files directly.

Before committing (saving) a file, SVN compares the latest revision of the file in the repository with the corresponding, locally saved, latest revision. Actually, it doesn’t compare the files directly. Instead, it compares the checksums. A checksum is a shortened hash that represents the contents of a file. If the checksum for a file changes, you know it has been altered.

Once you change a file, it’s really hard to get it back to its original state for the purposes of this check. Directly putting back the text that was changed didn’t work for me. I don’t know exactly how checksums are calculated, but it could be that they’re based on the contents of the file plus some meta-data (like the last modified date) or else I just missed some of the changes.

In any case, I was having a bugger of a time with this, until I discovered the above-linked article. Then, I was, to quote The Proclaimers, on my way from misery to happiness. Uh-huh. Uh-huh.

Enough, already! Show me how to fix it!

The process we will follow to restore the repo to a state where we can commit entails the following steps:

  1. Check out the latest revision of the corrupted directory into a temporary directory
  2. Delete the munged SVN revision files
  3. Copy the correct SVN revision files into the working directory

As you can see, it’s not difficult. You just have to know where to look for the correct files to swap out.

A benefit of my way over other procedures I’ve seen described is that I didn’t have to do anything special to get back to a state where I could commit the latest changes I had made. After doing the above, SVN told me I had changes to commit. I committed them, and I was done.

Ominous disclaimer: what I am describing worked for me, for text files. It may not work for you. It should work for binary files, but I haven’t personally tried it. Following this procedure, you may lose your life’s work, putting you on an irreversible path to destitution and despair. You have been warned.

OK, now that you’re too scared out of your wits to try them, know that these steps have face validity and worked in my case. If that’s enough assurance for you, let’s get this road on the show.

The following are the commands I used to restore my repo. The paths and filenames have been changed to protect the innocent. Also, I am describing the process for Mac OS X, so if you’re on a different operating system, make the proper adjustments.

  1. Open Terminal.app or your command line interface of choice
  2. Change to a directory that is not under version control. /tmp works nicely:

    $ cd /tmp

  3. Checkout the latest revision of the corrupted directory:

    $ svn co svn://me@myserver/path/to/directory

  4. Change into the directory that holds the SVN revision files:

    $ cd directory/.svn/text-base/

  5. Open a second terminal window and change into the directory with the corrupted revision files:

    $ cd /path/to/working/directory/.svn/text-base/

    At this point, if you were to list the contents of the text-base directories in both windows, they should be identical and consist of a list something like the following:

    $ ls -la

    drwxr-xr-x 31 andrew andrew 1054 24 Jan 14:52 .
    drwxr-xr-x 8 andrew andrew 272 25 Jan 15:50 ..
    -r--r--r-- 1 andrew andrew 198 16 Nov 18:21 .project.svn-base
    -r--r--r-- 1 andrew andrew 27 19 Dec 09:27 myTextFile.svn-base


  6. In the second window (the one with your working copy), delete the corrupted revision files. If you know which one(s) they are, just delete them. Otherwise, you can delete everything in this directory:

    $ sudo rm *

    (Note for the paranoid: you could backup this directory before performing this step if you want. I figured why bother since it’s corrupted already and I had a backup in the form of the newly checked out version in /tmp)
  7. Back in the first window, copy the contents of the text-base directory into your working directory:

    $ sudo cp * /path/to/working/directory/.svn/text-base/

That’s it. You should now be able to commit to your heart’s content.


Short URL to this article:
Tweet this article!


4 comments

for the record, i think andrew does give a much clearer set of instructions than mine :)

Posted by: xurizaemon · January 26, 2009, 8:08 am

Found this page while trying to fix my own problem, so hopefully my solution will help others…

My working copy is in windows and it was only one file causing the mismatch problem.

I made a copy of the problem file, then used TortoiseSVN to add this copy and delete the original.

Checked that in, then renamed the copy back to the original name. Checked in again.

Worked for me, and no need to mess about with the repository on my Linux server.

Posted by: KFCSpike · February 22, 2009, 4:43 am

This is a silly way.

Why not just check in the files you can, move your working copy dir somewhere, do an update to get a new working copy, and finally copy the remaining files into the new working copy. Delete old working copy. Done. No need to worry about .svn directories.

Why be married to a busted working copy? Just ditch it.

Posted by: Joe Smoe · May 21, 2009, 2:55 am

I agree, it’s overkill if you have a small number of files in modified states and you know which ones they are. In my case, I had a large number of files and wanted to make sure I didn’t miss any, so it made more sense to do it this way.

Posted by: Andrew Hedges · May 21, 2009, 9:37 am

Comments close automatically after 90 days.
Still have something to say? Drop me a line!

Possibly related posts