« Proposed Serialization Protocol in AS3 | Main | Proposed Hessian Extension For Erlang »

Converting Monotone To Mercurial

Today I had to convert a Monotone repository to Mercurial. Tailor is a tool that can convert changesets from one SCM into the format of another SCM. It currently supports many major SCM systems, including Monotone and Mercurial.

Tailor is written in Python and you can check out the latest version from their source repository:

$ darcs get --partial http://darcs.arstecnica.it/tailor

To do this, you will need to have darcs installed. Once you've got this, install tailor by running:

$ [sudo] python setup.py install

To be able to perform any conversions, you will need to have both the source and target systems installed in your environment. For this scenario, I needed to have both Monotone and Mecurial installed locally.

Using Tailor involves a two step process:

  1. Use Tailor to create a configuration file that describes the source and target repositories;
  2. Supply this configuration file to Tailor and tell it to run the conversion.

There is a good manual page that describes all of the options you can supply, but I just want to demonstrate how to convert all revisions of a particular branch in a Monotone repository to a Mercurial repository.

To do this, I ran Tailor with the following options, redirecting the output into a configuration file, which will be used in step two:

$ tailor -s monotone -t hg -R mtn.db \
-module com.acme.your_branchname \
target_dir --verbose > config.tailor

This indicates the location of the Monotone database and the particular branch to be converted. To perform the conversion, run the following:

$ tailor --configfile config.tailor

On the first attempt, the conversion was successful, apart from the way the commit comments had been migrated. Instead of copying the committer's actual comments, Tailor had produced comments that look this:

[project @ 4ff5bc70bed0ed59cbbc736d486044cb31047f6c]

To remedy this, there is an attribute called patch-name-format that you can set in the configuration file to tell Tailor to keep the original comments. You can see this option in the final version of my configuration file:

[DEFAULT]
verbose = True

[project]
target = hg:target
start-revision = INITIAL
root-directory = /tmp
state-file = tailor.state
source = monotone:source
subdir = target_dir
patch-name-format = ""

[hg:target]

[monotone:source]
module = com.acme.your_branchname 
repository = /tmp/mtn.db

After adjusting this, I reran the conversion and everything was fine.

If you want to, you can skip step 1 and just use this configuration file, adjusting the paths and branch names where necessary.

Posted on Friday, May 9, 2008 at 06:30PM by Registered Commenter0x6e6562 | Comments1 Comment

Reader Comments (1)

Oddly, because darcs has a strange notion of "revision identifier", using the empty-string for patch-name-format when converting darcs to hg doesn't produce good results, at least with tailor 0.9.35 (and darcs 2.0.2 and hg 1.0.1).

Instead, using the line "patch-name-format = %(revision)s" gave good results for me.

November 13, 2008 | Unregistered CommenterTony Garnock-Jones

PostPost a New Comment

Enter your information below to add a new comment.

My response is on my own website »
Author Email (optional):
Author URL (optional):
Post:
 
Some HTML allowed: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>