Appendix A. Migrating to Mercurial

A common way to test the waters with a new revision control tool is to experiment with switching over an existing project, rather than starting a new project from scratch.

In this appendix, we discuss how to import a project’s history into Mercurial, and what to look out for if you are used to a different revision control system.

Importing History from Another System

Mercurial ships with an extension named convert, which can import project history from most popular revision control systems. At the time this book was written, Mercurial could import history from the following systems:

  • Subversion

  • CVS

  • Git

  • Darcs

  • Bazaar

  • Monotone

  • GNU Arch

  • Mercurial

(To see why Mercurial itself is supported as a source, see Tidying Up the Tree.)

You can enable the extension in the usual way, by editing your ~/.hgrc file.

[extensions]
convert =

This will make an easy-to-use hg convert command available. For instance, the following command will import the Subversion history for the Nose unit testing framework into Mercurial.

$ hg convert http://python-nose.googlecode.com/svn/trunk

The convert extension operates incrementally. In other words, after you have run hg convert once, running it again will import any new revisions committed after the first run began. Incremental conversion will only work if you run hg convert in the same Mercurial repository that you originally used, because the convert extension saves some private metadata in a non-revision controlled file named .hg/shamap inside ...

Get Mercurial: The Definitive Guide now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.