Skip to content

Instantly share code, notes, and snippets.

@allenap
Last active December 7, 2016 16:03
Show Gist options
  • Save allenap/fe79b7a897d0ff51d94a5c1b2bee6937 to your computer and use it in GitHub Desktop.
Save allenap/fe79b7a897d0ff51d94a5c1b2bee6937 to your computer and use it in GitHub Desktop.
Bazaar repositories for fun/profit/shenanigans

Bazaar repositories for fun/profit/shenanigans

Starting from scratch

Create a new repository and create a branch within it:

$ 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

Migrating

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.

That's it.

$ 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment