A stacked branch is a branch that knows how to find revisions in another branch. Stacked branches store just the unique revisions, making them faster to create and more storage efficient. In these respects, stacked branches are similar to shared repositories. However, stacked branches have additional benefits:
These benefits make stacked branches ideal for various scenarios including experimental branches and code hosting sites.
To create a stacked branch, use the stacked option of the branch command. For example:
bzr branch --stacked source-url my-dir
This will create my-dir as a stacked branch with no local revisions. If it is defined, the public branch associated with source-url will be used as the stacked-on location. Otherwise, source-url will be the stacked-on location.
Direct creation of a stacked checkout is expected to be supported soon. In the meantime, a two step process is required:
Most changes on most projects build on an existing branch such as the development trunk or current stable branch. Creating a new branch stacked on one of these is easy to do using the push command like this:
bzr push --stacked-on reference-url my-url
This creates a new branch at my-url that is stacked on reference-url and only contains the revisions in the current branch that are not already in the branch at reference-url.
If the local branch was created as a stacked branch, then you can use the --stacked option to push and the stacked-on location will be implicit. For example:
bzr branch --stacked source-url my-dir
cd my-dir
(hack, hack, hack)
bzr commit -m "fix bug"
bzr push --stacked
The important thing to remember about a stacked branch is that the stacked-on branch needs to be available for almost all operations. This is not an issue when both branches are local or both branches are on the same server.
Stacking of existing branches can be changed using the bzr reconfigure command to either stack on an existing branch, or to turn off stacking. Be aware that when bzr reconfigure --unstacked is used, bzr will copy all the referenced data from the stacked-on repository into the previously stacked repository. For large repositories this may take considerable time and may substantially increase the size of the repository.