Bazaar can support you whether you like the Git model of having a single working tree for each clone of your repository, or if you prefer to have multiple working trees.
When dealing with large projects the latter can get slow and disk
hungry. This is because, by default, each new working tree created by
bzr branch a-branch new-branch also holds a complete copy of the
I use a mix of both development models when I’m using Bazaar. Fortunately there’s an easy and out-of-the-box way to prevent those slow downs and get back your disk space: shared repositories. Read on to find out how.
Starting from scratch
Create a new repository and create a branch within it. I’m going to use MAAS here, but you should use whichever project you’re interested in here, provided it manages its code with Bazaar.
$ bzr init-repo maas Shared repository with trees (format: 2a) Location: shared repository: maas $ cd maas $ bzr branch lp:maas trunk Branched 5593 revisions.
It doesn’t matter what you call that branch, or what branch you start with. The essence of why this is useful is because the history of every branch created within the repository directory is shared with all the other branches. This means that starting a new branch is quick — just a copy of the working tree, with a little additional disk space used for branch history:
$ du -sh .bzr */.bzr 116M .bzr 604K trunk/.bzr $ bzr branch trunk new-feature Branched 5593 revisions. $ du -sh .bzr */.bzr 116M .bzr 604K new-feature/.bzr 604K trunk/.bzr
If you have a number of branches already, you’ll want to migrate. For example:
$ du -sh .bzr */.bzr du: cannot access '.bzr': No such file or directory 117M old-feature/.bzr 117M trunk/.bzr
Create the repository in the parent directory, then reconfigure the branches:
$ bzr init-repo . Shared repository with trees (format: 2a) Location: shared repository: . $ bzr reconfigure trunk --use-shared $ bzr reconfigure old-feature --use-shared
Repeat that for the rest of your branches. The first reconfigure will take some time but the second and subsequent will be quick.
$ du -sh .bzr */.bzr 116M .bzr 604K old-feature/.bzr 604K trunk/.bzr
In other respects these branches / working-trees behave the same as their standalone cousins.