Cheap Branching Anywhere

Matthieu Moy Matthieu.Moy at imag.fr
Tue Jun 6 00:12:16 CDT 2006


"TK Soh" <teekaysoh at gmail.com> writes:

> Just curious... I saw this on bzr's homepage
> (http://bazaar-vcs.org/RcsComparisons):
>
> <quote>
> Cheap Branching Anywhere
> -----------------------------------
> Some systems only support cheap branching on filesystems that support
> hard links, but bzr can do cheap branching on any filesystem, and even
> on FTP servers.
> </quote>
>
> Any filesystem!? With the kind of repo size I am dealing with, it
> sounds really attractive. Any idea how it is done,

In bzr, you have two distinct notions to keep the history of a
project: The "repository" contains a set of revisions, each revision
being identified with a unique revision-id, and stored in a
delta-compressed manner. Ancestry is also stored here, so you have a
DAG of revisions.

Then you have the notion of branch. Each branch is a sequence of
revisions, but in the branch, you only need to keep the revision-id,
not the complete information that bzr will find in the repository.

For example, I have a repository containing several bzr branches:

$ du -sh .bzr/ bzr.dev/.bzr/ bzr.line/.bzr/ bzr.revnoX/.bzr/ 
27M     .bzr/          # This contains the revision store
372K    bzr.dev/.bzr/  # This contains only the revision history
376K    bzr.line/.bzr/
340K    bzr.revnoX/.bzr/

Now, of course, if you have a check-out (working tree) for each of the
branches, you'll use that disk-space in addition. However, you can
easily have one working tree only, and use "bzr switch" (currently
only available as a plugin, but should land in mainline once it is
better implemented) to change the branch.

Anyway, the size of check-outs are /usually/ not a big problem, since
people typically have tons of available disk-space for throwable
things, and wans to keep the important and backed-up (and/or
replicated on a remote public server) data as small as possible.

A "standalone branch" in bzr is simply a branch, a repository, and a
check-out located in the same place of the filesystem.

> and if the same can be done with hg?

AFAIK, Mercurial doesn't do this, but you have the notion of
multiple-heads branch which does something similar.

-- 
Matthieu


More information about the Mercurial mailing list