20130124 from cvs to hg - plembo/onemoretech GitHub Wiki

title: from cvs to hg link: https://onemoretech.wordpress.com/2013/01/24/from-cvs-to-hg/ author: lembobro description: post_id: 4138 created: 2013/01/24 18:40:45 created_gmt: 2013/01/24 22:40:45 comment_status: closed post_name: from-cvs-to-hg status: publish post_type: post

from cvs to hg

So it begins. Converting from cvs to Mercurial is actually not that big a deal. I ought to know, I'm doing it right now. My existing cvs repository is pretty clean, mostly because I've been the only one it it for most of the decade since it was first set up. As a result it turns out to be a really good candidate for conversion to Mercurial. This is especially true because my cvs repo has no branches or tags. It is also organized into distinct projects. What I'll actually doing is converting each of those projects into its own Mercurial repository. The first thing to do, of course, is to set up a directory where the converted projects will reside. In my case that's /data/share/hg. Next, I need to configure myself so I can access Mercurial's convert extension. That involves editing the .hgrc file in my home directory:

[ui]
username=Phil Lembo 

[extensions]
hgext.convert=

Then I need to make sure my local copy of those cvs projects is up to date. That's done by changing into each project directory and running the following command:

cvs update -P -d

Finally, I get to run the conversion routine itself by changing into my local cvs directory just above my projects and issuing the following command:

hg convert myproject /data/share/hg/myproject

Note that the routine will go out to your cvs repository on the network if you're configured to use it as part of your normal workflow (for example using the CVS_RSH method), so big repositories may take awhile to process. After doing this for each project you'll wind up with a directory full of new Mercurial repositories that have all the history from your old cvs projects. Initially each of those repository directories will appear to be empty, but if you look carefully you'll see the tell-tale .hg sub-directory where all your files and history actually live. To get a copy of each repository into your own home directory all you have to do is something like this:

cd ~/
mkdir hg
cd hg
hg clone /data/share/hg/myproject

That's all there is to it! The .hg/hgrc file in your cloned copy of each repository will contain a pointer to its original source that hg will use when performing pushes ("hg push") back into the original repo. But the good news is that you don't have to do that every time you update your local copy. You can make changes to your code and commit those to your local history with impunity and only push those to your "central" repo when ready. Next time: how to set up a "central" directory of repositories and make it accessible over ssh.

Copyright 2004-2019 Phil Lembo