DBA > Articles

Getting started with Bazaar for MySQL code

By: By Daniel Fischer
To read more DBA articles, visit http://dba.fyicenter.com/article/

Since you're reading this, you probably know that Sun is switching to the Bazaar version control system for all development work on the MySQL server. Unlike the version control system that we've been using previously, Bazaar is an open source project and freely available to anyone. This means that it is now much easier to follow ongoing development, or even to participate in it! On the downside, just like our previous tool, Bazaar is not quite as straight-forward as traditional version control systems such as CVS or subversion. The aim of this article is to give an overview and a general idea of how to set up Bazaar, how to access the MySQL server source code repositories, and the basic commands for working with the source code.

Bazaar is written in python and requires the python 2.4 interpreter, or any newer version. If you're on Solaris, Linux, Mac OS X or a similar UNIX or UNIX-like operating system, chances are that you already have python. Go to the Bazaar download page and download the latest stable source package. You can run Bazaar directly from the extracted archive, or you can install it system-wide. For details, and a list of "soft" dependencies that can improve your Bazaar experience, see the installation FAQ list. If you're on Windows, get the Windows installer from the download page and see the Windows installation page for details. Note that you will have to install several libraries that Bazaar depends on.

After this, you have a basic setup of Bazaar, including a command-line interface. (By the way: If you somehow translated "go to the download page and download the latest stable release" to an apt-get invocation or similar, please make sure that you have at least Bazaar version 1.5.) There are many plugins for Bazaar that are outside the scope of this article. One that might be of interest is bzr-gtk, a plugin that implements a graphical user interface for several common tasks. You can find it on the Bazaar site. Accessing the MySQL Server repositories


The MySQL Server on Launchpad. The grey box that says "current development focus" has the link to the 5.1 branch.

The MySQL source repositories are mirrored on Launchpad. Visit the MySQL Server project page on launchpad to see available branches. About in the middle of that page, you'll see a "Timeline" section with several release series listed. Click on the one that says 5.1 to get to an overview of branches in the MySQL 5.1 series. Then, click on the mysql 5.1 link in the "Code for this series" section to get to the actual MySQL 5.1 branch. You'll see a bunch of lines of general information about the branch, and the most recently committed changesets. More important, this page also tells you how to get the source code. At the top of the page, there is a line that says "Get this branch", followed by a command, in this case bzr branch lp:mysql-server. This command is all you have to enter to create a local branch of MySQL 5.1 on your computer.

Sounds easy, right? There has to be a downside, right? Right! Creating a branch means that bzr has to download the complete history of MySQL up to the most recent revision in the branch you're branching off. In the case of MySQL, this means downloading close to 60.000 changesets. On top of that, I'm sorry to have to admit that Bazaar is not exactly the fastest version control system there is. Creating the branch could take more than half an hour plus several cups of coffee!

The bad news is that you're not going to avoid this. The good news, however, is that you only have to wait this long exactly once. Now is a good time to decide what you intend to do with the MySQL source code: If you're planning to create multiple local branches, for example your own branch with your own changes, or just several of the different MySQL release series, there is something that you should know about: Shared repositories.

When you create a checkout with CVS, you get a bunch of files - but only that. The history remains in the CVS repository. When you commit a change, you commit it to the repository. Bazaar, as I mentioned previously, is not as straight-forward. When you create a branch, your copy contains the complete history. (There are ways to avoid this, but unfortunately, Bazaar is still slow, and it doesn't matter too much in the end.) If you create two local branches, both contain the entire history. If you create a third branch, you get the entire history again. And so on.

This is a bit redundant, and also a bit redundant. To avoid the redundancy, you can tell Bazaar to store the revision history of several branches in one common repository. This is called a shared repository. Bazaar will only put any part of the history in the shared repository exactly once. Consequently, it will also only download any part of the history exactly once. Since the various MySQL server branches share a good deal of their history, this will save you most of the download time when creating your second branch, and also a lot of disk space. Here's how you do it:

First, before creating any branches, create an empty directory in which you will keep all your branches. Then, create a shared repository by running bzr init-repo. in it. Now you're set! Create your first branch in this directory, as outlined above. It will still take about half an hour to one houre to complete. Now, create another branch, for example, MySQL 5.0, in the same shared repository: bzr branch lp:mysql-server/5.0. It should be much faster this time! Here are all of the commands you're going to type again, for your convenience:

$ mkdir bzr
$ cd bzr
$ bzr init-repo .
$ bzr branch lp:mysql-server
$ bzr branch lp:mysql-server/5.0

Now that you have one or two MySQL branches, and know how to get more, let's explore what you can do with them. Building the MySQL Server from Bazaar

Assuming you're not reading through all of this without an idea of what to do with the MySQL source code, one of the first things you might want to do is building the MySQL server, so you can run it.

It's pleasantly easy to build the server right in the branch that you created. The MySQL manual has instructions on building from a source distribution. The steps for building from a Bazaar branch are almost the same. However, depending on your operating system, you need to prepare the source before you can follow the instructions. Optional: Export the Source

There is one thing that you might want to do if you want to keep your branch clean: Export the branch and build the exported code. There is no strict requirement for this, but it makes some tasks easier. This is fairly straight-forward. From within the branch you created earlier, run the following command:

Full article...

Other Related Articles

... to read more DBA articles, visit http://dba.fyicenter.com/article/