From CVS to SVN
I manage the website for a non-profit bicycle advocacy group. It’s a great sandbox to try stuff out, I got the idea this weekend to take the code repository for the site, which was CVS on my localhost, and put it up in a Subversion repository on my host (Dreamhost). I have really taken a liking to svn - especially hosted not on my computer.
From what I can tell it went well, and I got it on the first run. How often does that happen? There was only 1 very minor glitch that was easily fixed. Here are the steps for this magical conversion….##cvs2svn##
The genesis of this idea really was a conversation with a coworker the other day when talking about Capistrano, which only recently included support for CVS. We use CVS at work, and he mentioned that there was a script that would convert a repository from CVS to SVN, but that wasn’t what he wanted. Now that Capistrano supports CVS we haven’t gone back to redo any of our projects. That’s perhaps a post for another day.
So I googled for such a script, and found cvs2svn. Hmmm - I wonder what it does?
This is one of those “roll your own” installs that comes with a Makefile. You can install it, or just run it from the unzipped and untarred folder. I don’t have a LOT of repositories, and I couldn’t tell where it wanted to be installed, so I just ran it from the folder on my desktop. I did eventually move it into a “packages” directory where I keep things that may be useful again.
There are a few options for make, and one of them is check (like make test, but make check). I ran that, and it failed miserably. A prereq is python 2.2, so I guess that the nice folks over at python gave us a -v switch to get the version, and I run that. I get this python vomit all over my screen. I guess that python is somehow honked, and I go find a newer (and hopefully less honked) version.
I find a nice package ready to rock for OS X, which I use.
Rerun make check, and it passes. Mostly. There were some fails, but I let them slide.
The Translation
The cvs2svn script does not alter your repository, but there is a chance that you need to alter your repository to make it work. I use SmartCVS, so my repository is actually in pretty good shape. All files are tagged properly.
I still copied the repository to a temporary folder - also on my desktop. Be sure if you do this that you grab the full CVS repository. Even if you are only converting 1 project of the many you have in the repo. You need the CVSROOT directory.
cvs2svn -s /path/project-svn /path/cvsrepo/project
There was a permission problem on something in the CVS repository, so I ran the command with sudo.
I them ran svnadmin verify to take a quick pass at verifying the fancy new svn. Allgood.
Now What?
Now that you have this nice repository you need to put it somewhere. I created the svn repository on DreamHost, and then logged into the server via FTP. I went through the different files and directories and came up with this list to upload:
- db/current
- db/revs/*
- db/revprops/*
That’s It
I did a checkout of the repository to see how it went. I updated my VirtualHost config in my local Apache webserver, and fired it up. There was an old version of the index.htm file (probably from the very first version of the site) in addition to my index.shtml. I did a quick svn delete, and removed the errant file. Good to go.
Here are the steps in recap
- Download svn2cvs
- Update python if necessary
- run make check
- run sudo make install (optional)
- copy full repository to a temp dir (optional)
- sudo cvs2svn -s /path/project-svn /path/cvsrepo/project
- cd into the new svn; svnadmin verify .
- upload db/current, db/revs/*, and db/revprops/* to host
- checkout
- test