Chapter 9. Using Bazaar Together with Other VCS

Bazaar is very flexible and can work well with other version control systems almost completely transparently. In this way, even if your team is using a different VCS, you may still have the option to use Bazaar and take advantage of its unique features.

In this chapter, we will explain how to use Bazaar to interact with other version control systems, along with important practical tips and limitations that are good to be aware of. We will cover, in detail, how to work with Subversion and Git directly. As an alternative solution, we will explain fast-import, an indirect method that can work with any VCS, at least in theory.

The following topics will be covered in this chapter:

  • Working with other VCS in general
  • Using Bazaar with Subversion
  • Using Bazaar with Git
  • Migrating between VCS using fast-import

Working with other VCS in general

Bazaar can interact with other version control systems through plugins. An appropriate plugin can intercept version control operations between Bazaar and the foreign system, and perform the necessary translation between the two protocols. In this way, in theory, Bazaar can work with any other VCS.

Throughout this chapter, we will refer to other version control systems as foreign repositories, and branches or branch-like concepts in such systems as foreign branches. In this section, we will cover the important general subjects when working with foreign repositories and branches, such as how to install the required plugins, and common good practices, limitations, and known issues.

Working with foreign branches

In order to interact with foreign branches, the plugin must intercept all the operations between Bazaar and the foreign branch, and perform the necessary translation between the different protocols. This translation is an overhead, and inevitably results in some slowness, especially in operations that potentially fetch large number of revisions, such as branch, checkout, push, pull, and merge.

A very important key point to understand is that when creating a local branch by using bzr branch or bzr checkout from a foreign branch, the new local branch will be a native Bazaar branch. You can use the branch in your local workflows in the same way as any of your other local native Bazaar branches; all your operations will be native Bazaar operations.

Another key point is that in order to ensure integrity in interactions with multiple foreign branches, Bazaar identifies unique revisions of the foreign repository even across multiple branches, and it preserves all the necessary metadata to avoid loss of information.

Installing plugins

Depending upon your operating system, the plugins required to work with foreign branches may be installed by default, or you may have to install them as separate packages.

The relevant plugins used in this chapter are as follows:

  • bzr-git: This provides support to work with Git branches
  • bzr-svn: This provides support to work with Subversion branches
  • bzr-fastimport: This provides support to import and export VCS-agnostic version control data

You can confirm whether these plugins are already installed by using the bzr plugins command:

$ bzr plugins
fastimport 0.14.0dev
  FastImport Plugin

git 0.6.7
  A GIT branch and repository format implementation for bzr.

svn 1.2.1
  Support for Subversion branches

For basic information about each plugin, you can use the bzr help command by specifying the name of the plugin. For example, bzr help svn.

Installing plugins in Windows or Mac OS X

In Windows and Mac OS X, the installer includes the plugins to work with Subversion and Git by default. If you deselected them during installation, then you can install them later by running the installer again and selecting the plugins you need. For example in Mac OS X:

Installing plugins in Windows or Mac OS X

Installing plugins in Linux

In Linux, all Bazaar plugins are in separate packages; you can install them by using the software management tool of your distribution. The package names of the plugins are typically prefixed with bzr-; for example, bzr-svn, bzr-git, and bzr-fastimport.

Installing plugins using Pip

Installing plugins using Pip, the Python package manager tool, can be a good option if you don't have administrator access or if you prefer to isolate the plugins in a virtualenv environment. The package names of Bazaar plugins are typically prefixed with bzr-; for example, bzr-svn, bzr-git, and bzr-fastimport. Install the plugins you need by using pip install. For example:

$ pip install bzr-svn

Installing additional requirements

Some plugins may have additional requirements; for example, bzr-svn requires the subvertpy Python package, and bzr-fastimport requires fastimport. These requirements are mentioned in the relevant plugin-specific sections. To install these requirements, follow the same steps as when installing the plugins themselves.

Understanding the protocol overhead

Keep in mind that when working with foreign branches, Bazaar must translate between the remote protocol and its own native format. For this reason, all the operations involving foreign branches are slower as compared to the same operations with native Bazaar branches.

Bazaar is a distributed VCS, therefore when branching from a remote branch, it downloads the full revision history, even if the remote branch is not a distributed VCS. Considering that the revision information must be translated to the native Bazaar format, this can take a very long time.

Using shared repositories

When working with multiple remote branches, using a shared repository helps reducing the overhead of network transfers, as the common revisions in the remote branches only need to be downloaded once.

Similarly, in the case of fetching foreign branches, using a shared repository helps reducing the overhead of translation between Bazaar and the foreign protocol, as the common revisions in the foreign branches only need to be translated into Bazaar's native format once. Thus, downloading a second branch from the same foreign repository should be significantly faster than the first.

Limitations

Although a plugin can do a great job at translating the core version control operations, some features may not be possible to implement perfectly due to fundamental architectural differences between Bazaar and the foreign system. This is an inevitable limitation; you should always keep this in mind when interacting with another VCS through Bazaar.

Before you begin to use Bazaar with a foreign repository, make sure to read the Limitations section of the plugin documentation carefully, in order to understand the key differences. It also helps to have a good working knowledge of the given foreign repository.

Issues and crashes

Working with foreign branches is very difficult, and unfortunately sometimes even the most basic operations, such as the initial branching or checkout, may fail. In this case, Bazaar dumps a stack trace, which you can use to report it as a bug, but, of course, that's little consolation when you need to work on something immediately.

A possible last resort in such cases may be using fast-import to convert the version control information of the foreign branch into Bazaar's native format. We cover fast-import later in this chapter. However, this method is designed for migrating repositories from one version control system to another, and thus is really not the same thing as performing Bazaar operations on foreign branches.

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

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