Using a shared repository

The default configuration of a Bazaar project is the standalone tree. A standalone tree includes a repository, a branch and a working tree.

When working with multiple branches, creating multiple standalone trees is inefficient, because the revision data is duplicated in multiple repositories:

Using a shared repository

A more efficient solution is the shared repository configuration, where branches don't have their dedicated repository but share a single common repository. The shared repository stores all the revisions of all the branches, eliminating unnecessary duplication, and speeding up branch operations:

Using a shared repository

A shared repository with its branches is organized as follows in the local filesystem:

/path/to/shared/repo/
|-- .bzr
|   |-- repository      # repository data
|-- some_branch
|   |-- ...             # project files in the working tree
|   |-- .bzr            # hidden .bzr directory
|       |-- checkout    # working tree data
|       |-- branch      # branch data
|-- another_branch
|   |-- ...             # project files in the working tree
|   |-- .bzr            # hidden .bzr directory
|       |-- checkout    # working tree data
|       |-- branch      # branch data
|-- yet_another_branch
|   |-- ...

The shared repository is inside the .bzr directory at the top level.

The subdirectories correspond to branches, optionally with a working tree. In this setup, the branches don't have their own repository; they all use the common shared repository.

In practice, most branches differ only in a few revisions. Therefore, using a shared repository usually makes a huge difference both in terms of storage and speed. The larger the project, the greater the benefits of a shared repository.

In general, it is almost always better to use a shared repository right from the start instead of a standalone tree, even if you don't expect to work with branches or collaborate with others in the near future.

Using the command line

You can create a shared repository using the bzr init-repository command with the target location as a parameter. For example:

$ bzr init-repository /tmp/shared-repo
Shared repository with trees (format: 2a)
Location:
  shared repository: /tmp/shared-repo

This creates a new directory with only a hidden .bzr directory inside. This directory stores only a repository without branch data or working tree data. Working tree and branch commands will not work at the root of a shared repository. For example:

$ bzr status
bzr: ERROR: No WorkingTree exists for "/tmp/shared-repo/.bzr/checkout/".
$ bzr log
bzr: ERROR: Not a branch: "/tmp/shared-repo/.bzr/branch/": location is a repository.

The shared repository directory is a container for branches. You can create as many branches inside as needed. The branches will store their revisions inside the shared repository instead of their own .bzr directory. This way, all the branches can reuse the common revisions.

Using Bazaar Explorer

In Bazaar Explorer, you can create a shared repository using the Initialize view, the same view you used for creating branches. You can open this view in several ways:

  • From the menu, select Bazaar | Start | Initialize
  • From the Welcome view, in the Start a new project tab, select Initialize
  • Using shortcuts such as Ctrl + N (Windows, Linux), Cmd + N (Mac OS X)

In the Location textbox, you can either type the path to the target directory, or click on the Browse button and navigate to it. In the Workspace Model box, select either Shared repository or Feature branches.

With the Shared repository option, Bazaar will simply create an empty shared repository, just like the bzr init-repository command. With the Feature branches option, Bazaar will create a shared repository and a new branch inside it named trunk. If the target directory contains files, use Move existing files, if any, to the working tree location to have Bazaar move those files into the new branch.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.144.232.189