Kash Farooq's software development blog

.NET Developer

Posts Tagged ‘BZR’

Ignoring files and folders with Bazaar Source Control

Posted by Kash Farooq on September 15, 2009

Continuing the series of blog posts to help you move away from subversion.

In Subversion, you can ignore files or whole sub folders with Subversion properties. Unfortunately, you have to do this everytime you add a new project to your source code structure – for example, you have to add Subversion properties to ignore the new obj and bin folders.

With Bazaar you can also ignore a specific file or directory. e.g. to ignore a directory:

bzr ignore src/myproj/bin

The first time you ignore a file, a .bzrignore file is created. This file contains all the files and folders you want BZR to ignore. You can push this file to a shared repository and then everyone who makes a branch from the shared repository will ignore the same files.

Rather than ignoring files and folders individually, you can update this file yourself to add pattern matching file paths you want ignored. Paste the following into your .bzrignore to ignore all bin folders, obj folders, ReSharper folders and associated files, and Dev Studio files that you normally do not put in source control:


Now, when you commit .bzrignore and push this file back to the shared repository, everyone who pulls the changes to their branches will ignore the same files.

To always ignore these files for all of your BZR branches, you can paste the above code the global ‘ignore’ file. You can find this at:

  1. Windows Vista: C:\Users\your-user-name\AppData\Roaming\bazaar\2.0\ignore
  2. Windows XP/2003: C:\Documents and Settings\your-user-name\ApplicationData\bazaar\2.0\ignore

Posted in Bazaar Source Control | Tagged: , | Leave a Comment »

Getting started with Bazaar Source Control

Posted by Kash Farooq on September 14, 2009

Following on from moving away from subversion, here are some instructions to get you up and running with Bazaar on Windows.

These instructions are generic for any type of file you want to put into source control – however there are one or two Dev Studio/ReSharper/.NET specific comments.

Install it

First, let’s install it. I installed bzr 1.18-1 Windows Standalone Installer. I unticked TortoiseBZR – you don’t need it! And I let it add BZR to my PATH.

Create a repository

I created a BZR repository “trunk” on my USB pen drive (mounted as f:).
Open a command prompt and then run the command:

bzr init f:\bzr_repo

Create a personal branch

Do a “checkout” of this repository. In BZR speak, I’m creating a personal branch:

bzr branch f:\bzr_repo c:\dev\bzr_branch

This command created the directories for me.

Add some files

Now you can add some code to your local branch. I exported all my code from my subversion repository into c:\dev\bzr_branch.
Open a command prompt at c:\dev\bzr_branch and run the command:

bzr add

This added all my code to my local change set. I haven’t touched the trunk on my USB drive.

Commit your file adds

To do a commit, issue the command:

bzr commit

Notepad pops up for me to add some commit comments. Saving the file commits the added files to my local branch.
I still haven’t touched the trunk on my USB drive.

Push your commit to the trunk

Finally, you can send your change set to the trunk on your USB drive:

bzr push f:\bzr_repo

You only have to add f:\bzr_repo for your first push. For subsequent push commands, it uses the last push location provided.

Now we can make some code changes

Go ahead and change some code, add some files, compile and then run the command:

bzr status

It shows you all the files that you have amended. Unfortunately it also shows you files and folders that you don’t want to commit to source control (obj, bin, ReSharper, etc).

Ignoring files

You can ignore files and folders with the .bzrignore file.

Push your changes back to the central repository

Now that you have ignored files that you don’t need to commit, running the following commands adds the files you do want and commits them locally (with notepad popping up) and then pushes them to your trunk.

bzr add
bzr commit
bzr push

This article should get you going. I’ll be writing a few more blog posts to discuss merging, renaming files and integrating with a subversion trunk.

Posted in Bazaar Source Control | Tagged: , | 2 Comments »

Bazaar or Git? Moving away from Subversion.

Posted by Kash Farooq on September 8, 2009

I’ve had enough of Subversion and decided to move to Bazaar. Click BZR in the Tag Clould to see my series of blog posts to help you do the same.

Do any of these Subversion complaints sound familiar?

  • You are randomly instructed that “you need to run update”. You then do an update – which takes ages to complete. And then, finally, you see that there were no changes that needed to be downloaded.
  • You are randomly instructed that “you need to run cleanup”.
  • You have huge merge problems. For example, you use ReSharper to rename a class, and some else has updated that class in the meantime. You then see the dreaded tree conflict error (shudder). Or even worse, you rename an entire namespace and folder (double shudder). Now you really are in for a world of pain.
  • Your merges tend to be more and more manual. You frequently have to use WinMerge because Subversion hasn’t got a clue.
  • You are often waiting around for Tortoise to update/check for modifications/anything.

I have a subversion repository on my USB pen drive. I get tree conflicts and merge problems with that, and I’m the only user!

The main problem is merging. Our team has to work on branches as we have different projects running concurrently, working on the same code base. We don’t know which project will be going live first, or even if the project will be released at all (they may get canned). So, we need an efficient merging process.

Merging has become so problematic that we’ve considering adding merging as a separate task for each MMF we implement – that’s how long it takes nowadays. We’ve even considered putting a “Work In Process” limit on particular pieces of code to make sure two unrelated MMFs don’t touch the same code.

[Can you tell that I am not happy with Subversion?]

So, I decided to try something else.

I was going to try Git. I downloaded binaries, documentation and guides. But then I read this article: Renaming is the killer app of distributed version control. And I agree, renaming is really, really important. We rename files all the time. We refactor.

Git doesn’t handle renames as a “first class operation” – renames are just a delete operation followed by an add operation. This is the same as Subversion. I assume Git handles it much better than Subversion, but I wanted a SCM that has it built in.

So, I decided to start using Bazaar: renames are a first class operation in Bazaar, and it also has “Intelligent Merging” to cope with your Dev Studio file moves or renames.

For a full feature list of a number of SCM systems see this source control comparison page.

So far, I’m happy:

  • It runs natively in windows (I didn’t really want to run a unix-type shell to get Git working).
  • It is easy to work with from the command line (I thought I’d miss Dev Studio integration, e.g. VisualSVN and Ankh, but I don’t).
  • I even decided not to install TortoiseBZR – you don’t need it. [Tortoise is one of the reasons I wanted to move away from Subversion so I didn’t want to install the BZR equivalent.]
  • BZR comes with some GUI applets if you really need your GUIs. For example, there is a useful one for viewing change logs (command: “bzr qlog”)

To make the move, check out getting started with Bazaar source control.

Posted in Bazaar Source Control | Tagged: , , , , | 4 Comments »