Mere Code

Diverse Topics of General Interest to the Practicing Programmer

Another Bazaar story

I’m currently hacking away on Launchpad’s support for ”stacked branches”, something that will really make Launchpad’s codehosting a joy to use.

At the moment, I’m writing some tests that require a user to login. This was becoming a bit cumbersome, until I remembered something: Tim has recently landed some code to make this easy. But how do I get these changes without messing up all of the work I’m doing now? bzr shelve to the rescue!

‘shelve’ interactively goes through each change you’ve made to your current working tree and allows you to decide whether to keep a change or shelve it. It comes with a twin command ‘unshelve’, which lets you interactively restore your changes.

In this case, I don’t even care about the interactivity, so here’s what I did:

# Shelve my changes
bzr shelve --all
# Fetch the latest trunk
cd ../trunk
bzr pull
# Merge it into my branch
cd ../stacking
bzr merge ../trunk
bzr ci -m "Merge in changes from trunk to get login testing improvements."
# Restore my changes
bzr unshelve --all

The ‘shelve’ command comes with the bzrtools plugin, and I am basically in love with it.

As a parting shot, I should mention that things like bzrtools aren’t accidents. They are natural and inevitable when you have good APIs in a high-level language and a very nice plugin system.

And now I’m off to keep working on this branch.