09 January 2015

Workflow: git-Gerrit to bzr-Launchpad

I'm coming from a world of git and Gerrit to one of Bazaar (bzr) and Launchpad. Both sets of tools will, no doubt, do the job, and I hope to be able to translate my workflow from one to the other.

git and Gerrit

Here's a rough outline of what I would do with git and Gerrit:

# get a local repo down from gerrit
git clone ${UPSTREAM}/${REPO}
cd $REPO
git review -s

# work on a feature branch
git checkout -b $FEATURE
    hack and test...
git diff
git commit -a -m "Added $FEATURE"
    hack and test...
git commit --amend -a -m "Added $FEATURE"

# merge any changes in master to our feature
git checkout master
git pull
git checkout $FEATURE
git rebase master  # let's assume no conflicts

# push our new feature for review
git review
    In the Gerrit web app, others probably need to review and merge the change.

# update our local master with newly merged feature from Gerrit
git checkout master
git pull

# tidy up
git branch -D $FEATURE


bzr and Launchpad

Bazaar uses some similar concepts and commands, but is different enough to confuse, on first attempt.

  • Where git branches are cheap and easy references to specific commits within a repository, in Bazaar they seem to be analogous to a git repository itself, as the stand alone, fundamental unit
  • Where a developer in a Gerrit-based team may have multiple local git feature branches, each with a review waiting on the Gerrit server, Launchpad users may have several local bzr feature branches, but seem to limit themselves to a single personal branch in Launchpad, from which they make merge proposals (analogous to Gerrit reviews) against the team branch


Now the bzr and Launchpad equivalent of the workflow above:

# get a local branch down from lp:~teamname/projectname/branchname
bzr branch ${UPSTREAM}/{$BRANCH}

# work on a feature branch
bzr branch $BRANCH ${BRANCH}-${FEATURE}
cd ${BRANCH}-${FEATURE}
    hack and test...
bzr diff
bzr commit -m "Added $FEATURE"

# merge any changes in trunk to our feature
cd ../${BRANCH}
bzr pull
cd ../${BRANCH}-${FEATURE}
bzr merge ../${BRANCH}
bzr conflicts  # let's assume none
bzr commit -m "Merge from upstream $BRANCH"

# push our new feature for review to our personal branch
lp:~username/projectname/branchname
bzr push ${PERSONAL}/${BRANCH}
    In the Launchpad web app, raise a merge proposal to have this personal branch merged into the team trunk branch. Others then need to review and approve the MP.

# reviewer should probably do this
# update our local trunk with the feature
cd ../${BRANCH}
bzr merge ${PERSONAL}/${BRANCH}
bzr commit -m "Merged branch for $FEATURE"

# push up to remote trunk
bzr push

# tidy up
rm -rf ../${BRANCH}-${FEATURE}


Further Reading and References


  • https://wiki.openstack.org/wiki/Gerrit_Workflow
  • http://doc.bazaar.canonical.com/migration/en/survival/bzr-for-git-users.html
  • http://doc.bazaar.canonical.com/latest/en/tutorials/using_bazaar_with_launchpad.html