[ originally posted Nov 17, 2008 @ 15:18 ]

Note: I’ve since gone back to using Bazaar on my laptop, because I really wanted local committing functionality. Unfortunately it is still awkward to use, particularly with TortoiseBzr for Windows, which sometimes mixes up its commands. My first choice for version control would now be git.

As a Windows-based developer, I was really enthusiastic about using Bazaar (BZR) for version control. 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 from my laptop.

Unfortunately, Bazaar’s Windows interface – TortoiseBzr – is still experimental, and DOS doesn’t make it easy to make partial commits because of its awkward copying and pasting functionality.

So even though Subversion is a centralised version control solution, I decided I wanted to go back to it – choosing to have a repository on my laptop.

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

While there are tools for migrating to bzr from SVN, such as svn2bzr, there’s not much about going the other way. Actually, I had to do a lot of searching to find the tools.

The answer eventually came, in cryptic form, via someone else’s bug report. And 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 – 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.
    Make sure you’ve install Bazaar 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, 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.

Then 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 BZR 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.

In my case, I did the following:

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

The bzr-svn plugin creates a new branch in my Subversion repository (file:///C:/svnrepos/project) called bzr-import, and then copies 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).

Hopefully this will help if you’re aiming to make the jump from BZR to SVN.