Using Bazaar On a Mac

Bazaar has become a tool I’m using all the time. Using Bazaar as a version control system means using a command line interface. I haven’t found a feature-rich Bazaar GUI tool like the ones that exist for Subversion. I feel alright with using a command line interface for executing commands; but it is frustrating to edit text, review diffs, and manage merges in a command line environment. It just sucks! I want something better: a work-flow that keeps me productive, and an appropriate interface for the task at hand. Specifically, I want my version control system to be integrated with my Mac and the existing tools I use; I want to be able to:

  • Manage my files and folders using Finder
  • Write commit messages, view diffs, and manager merges in TextWrangler

Moving/renaming files can’t be an issue

Version control systems are suppose to be smart; why do they always have an issue if I move a file to a different folder or change the file’s name? I want to be able to use Finder to manage my files and folders, not a command line interface!

Bazaar handles files I delete; but it also thinks that I’ve deleted one file and added a new file if I change the file’s name in Finder. This is disruptive to my work-flow, and Finder provides a great interface to organize my files; I want to use Finder (and other external applications), not bzr mv to move/rename files and folders.

automv Bazaar plugin

The automv plugin provides a command, bzr automv, which will look at your working tree and detect file/folder renames/moves. The plugin uses a configurable threshold to handle a rename/move of a file which also has changes.

Having this plugin installed will allow me to organize my files and folders using Finder (or other apps like Eclipse) without having to worry about moving them again with a Bazaar command. The Finder app provides a much more appropriate interface for dealing with file organization; the automv plugin will allow me to use it and make sure Bazaar understands my intentions.

You can install the automv plugin by branching it

Bazaar can use your plugins directory under the hidden Bazaar configuration directory in your home directory: ~/.bazaar/plugins

$ bzr branch http://bzr.oxygene.sk/bzr-plugins/automv/ ~/.bazaar/plugins/automv/

A CLI is not appropriate for complex tasks

Reviewing and managing merges conflicts are complex tasks; version control systems delegate this task to a human. For a human to manage these complex tasks, using appropriate tools is helpful.

TextWrangler is an awesome text editor for the Mac, offered for free by Bare Bones. There’s a pretty huge list of features, but I’d like to focus on using TextWrangler as an external diff tool for Bazaar.

difftools Bazaar plugin

The difftools plugin provides Bazaar a way to support the use of external diff tools, especially GUI tools.

Reviewing a diff of two files is much easier when the two versions of the file are side-by-side with syntax highlighting. The complex task of reviewing multiple diffs while managing merge conflicts is much better suited for a GUI. The difftools plugin supports many popular GUI diff tools; I’ve found it also seems to work with TextWrangler.

Branching the difftools plugin

Like automv, difftools is available in a public Bazaar repository; it happens to be hosted on Launchpad. You can install difftools in your plugins directory with the following Bazaar command:

$ bzr branch lp:bzr-difftools ~/.bazaar/plugins/difftools/

Notice the lp: prefix; Bazaar is integrated with Launchpad and offers this shortcut for Launchpad-hosted projects.

Delegating complex tasks to TextWrangler’s interface

TextWrangler ships with support for command line tools. We’ll have to enable these so we can configure Bazaar to delegate commands to TextWrangler, specifically for diffs, and set TextWrangler as our default editor for Bazaar.

Install TextWrangler’s Command Line Tools

By selecting TextWrangler » Install Command Line Tools… from the menu bar, you’ll have two Unix executables available: edit and twdiff, both in /usr/bin/.

Showing TextWrangler's menu option to Install Command Line Tools...

Showing TextWrangler's menu option to Install Command Line Tools...

You should see a dialog similar to the one below, confirming that the command-line tools are installed:

Showing the dialog that TextWrangler displays after installing the Command Line Tools.

Showing the dialog that TextWrangler displays after installing the Command Line Tools.

We’re ready to modify our Bazaar configuration to utilize these command line tools we just had TextWrangler install.

Configuring Bazaar to use TextWrangler

Our last step here is to link up Bazaar commands that will launch TextWrangler. From our earlier step of installing the difftools Bazaar plugin we can create a command which allows us to view diffs in TextWrangler instead of just in a command line interface.

Your Bazaar configuration file is located at: ~/.bazaar/bazaar.conf

We can use TextWrangler’s File » Open Hidden… menu option to navigate to and open the Bazaar configuration file since it’s in the hidden Bazaar folder. My configuration file contains the following:

[DEFAULT]
email = Eric Ferraiuolo <eferraiuolo @gmail.com>
editor = edit -w

[ALIASES]
twdiff = diff --using twdiff --diff-options --wait

There are two important lines here, first:

editor = edit -w

Which configures Bazaar to use TextWrangler (edit) as it’s default editor with the wait option enabled telling Bazaar to hold the command until you’re finished in TextWrangler. Now doing executing a bzr commit command in a working tree will open TextWrangler for you to type in your commit message.

The other important line is adding an alias command, twdiff:

twdiff = diff --using twdiff --diff-options --wait

This line sets up an alias which runs Bazaar’s diff command with the option to use (--using) TextWrangler and wait for you to finish with the files in TextWrangler before the command returns. This alias allows you to run: bzr twdiff in a working tree and delegate to TextWrangler’s interface to review the diff.

My Thoughts

I’ve been happy so far with this Bazaar setup on my Mac. I feel much more confident and less frustrated when dealing with my files under version control. I really like that I didn’t have to add any tools or applications to my Mac, just a couple of light-weight Bazaar plugins.

Let me know your thoughts, or about your Bazaar setup on your Mac. I’d be interested to see if you have something I like better. :-)

6 Responses to “Using Bazaar On a Mac”


  • Did you try QBzr (Qt GUI front-end for bzr)?

  • @bialix No I haven’t. When looking at it before I remember that it added a new set (about 15) of commands (aliases) to Bazaar. It seems that you execute the QBzr commands in the Terminal which launches the GUI?

    QBzr would be much more compelling to me if it executed all the bzr commands through the GUI. I’ve used Versions app and SmartSVN when working with Subversion repositories and felt satisfied and confident.

    In any case, I might try out QBzr and see how it feels; but a feature-rich GUI app for Bazaar that’s similar to Versions app for Subversion would be, I feel, the best kind of tool to have.

  • How do you handle commits? I’m guessing from this that you still must use the CLI for that sort of thing?

  • @Josiah By setting editor = edit -w in my bzr config file, typing bzr commit TextWrangler is opened and I get to author my commit message there; making it much easier to add formatting.

  • Still coming back and reading this article every once in a while. This is good stuff!

    I was wondering if anything in your personal setup has evolved since you wrote this.

    (Bazaar releases are pretty frequent—I think they try for monthly updates. And since the recent 2.0 release, it might be worth checking if any features that previously required workarounds are now built-in to the core program.)

    Keep it coming! :)

  • @Tony, I’m glad you find this helpful :-)

    I would say the only major change in my setup is the removal of the bzr automv plugin since I can now use the bzr mv --auto command. I forget which of the (as you mentioned) frequent Bazaar releases this featured showed up.

    I’ve also setup the bzr-git plugin to provide inter-op with Git repos, although nothing here is Mac OS X specific.

    The task I would like to simplify is working with remote repositories and coming up with a way to easily to have them configured with “nicknames”. This maybe as simple as digging through the Bazaar docs some more, or just waiting until a Mac OS X 10.6 Installer is created for Bazaar Explorer. Currently installing Bazaar Explorer on Snow Leopard is a fairly crazy list of packages and tasks.

Leave a Reply

Additional comments powered by BackType