Muffinresearch Labs by Stuart Colville

Bazaar Version Control | Comments (2)

Posted in Code on 22nd April 2007, 11:53 pm by Stuart

With the development of TweetyPy I’ve moved to using Bazaar for version control. Bazaar is written in Python so it will work as expected cross-platform.

Bazaar is different from a typical version control because it doesn’t rely on having one centralised repository instead it operates on a de-centralised model. You can either operate with the repository stored locally, or, you can set up a centralised location for your code and then checkout a out to each developer’s machine. When the changes are committed they are stored both locally and uploaded to your remote repository.

The reason why this is cool is that it means that if you like to work off-line, hack on the train for short or long periods, or your connection to the internet is just down for a time, you can continue to work and commit new revisions. When off-line you simply add a switch to you command e.g: bzr commit --local -m "a commit message" and then your commits will be set to pending. When you are back online you run the commit again and all your off-line commits will be synchronised.

The other thing that hits home about bazaar is that it simply does not get in the way of the work you are doing. It just works as expected. Setting up branches and repos takes two secs. Really, hang on I’ll prove it, read on…

Examples:

For example. You’ve already installed Bazaar. After setting your name and email address with bzr whoami "Your Name <Email Address>", to set-up a working branch simply navigate to that directory with your command line and then type bzr init. Then add the files you want to version e.g: bzr add (adds everything). Then do your first commit. bzr commit -m "my first revision".

A shared repository

If you want to be frugal with your disk space you can use a shared repository. This then means that all of the branches you create or checkout will utilise the same area for storage. For linux/unix/mac systems a logical place would be your home directory. On windows choose a location of your choice. Maybe somewhere in “my documents” will suffice but really the choice is yours whatever the system. To do this run: bzr init-repo --trees <directory> where <directory> is the directory you want to use.

A remote repository

Creating a remote repository for your project is pretty straightforward too. bzr init-repo --no-trees sftp://yourhost/path/repo/ creates the repo. Next we need to initialise our project bzr init sftp://yourhost/path/repo/project.

To do something with this branch you need to check it out to your local machine. Change directory to where you want to store your on your local machine and then run bzr checkout sftp://yourhost/path/repo/project dev. This will create the branch in a directory ‘dev’ in the directory where you run the command from.

As a test create a file. e.g: vim mytest.txt (windows users can improvise with notepad or WHY). Now you need to add the file: bzr add. Lastly commit this file. bzr commit -m "the first revision for project x" If all is well as you have checked out a remote branch the file will be committed both locally and the revision info (Note: Not the file itself) will also be sent to your remote repo.

If you want to you can now test this by checking out the same remote branch to another location on your system you should see the file you comitted appear in the location your checked the branch out to.

Now for a couple of useful commands. bzr status tells you what files are modified, what files are added etc. It’s a good way of checking where you are at. bzr log will show you all of the current revisions and the comments along with who commited the branch.

Publishing branches

Publishing a branch is totally straightforward as branches are self-contained in the directory they are created in, you only have to copy the directory to somewhere publicly accessible for the branch to be available for people to checkout. E.g http://muffinresearch.co.uk/bzr/tweetyPy/devel. The current development branch of TweetyPy. All someone would need to do to take a copy of the branch from this location is to run bzr branch http://muffinresearch.co.uk/bzr/tweetyPy/devel.

In conclusion

The more and more I use Bazaar the more I love it. It’s simple, it does everything that I need from a version control system and that’s all there is to be said. Like the reponse to the command bzr rocks. It sure does!

Post Tools

Comments: Add yours

1. On June 5th, 2007 at 1:33 am Dealing with conflicts in Bazaar Version Control | Muffin Research Labs by Stuart Colville said:

[...] post is a follow-on from a previous post that formed a basic introduction to Bazaar version control. If you’d like to find out more about Bazaar then you can also read about it on the official [...]

2. On August 14th, 2007 at 10:34 pm Contributing to projects on Launchpad.net with Bazaar | Muffin Research Labs by Stuart Colville said:

[...] Bazaar version control is a really straight-forward to use, de-centralised version control system written in Python. Now an introduction to bazaar is beyond the scope of this article but you can read more about bazaar on http://bazaar-vcs.org or read my previous post; “Bazaar Version Control“. [...]







XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>



Ubuntu: Turn off changing workspace with mouse wheel|(0)

I found the changing with the workspace with the mouse wheel really annoying. To disable it go to System => Preferences => CompizConfig (available if the compizconfig-settings-manager package is installed) and uncheck “Viewport Switcher” which is under the “Desktop” heading.

Ubuntu: Mounting a TrueCrypt volume at startup or from the CLI|(0)

All you need is a mount point e.g: mkdir /media/ and then use the following: truecrypt /path/to/truecrypt/diskimage /media/. This is handy when you want to mount a truecrypt image at start-up or just do it quickly from a shell. It’s far more direct than using the GUI.

Photos on Flickr

© Copyright 2004-09 Stuart Colville, all rights reserved. May contain traces of Muffin. Powered by WordPress. Hosting by Slicehost.com This page was baked in 0.764s.