Migrating from RCS to Bazaar

October 22, 2007

The RCS revision control system is a perfect example of the Unix philosophy. It is a simple yet extremely useful command-line tool with a clear focus: version control for small projects with relatively few files. It is not strictly for source code either—I use RCS for writing everything from academic papers to web pages. Unfortunately for larger projects, or those with several geographically dispersed developers, the limitations of RCS become clear and it becomes necessary to migrate to another system such as Bazaar.

Bazaar is a distributed version control system which allows a group of developers to maintain several different but inter-related related branches of the same project (derived from a common ancestor). Bazaar has several benefits over RCS for larger projects:

I have recently converted several projects to Bazaar, some of which have lived happily in RCS for years. This is easy if revision history is not important. Simply start a new Bazaar branch (bzr init) in the project directory and commit the current working copies (bzr commit -m "Initial import from RCS."). Unfortunately, it is not nearly as straightforward to migrate the project to Bazaar while keeping the revision history intact.

The best solution I have found is still very roundabout, requiring an intermediate Subversion repository. That is, I first convert the RCS “repository” to a Subversion repository and then convert the Subversion repository to a Bazaar branch. I use this method because there are stable tools available for doing so. There are two clear drawbacks to this procedure. First, it results in a lot of revisions. Each individual RCS file revision maps to a separate revision in the resulting Bazaar repository. Second, there is some degree of information loss. Although the original revision timestamps are preserved, they are only preserved in the Bazaar log text, not as actual Bazaar timestamps.

You will need two simple scripts, rcs2svn, a Perl script, and svn2bzr, written in Python. To convert your old rcsproj files to Subversion, first start an empty Subversion repository:

svnadmin create /path/to/svnrepo
cd /path/to/rcsproj
svn co file:///path/to/svnrepo .
perl rcs2svn.pl -v -f -g

Don’t forget the dot (.) in the third line or you will check out a copy in a subdirectory. Be sure to check the rcs2svn documentation to see which switches you might need. Now you should have a working copy of the empty Subversion repository, populated with your versioned files. You simply need to commit these changes:

svn commit -m "Imported RCS project"

Now /path/to/svnrepo contains the complete revision history of your old RCS project. If you have additional files that weren’t under RCS control (such as binaries) that you want in the Bazaar repository, add them now. For example:

svn add image.png binaries/*
svn commit -m "Imported additional project files"

Now, create a dump of the Subversion repository and convert it to a Bazaar branch:

svnadmin dump /path/to/svnrepo > svn.dump
svn2bzr.py --scheme=single svn.dump bzrbranch

Now bzrbranch is the resulting Bazaar branch, containing your complete RCS revision history. I highly suggest making a backup of your RCS-versioned project just in case.