Developing with Bazaar

March 23, 2009

I’ve been using Bazaar VCS for some time now, perhaps half a year or so, and have come to love it for its simplicity but also its flexibility.

In this article I’m going to outline the process of setting up a project repository with Bazaar and then using it alongside development.

Please note that this was written from a Mac perspective, but it should be the same (or similar) for other operating systems. It should also be noted that this but one of many ways to use Bazaar - this is just how I’m using it at the time of writing.

I won’t describe the process of installing Bazaar, as there is plenty of documentation and help on both the official website and search engines.

Once Bazaar is all setup on your machine, you should download the bzr upload plugin - this basically uploads your working tree to an FTP or SFTP location. More information can be found on its website.

Now, you’ll want to setup a project repository - there are two ways of doing this, you can create a shared repository which stores every child branch revision, or you can create standalone repositories, which are good if you don’t want to share revision information with other branches.

Generally, I think you’ll probably want to create a shared repository, as you can then have sub-directories such as trunk, branches and any others you might want to use. More information can be found in the Bazaar manual (specifically bzr init and bzr init-repository).

Let’s see an example - items in <brackets> should be replaced by you:

bzr init-repository <some_directory>
bzr init <some_directory>/trunk
bzr init <some_directory>/branches

If you view the contents of some_directory, you should see a directory named .bzr - this is where Bazaar stores the revision information for your repository and its branches.

Now, we can add a few files to the trunk directory - this is where the main line of development will take place:

touch testfile.txt
touch anothertest.txt

We can run bzr status to show us what the repository status is - if you do this you’ll see it output the following:


To rectify this, we run bzr add, which puts these files under version control:

added anothertest.txt
added testfile.txt

Now we can make our first commit!

bzr commit -m 'Initial commit'

You’ll see that Bazaar shows what’s been committed, and what revision number it has assigned to the commit - in this case it’s revision 1.

Now - if we want to - we can upload this revision to our remote server, using the Bazaar Upload plugin we installed earlier:

bzr upload sftp://user@server:22/path/to/directory

Note: you only need to type the full location once - the location is remembered for subsequent uploads.

I think that’s about it - there’s a few things I’ve missed out due to laziness but also the fact that the Bazaar manual can cover this in much more detail.

You might find this other article useful, if you’re looking to setup a fully-fledged local development environment.

comments powered by Disqus