Subversion Fun

In my new position at Fontis, I have been tasked with continuing development on a somewhat larger project for an external client. It doesn't sound like anything too dramatic – web site written in PHP, using the CakePHP framework, and driven by a database. I just didn't factor in Murphy's Law.

The first order of business has been to upgrade the version of Cake that's currently being used, 1.2 alpha, to the new 1.2 beta version. I figured this would be simple since the existing code was being kept in a Subversion repository that we had access to and we had a copy of the latest working version. Unfortunately the code had not been checked in for quite a while, and contained updated code, so I would have to do a "first" commit … and this is where the first problem popped up. It turns out that the repository has since been moved to a new server, because of the project change over, so I had to switch the existing working copy over to the new URL. Anyone attempting this themselves: it turns out a Subversion working copy doesn't like it when you switch targets with some unversioned files inside it. For the first time ever I discovered a ~ next to the status of several directories – this apparently means something is "blocking" this file.

This is where I ran into the second problem, which is actually rather amusing. Trying to fix one of these directories resulted in some circles: first I would be told that they couldn't be checked in because the file .svn/entries could not be found. Hardly surprising since it didn't exist. Trying to create it by svn adding the directory, I got told that I couldn't add the directory because it was already under version control. Going back to step 1 and repeat! My attempts to fix the problem only exacerbated the problem by moving it further up the directory tree.

Thus I found myself using a rather "brute force" approach to fix it: checking out another copy and copying the original working copy's files over the top of this new one. Thankfully, this eventually worked.

The moral of the story?

  1. Don't switch over a working copy when it has unversioned files in it.
  2. Commit your work regularly – something I'm sure most developers forget!