Thoughts on Systems

Emil Sit

Jan 31, 2007 - 3 minute read - Research mercurial programming tools

Tools for moving from CVS to Mercurial

When switching to a new version control system, it is important to be able to bring along all the past history of a project. There are several tools capable of converting a CVS repository to Mercurial; I have considered cvs20hg, tailor and Mercurial’s own convert-repo. While these all do the conversion, careful testing of the results is necessary. My experience was not so bad, but I did uncover a problem much later than I would have liked.

The Chord CVS conversion was done using cvs20hg, a tool which parses the ,v files used by CVS internally to reconstruct a changeset oriented history out of the individual file modifications. To test cvs20hg, I set up a nightly sync of the CVS tree to a read-only Mercurial repository: this ran without problems. Thus emboldened, I took advantage of a pause in development along a CVS branch to make the official conversion.

Unfortunately, as I later discovered, cvs20hg seems to have a problem with branches (at least, our branch). While I was attempting to trace back the history of a particular file, I found that the history abruptly terminated at the point where the file had been moved between two directories. Older checkouts did not include the file at all! After spending a little time debugging, I found that the problem seemed to be that cvs20hg incorrectly identified the branch start date as being the initial repository creation date and, as a result, ignored the history of all files that were ever deleted.

After a few hours of experimentation, I was able to re-migrate the repository cleanly by first migrating up to the actual branch creation date and the continuing along the branch for the remainder of the migration. The new transplant extension was able move over a month’s worth of commits from the old migration into the new migration without any problems.

I did not wind up choosing convert-repo or tailor, though I did consider them. convert-repo in the Mercurial tip now supports CVS using cvsps to generate the changesets. When deciding how to recover from my initial mis-migration, I experimented briefly with this tool. However, it makes use of the new named branches feature of Mercurial which perhaps is still a bit young; it seemed premature and overly complex to include named branches in my conversion.

tailor is a more mature tool and I have used tailor in the past to convert to other systems with success; however, compared to the special cvs20hg tool, tailor is harder to use. On the other hand, tailor has many more features and can be used in more configurations. It is also actively maintained. Others have reported successful experiences mirroring repositories where cvs20hg would not work.

While these tools are all functional, there is room for improvement: these tools are certainly not yet ready to handle migrating complex projects like Mozilla. Fortunately for me, they do work well enough for simple projects. Many thanks to those early adopters who came before and got these tools working.