{ ^_^ } sinustrom Solving life, one problem at a time!

Goodbye, old friend BZR

Author: Zoltan Puskas
Categories: linux

It seems that in the FLOSS world’s race of distributed revision control systems between BZR, Mercurial, and Git, the latter took the crown, with the significant help of GitHub blowing into it’s sails. When, in 2008, I started using version control for both personal and university projects I chose BZR, mainly because it fit my research work flow the best, e.g. by having a working tree for each of my branches, amongst other nice things. Unfortunately with the rise of Git and GitHub came the decline of BZR, so it’s time to migrate repositories before my data becomes inaccessible.

Tools for migration

I assume both version control systems are available on the system, but if not install them using via your package manager. I will be demonstrating this on Gentoo box, so you will need to adapt installation commands for your distribution:

# emerge bzr
# emerge git

Additionally some export and import tooling is needed. Fast-import is built into Git, while for BZR we need to install a helper:

# emerge bzr-fastimport

Converting a BZR repository to Git

Unfortunately Git does not support multiple trees for a single repository, so the choices for migration are:

  • separate Git repository for each branch,
  • using Git subtrees and merge to eventually end up with a single tree.

Since for some of my research papers I used BZR branches as separate entities (e.g. university vs. conference version of a talk) with a common root, only the first path was a reasonable solution for me without losing information. Below steps shall be repeated for each BRZ branch to be converted to a Git repository.

New bare Git repository for central storage

You will likely run this on the remote server, where you store your repositories.

$ cd /srv/git
$ git --bare init name.git
$ cd name.git
$ git --bare update-server-info
$ cp hooks/post-update.sample hooks/post-update

Alternatively you can create public repositories on GitHub and push your code there, if migrating from another system, like Lanuchpad.

BZR branch conversion

$ bzr branch name
$ cd name
$ git init
$ bzr fast-export --plain . | git fast-import
$ git reset HEAD
$ rm -rf .bzr
$ git remote add origin machine:/srv/git/name.git
$ git push --set-upstream origin master