My merry five minutes with Bazaar

4 June 2007

After `OpenBSD failed the five minute test`_, can Bazaar be usable within 5 minutes?

Backup upon Backup

I have been writing my latest little Python program and it has accidentally become not so little. So I have been backing the directory up before making changes each little coding session. Now I have 15 or so old directories, and if I need to go back and see what I have done, and at some point I will, then it would be a little dull to try to grep my way through them.

So I decided to use a source control management system. I strongly dislike CVS and Subversion, for reasons I can explain another time, and for another project I have been using hg (also known as Mercurial), so I was just going to use that. This time, however, I decided to use Bazaar, not least because if I ever get the code to a point where I am willing to share it, then I will probably upload it to my launchpad.net thingie, as I find Sourceforge pretty horrible to use.

My two minutes with Baz

To install programs is a bit operating system specific of course, but on Gentoo Linux you just have to type:

emerge bzr

Note, that confusingly enough, it is not the package 'bazaar' - that is an old deprecated program that does not share code and has a different set of features. That tripped me up as I was using the wrong program to start with. Hopefully the Gentoo maintainer who I ran into will make it more clear. So that used up the first two minutes.

Fortunately, the correct Bazaar is so user friendly that I easily did the rest in three minutes. I subsequently learned that Bazaar folks call the new one bzr and the old one baz. Both programs were written by the same people, they seem to have simply downed tools on the old one then wrote the new one. There seems to be no good reason to use the unmaintained old one, and many good reasons to use the new one. Anyway, enough of this, lets move on.

My Three Minutes with Bzr

So I followed the relevant bits of the handy tutorial. Firstly I set up my name and email address. Which I have cunningly obfuscated so I get less spam (my email address is easy to figure out if you are a real human).

bzr whoami 'Command Line < warrior@localhost.com >'

Then I went to my folder with my code in and blessed it with holy penguin pee:

bzr init

This made a folder called .bzr which will contain the history and other control data. You are meant to ignore it and leave this alone. Then I could run:

bzr status

This showed all my files as 'ignored', since none are currently being watched by bazaar. Next I did:

bzr add *.py

So at this point, all of my Python files are being watched by the system, and all other file types are unknown. Cleverly, it automatically ignored all the compiled Python bytecode files (.pyc) which I would never want to track.

So the manual says "There are three classes of file: unknown, ignored, and versioned". My Python source files are 'versioned' (yes they make up words!), while my compiled python files are ignored and my other files are unknown to the system.

Next up I added another file, and was ready to make my first commit. I used -m to add a message:

bzr commit -m "added my initial files"

That's all there is to it really, (I am sure there are lots of other features I do not need). A rather nice thing is that you can use normal filesystem commands without messing up the system and no need for some horrid database. If I want to stop Bazaar from tracking a file then I can use:

bzr remove oldfile.py

Or alternatively I can just delete it using rm.

Bazaar VS Mercurial

I am pretty happy with both so far. I will probably use Bazaar for new projects at the moment as it seems a tiny bit more user friendly.

Having said that, the commands seem very similar, so I do not know why the world needs both? They are both in Python, both under the General Public Licence and they both do the same job. It seems a bit weird to have two.

While the new kid on the block, Bazaar seems to be well liked by hobbyists like me and groups at the 'community' end of the open source world, while hg seems to be more liked by the large corporate projects. So to take two examples, Ubuntu uses Bazaar for its' projects, while Solaris uses hg. Zope uses Bazaar while Java uses Mercurial. Yes the code to Java is maintained in a Python application, I can't say that I'm surprised, while Java has taken over the world in terms of people than can use it, it is still not fast at all in certain circumstances.

The performance benchmarks out there seem pretty dated but seem to favour hg over bazaar for ridiculously large projects (i.e. several gigabytes), however if high performance with a giant codebase over user-friendliness is your bag then you really want to be looking at git which is out in front (with hg in second and proprietary tools are way-way down the list).

