Converting to and from mercurial

There are many cats and many ways to skin them.

Converting from CVS to Mercurial

There are (or have been) things called cvs20hg, tailor, and even "convert-repo" as part of mercurial. Tailor is still around (as of 2012) as a fedora package, but the word is that for a simple repository (like mine, without branches), the "convert" extension that comes with mercurial may do just fine. It needs to be enabled by creating (or editing) the ~/.hgrc file and adding:
[extensions]
hgext.convert=
After this, you do:
hg convert working_dir new_dir
Note that working_dir is an actual checked out from CVS working directory of the project you want to migrate to mercurial. It will pick out a default name for new_dir (typically the last thing in the working_dir path with _hg added), but you can pick the name yourself as I do.

This actually seemed to work just fine, yielding the directory I specified with a freshly minted .hg directory inside of it.

Converting from SVN to Mercurial

There are apparently lots of svn to Hg conversion tools, most of them bad, but hgsvn is said to work (the command name is hgimportsvn).

Converting from Mercurial to SVN

As an amusing side note, I found the following question online:

Due to lack of Mercurial support in several tools, and managerial oppression it has become necessary to convert several trial Mercurial repositories to Subversion in order to conform with the company standard.
And this is done via: hg convert --dest-type svn hgreponame svnreponame

Converting from Mercurial to GIT

Something called "fast-export" is claimed to be the ticket.
cd workingdir
git clone git://repo.or.cz/fast-export.git
git init git_repo
cd git_repo
../fast-export/hg-fast-export.sh -r /path/to/old/mercurial_repo
git checkout HEAD
Here is another approach, using the mercurial hggit plugin: The last part (the git clone) goes like this:
cd newdir
git init
git remote add origin server/myproject.git
git pull origin master
git reset --hard HEAD
You can be bold and just do this in your mercurial working directory, add a .gitignore file if desired, and to burn your bridges, delete the .hg directory.
Feedback? Questions? Drop me a line!

Tom's Computer Info / [email protected]