So you’re new to version control? I was when I started my first “real” Mac OS X project in Xcode. Prior to this, I was programming on a .NET platform and Visual Studio’s SourceSafe comes at a steep price - and when I say steep, I mean $549 for the Standard Edition, $799 for the Professional Edition. Needless to say, I never bothered with it. Not that I couldn’t use another version control software, but being on the Windows platform, I guess I just wasn’t exposed to all the possibilities. I had never heard of CVS or SVN, believe it or not! It’s amazing how much exposure I’ve had to - and how much I’m enjoying - the *nix platform on OS X. Everything a developer needs, free!

Like most newbies would probably do, once I had SVN installed and running, I imported my project and was done with it:

svn import myProject svn://servername/myProject

Then I set up Xcode for SVN and relied on Xcode for the most part to help me with commits. Later on I read that the main project undergoing development should be stored in a ‘trunk’ directory. The suggested layout looks something like this:

SVN Recommended Repository Layout

Notice the trunk and branches. Yet another subdirectory would be ‘tags’ which is normally used to hold your version releases or any ‘milestone’ at which you wish to snapshot your project.

So what if you forgot to create a trunk directory? The first logical thing to do is to “move” the directory like this:

~/dev>move myProj myProj/trunk

Subversion doesn’t allow this and responds with:

svn: Cannot copy path ‘myProj’ into its own child ‘myProj/trunk’

I followed this article: Moving multiple files in subversion and this almost worked, but I had problem with the Xcode project file (.xcodeproj) and some NIBs. The problem was that the .xcodeproj “file” is really a Package (or directory) and contains multiple files, some of which were not properly version controlled. I don’t know exactly what happened, but in the end, SVN was expecting the .xcodeproj file to be at “myProj”, my local SVN client had it at myProj/trunk and ’svn status’ showed an ‘S’ in the 5th column which I could not resolve for the life of me! Good thing I had a hotcopy. A hotcopy creates a fully functional copy of your repository, able to be dropped in as a replacement.

Ok, so here’s how I did the hotcopy and then how I ended up creating a trunk directory “after the fact”:

E:\>svnadmin hotcopy e:/svnrepos e:/svnrepos_hotcopy
E:\>svn mv svn://localhost/myProj svn://localhost/trunk -m “rename myProj to trunk”
E:\>svn mkdir svn://localhost/myProj -m “re-create the myProj directory”
E:\>svn mv svn://localhost/trunk svn://localhost/myProj -m “now move trunk into myProj”

Note that my repository is on a Windows server hence the drive letter notation in the svnadmin command.

Just to be sure things were in sync, I axed my local working copy and checked out a fresh copy:

~/dev>mkdir myProj
~/dev>cd myProj
~/dev/myProj>svn co svn://servername/myProject/trunk trunk