Migrating from BZR to SVN

written by Drew | 2008.321 Mon 17 Nov

Note: I’ve gone back to using Bazaar on my laptop. It is, however, still awkward.

As a Windows-based developer, I was really enthusiastic about using Bazaar as a version control tool. At the time my SVN repository was on my home computer, and with being out of the house 13 hours a day there was no scope for making regular commits.

Unfortunately, Bazaar’s Windows interface – TortoiseBzr – is still in the experimental (read: alpha) stages, and DOS doesn’t exactly make it easy to make partial commits, because of its awkward copy and pasting functionality.

TortoiseSVN in Windows is far more complete, and allows me to do all the useful things I couldn’t do with TortoiseBzr (like adding and removing files from version control!). So, I decided I wanted to go back to SVN, using a repository on my laptop instead.

It would have been simple to just do export what I had so far, and create a fresh branch in SVN. Unfortunately, I wanted to keep the 96 revisions I already had. Tags – which I began to use for version numbers – would be useful too.

There are widely-known tools for migrating to bzr from SVN, such as svn2bzr. But unsurprisingly there’s very little about going the other way around. Actually, I had to do a lot of searching to find the tools themselves.

The answer to my issue of migrating commits from Bazaaar to Subversion came, in cryptic form, via someone else’s bug report. For your convenience, here is my explanation, in plain English.

  • You will require:
    • Bazaar (bzr) version 1.4 or 1.5 installed [windows installer for 1.5]
    • Subversion (SVN) installed, with a repository created ["one click SVN" windows installer]
    • Python 2.5 (or possibly greater) installed [windows installer]
    • the bzr-svn plugin [windows installer].

      If you’re using Windows, you’re limited to Bazaar 1.5 – for some gay reason, the only available installer for the bzr-svn plugin is only compatible with 1.4 and 1.5. Unix users should be okay with the latest version of bzr, as long as you can build the bzr-svn plugin.

      Bazaar should be installed before installing the bzr-svn plugin.

  • At the command prompt, type in

    > bzr help commands

    and make sure you can see the svn-push command, which is usually near the bottom of the list. If you can see it, that means the bzr-svn plugin is correctly installed.

  • Navigate to the Bazaar branch you want to migrate to Subversion: this would be the folder with a hidden .bzr folder in it.
  • If you haven’t yet got a Subversion repository to copy everything to, create one now.
  • Now for the main event! At the command prompt, type in

    > bzr svn-push [path-to-non-existent-svn-branch]

    The svn-push command (at the time of writing) will only copy a Bazaar branch to an SVN branch that doesn’t exist, so you can’t point it to the trunk. Instead, we specify the path to our SVN repository and a name for a new branch to export to.

    So in my case, I did the following:

    > bzr svn-push file:///C:/svnrepos/Foley/branches/bzr-import

    The bzr-svn plugin creates a new branch in my Subversion repository (file:///C:/svnrepos/Foley) called bzr-import, and then starts copying all the revisions from the Bazaar branch. Of course, you can call the branch whatever you want.

  • Once it’s finished, you should be able to pick up where you left off using SVN (or TortoiseSVN).

This doesn’t appear to copy tag information over, so I’ll have a look into that myself.

Hopefully this article has been useful for you.

Tags: , , , , ,