Those benchmarks are irrelevant for me when 20 files is a pretty massive program. Also all projects are different, so no one system will win them all. I think it may be a couple of years still until the plates stop spinning and we can see who wins the distributed SCM world; in the centralised SCM generation, CVS eventuality became the dominant standard tool.

Other interesting things to look at would be graphical front-ends, Emacs plugins, and so on; but at this point, I can now manage my little project, so Bazaar passes the five minute test.

1 Daniel says...

I've been using Bazaar for a few small projects and I've really liked it. Once I wrapped my head around it I've really grown to like decentralized source control over traditional CVS/SVN models. I haven't had a reason to play with Mecurial yet, as the code base for those projects is relatively small compared to the stuff I've been doing for work. I will say that Bazaar's ease of renaming and changing directory structure is great when you're first starting a project and still revising the layout.

One of these days I'll probably convert some of my work code to a DSC system, just to play with Bazaar or Mecurial with a larger project, but SVN is just fine for that right now.

Posted at 2:57 a.m. on June 5, 2007


2 DG says...

Hi, thanks for the intro to bzr etc...

some questions :

  1. I presume bzr behaves the same as svn/cvs, in that if you 'rm $file'

    first, it will restore it when you next do a 'bzr update' ?

  2. Have you looked into finding any web interfaces (like trac) for bzr?

