Launchpad, used by most Ubuntu projects and flavors, has utilized Bazaar (bzr) for it's version control system (VCS) for quite some time. Meanwhile, the rest of the open source world has been transitioning to Git, with even Debian migrating in recent years. This guide will help you migrate an existing bzr project on Launchpad to Git.

Getting Started

This guide makes a few assumptions:

Enable Launchpad Abbreviations

Git identifies repositories using URLs. Unlike Bazaar, there is no built-in abbreviation for repositories hosted on Launchpad, but it is very easy to add such a thing yourself. Edit ~/.gitconfig and add these lines, where USER is your Launchpad username:

[url "git+ssh://[email protected]/"]
        insteadof = lp:

This allows you to type git clone lp:REPOSITORY and keeps the bzr and git workflows consistent.

Migrating The Project

Launchpad projects have the following features available:

  • Code hosting
  • Development series and milestones
  • Translations with automatic import and export
  • Automatic builds with “recipes”

Code Hosting

Start with migrating bzr trunk to git master. I'll be using “sgt-launcher” for this demo, but be sure to replace this with your project.

Before you get started, you may want to disable automatic Launchpad translation imports.

bzr branch lp:sgt-launcher
cd sgt-launcher
git init
bzr fast-export --plain --git-branch=master . | git fast-import
git stash
git remote add origin lp:~bluesabre/sgt-launcher
git push --set-upstream origin master
git push --tags origin master

With this, the git master branch should be ready to go and is accessible from git clone lp:sgt-launcher.

And now we can migrate each of the project branches.

bzr branch lp:sgt-launcher/0.1
cd 0.1/
git init
bzr fast-export --plain --git-branch=0.1 . | git fast-import
rm -rf */* * .bzrignore # otherwise git complains
git checkout 0.1
git remote add origin lp:~bluesabre/sgt-launcher
git fetch origin
git push --set-upstream origin 0.1
git push --tags origin 0.1

Tidy Up The Bazaar Branches

Now that we've moved everything to Git, go ahead and mark the Bzr branches Merged or Abandoned, or delete them all together. Go to https://launchpad.net/PROJECT/+configure-code and update the default VCS to git.

Development Series & Milestones

Launchpad does not currently support associating git branches with development series, so go ahead and unlink all of your existing branches for tidiness.

Translations

Launchpad does not currently support associating git branches with translations, so a few changes have to be made to continue using translations within Launchpad.

  1. Create a new git import bzr branch to mirror git master. I recommend lp:PROJECTNAME/import to reduce confusion.
  2. Configure automatic translation imports from the import branch.
  3. Disable automatic translation exports. These will have to be manually exported and synced in the future.

Recipes

Recipes will need to be updated to utilize the new git branches.

For the following bzr recipe:

# bzr-builder format 0.3 deb-version 1.0+{revno}
lp:bzr
merge fix-build lp:~bzr/bzr/fix-build
nest pyfoo lp:pyfoo foo
  merge branding lp:~bob/pyfoo/ubuntu-branding
nest-part packaging lp:~some-person/some-project/trunk-with-packaging debian debian

You would use the following git recipe:

# git-build-recipe format 0.4 deb-version 1.0+{revtime}
lp:germinate
merge fix-build lp:~contributor/germinate fix-build
nest pyfoo lp:pyfoo foo master
  merge branding lp:~bob/pyfoo ubuntu-branding
nest-part packaging lp:~some-person/some-project debian debian master-with-packaging

Note that the “lp:PROJECT” alias for the project's default branch may still be configured for bzr, and will currently take precedence over the git default repository. You can always disambiguate like this:

https://git.launchpad.net/PROJECT master

Packaging

If you have access to the packaging, go ahead and update the VCS URLs at this time. Otherwise, notify the current package maintainer.