Wednesday, July 01, 2009

Convert an svn repository to an hg repository

[The following is a very condensed version of the instructions found here.]

Suppose svn-working-copy is a working copy of the svn repo.
hgimportsvn svn-working-copy hg-repo
Pull all SVN history with hgpullsvn
cd hg-repo
hgpullsvn
Do an update for good measure
hg update (optional)
Clean up the .svn and .hgignore directories.
cd hg-repo
find . -name .svn | xargs -0 rm -rf
find . -name .hgignore | xargs -0 rm -rf
Done. Yay.

Install hg in a custom location

The hg installation scripts allow you do a system-wide installation or an installation in $HOME (~/bin, ~/lib,...). To use a different location, do the following.

The install-home option for make installs hg into $HOME so we redefine the $HOME variable.
export HOME=/home/username/Applications/mercurial-1.2.1/
mkdir $HOME
Then run make.
make install-home
Create symlinks, if desired.
cd /home/username/Applications/bin
ln -s ../mercurial-1.2.1/bin/hg .

Add the following to .bashrc (change appropriately; for example, lib vs lib64, ...).
export PYTHONPATH=$HOME/Applications/mercurial-1.2.1/lib64/python/
export PATH=$HOME/Applications/bin:$HOME/bin:$PATH
Set $HOME back to the original location.
export HOME=/home/username/