Sunday, December 12, 2010

HOWTO: Convert a darcs repository to mercurial

It seems the "easiest" way to convert a darcs repo to a mercurial repo is via git =( This uses darcs-fast-export, git-fast-import and hg convert. Other solutions such as tailor and "darcs2hg.py" exist but seem hard(er) to setup or have errors.

  1. Get darcs fast-export from bzr-fast-import:
    git clone git://vmiklos.hu/bzr-fastimport
    
  2. The only thing you care about in the entire bzr-fast-import repo is "darcs-fast-export" (a python script) in bzr-fastimport/exporters/darcs.
  3. Checkout the darcs project
    mkdir project; cd project; darcs get codebox:/code/project project.darcs; cd .. 
    
  4. Convert darcs to git (in Ubuntu karmic git-fast-import isn't in PATH)
    mkdir project/project.git; cd project/project.git; git init
    ../../darcs-fast-export.py ../project.darcs | /usr/lib/git-core/git-fast-import; cd .. 
    
  5. Convert git to hg
    hg convert project.git project.hg; cd project.hg; hg update