We use subversion at work, and it works very well with trac. Because of this there is no way we could ever change, unless trac supported bzr (having said that, a quick google comes up with https://launchpad.net/trac-bzr ).

Tried branching / merging yet?

Posted at 7:21 a.m. on June 5, 2007


3 Zeth says...

Hi everyone,

Hi Daniel,

Yeah, thanks for that, I did not really have time to talk about why decentralised SCMs suck a whole lot less than CVS, SVN etc, but I am squarely in the decentralised camp.

Dave,

  1. Well in the situation given above where it is just my code, when you

    rm filename.txt, then it is gone, it does not come back. You can however recreate it with bzr revert filename.txt

However, if I was tracking another upstream source, then if I used bzr pull to pull down the changes, then it would come back if it was still upstream. However, I would merge rather than pull I suppose, otherwise I would lose what I had done to the code.

  1. I haven't really yet (that did not fit within the five minutes). One

    nice thing is that you do not have to, being a distributed SCM, means that you can push a copy out to a third-party service such as Launchpad and have them worry about it.

Apart from that, I guess there are lots. A quick Google brings up these: http://www.lag.net/loggerhead/ http://goffredo-baroncelli.homelinux.net/bazaar

Phill

Maybe, I guess I am just annoyed with Java at the moment because in my day job we were forced to move to this proprietary Java based web framework which is as slow as hell, really awful.

Posted at 8:51 a.m. on June 5, 2007


4 Daniel says...

Why did you never consider GIT? Kernel an more and more OS use it. I love it for smallest to big project and even convert CVS/SVN projects to git for me at home.

Daniel

Posted at 6:28 p.m. on June 8, 2007


5 Bob says...

I second Git

Here is a funny talk by Linus himself on why he wrote Git because nothing else does what he needs.

http://www.youtube.com/watch?v=4XpnKHJAok8

ps, Git is not an acronym. It's British slang for a b*std

Posted at 5:22 p.m. on June 18, 2007


6 dbr says...

"Yes the code to Java is maintained in a Python application" I'm not sure I'd use a source-control application that's written in the language I'm currently developing. What if there's a bug that screws up the java-vcs command and won't let you push your fix? :P

I've been using darcs for tracking local changes (Kind of as a less-temporary undo) - basically because it has a nice interactive command-line interface, then when I get to a ~complete stage, I commit it to a remote SVN server for syncronization between multiple machines, and as a backup..

I've been meaning to play with bzr or hg.. I tried Git, but it was horribly convoluted. Installing it created about 150 files in /usr/local/bin/, some of them binaries, some of them shell-scripts, some of them aliases, some of them perl scripts, and it also required a few perl modules.

If you get the time, it'd be interesting to read a comparison between bzr and mercurial(hg)

Posted at 2:46 a.m. on February 25, 2008


What do you have to say?

Show Editing Help

About

Hello, my name is Zeth, I'll be your host here.

Command Line Warriors is about taking control of your own technology, it looks at our experiences of computing; especially using GNU/Linux, the Python programming language, the command-line and issues such as techno-ethics, best practices and whatever is cool now. If you take control of your technology then you are a Warrior too!

This site is your site too which means that you can contribute and get involved. You can leave comments using the facility provided. For me, the comments and discussions are by far the best part of the site. So please do have your say!

Latest Discussions

Zeth

November 29, 2009
Hi Jordan, yes that URL is gone now. I have a new contact form on this site.
Python CGI contact forms

Jordan

November 29, 2009
Zeth attention! Your form, http://zeth.me.uk/contact/, is not working The explorer says connecting ..but nothing happens Sorry for my poor English: I am Spanish Regards
Python CGI contact forms

Jordan

November 26, 2009
Sorry: tell me , not tellme (I'm spaniard) And http://zeth.me.uk/contact/ don't work
You got the touch, you got the power

David Jones

November 25, 2009
Your mad skillz are too l33t! for me. I specifically switched to Google Reader so that I could show people what blogs I read. But I couldn't work out how ...
How to find the fashionable blogs quickly

Brian R. Hickey

November 20, 2009
Symantec picked it up too.
How to bring down Internet Explorer with six words

Zeth

November 17, 2009
Thanks djm, I am the moose here. Christian, assuming one actually does Internationalise the countries, it should still work I guess, as the gettext stuff will happen before the list ...
Countries in Django

Phillip Temple

November 17, 2009
Good start, but: a) wouldn't I want None back rather than 'ZZ'? b) why not add a 'shortcut' boolean, then prepend flagged fields (plus usual '-----' separator) to the actual ...
Countries in Django

djm

November 17, 2009
Am I being a moose or did you mean: from whatever.countries import CountryField instead of from whatever.countries import CharField ? Good post though, cheers.
Countries in Django

Christian Joergensen

November 17, 2009
Wouldn't the ordering get messed up after i18n?
Countries in Django

Steve - Electronic Cigarettes Fan

November 17, 2009
Very well done. Is your blog just you writing? Nicely done, Steven.
Blogger vs Wordpress

vetetix

November 15, 2009
Sorry to bother you nearly two years after you wrote this blog article, but I can't manage to find how to modify an existing field. I am trying to change ...
Three Useful Python Bindings - ClamAV, Apt and Evolution

Manju

November 4, 2009
I am transferring some files using psftp to other device's FAT partition. But the filestamp of the file being transferred is modified to that of FAT device, after the transfer. ...
PuTTY Series: Using PSFTP

iki

November 2, 2009
or simpler: socket.gethostbyname_ex(socket.gethostname())[2]
How to find out your IP address in Python

iki

November 2, 2009
local_ip = set([ i[4][0] for i in socket.getaddrinfo(socket.gethostname(), None) if i[0] == 2 ])
How to find out your IP address in Python

Fred

November 2, 2009
testing rst ------------- - point 1
An Introduction to ReStructuredText

Ano

October 27, 2009
"You simply found the license of the StumbleUpon Toolbar for Internet Explorer." That's possible. I've got some more interesting information to add. Firstly, go to this page: https://addons.mozilla.org/en-US/firefox/addon/138 - this ...
Are your Firefox extensions proprietary software?

Ken

October 21, 2009
Stumbled in here at lunch. This is the best find of the week. Thanks.
Three classic command line tips

Jim

October 19, 2009
Thanks for the rtsp:// post - that's something that has been bugging me for a while!
Three classic command line tips

Zeth

October 18, 2009
Thanks for the comments guys. Great to see the all the gang are still here!
Three classic command line tips

Bubba

October 18, 2009
Is there any way psftp can return the true transfer rates oberved during the actual transfer?
PuTTY Series: Using PSFTP