cheap branching across file systems?

John Arbash Meinel john at
Tue Jun 27 17:57:25 BST 2006

Hash: SHA1

TK Soh wrote:
> On 6/27/06, Wouter van Heyst <larstiq at> wrote:
>> On Tue, Jun 27, 2006 at 10:51:34AM -0500, TK Soh wrote:
>> > I created a branch on a different file system, but 'du' reported
>> > similar usage on both repo. Have I misinterpreted the concept of cheap
>> > branching?
>> Could you provide some more context? If you branch inside a repository
>> (created by bzr init-repo) the storage for revisions is shared, but I
>> can't judge from here what is going on.
> % cd /tmp
> % bzr branch /home/tksoh/NEdit/n1 n2
> Branched 1 revision(s).
> % du -ks  /home/tksoh/NEdit/n1 n2
> 17320   /home/tksoh/NEdit/n1
> 17232   n2
> Let me know if you need more info.

In general, if you are using standalone branches, each branch is a full
copy of the complete history.

So doing 'bzr branch a b' will copy everything in 'a' into 'b', and you
will use 2x the disk space. At some point we might change this to use
hardlinks and doing copy-on-write, since it makes standalone branches a
little bit cheaper.

But for now, we came up with a different solution, which works in more
cases, and keeps disk usage low, even after the two branches have
diverged a bit.

You can create a repository, so that all branches that reside inside
share their ancestry storage. You can do that with something like:

bzr init-repo --trees repo
cd repo
bzr branch ../other/branch a

This will copy all of other/branch's history into the local repository,
and then create a child branch which only contains enough information to
identify the branch. (Note: for compatibility purposes, this doesn't
work if 'other/branch' is a bzr-v0.7 branch, but there are workarounds)

At this point, you can do:
cd $repo
bzr branch a b

And now a & b share their history, so both will be very small.

However, if you branch outside the repository, such as by doing:
bzr branch a /tmp/foo

It will create a new standalone branch that contains all of the history.

There is one other way to get 'cheap branches', but only because they
aren't really branches. If you do:

cd /tmp
bzr checkout --lightweight $repo/a my_checkout
du -ksh my_checkout

You will see that it is very small. But that is because a lightweight
checkout uses the branch information and storage of the original branch.
So if you do a commit in a checkout, it will update the other branch
(you can't do a bunch of commits on both sides like you could if both
were full branches).

I think that covers the gamut of bzr style branching (and cheapness).

Does that help, or just confuse things. I can try and simplify more if
you want.

Version: GnuPG v1.4.2.1 (Cygwin)
Comment: Using GnuPG with Mozilla -


More information about the bazaar mailing list