Bazaar, Araxis Merge, Homesite and Windows

As promised, some more info on how I’m getting along using Bazaar as my VCS of choice under windows, using homesite for classic ASP development.

Let’s start with the basics, there are two possible ways of installing Bazaar under Windows; installing the version for Python, or installing a standalone .EXE with Python “built-in”. Not all plugins work with the standalone version, but I installed it anyway, because it’s an easier install. Also, it shouldn’t be too hard to uninstall the standalone version and install Python and Bazaar for Python later on, if the need arises.

After installing Bazaar, you should be able to start bazaar from any command prompt. So start a command line (for example by using Start…run… and typing ‘cmd’) and type ‘bzr [ENTER]’. You should get a general explanation of Bazaar’s most used functions. If not, try rebooting. Bazaar should have added itself to your PATH environment variable. This way bzr.exe is found no matter where you type it in a DOS prompt. Sometimes it takes a reboot for Windows to see a new addition to the environment variables.

If you verified that Bazaar can be started, it’s time to set up your workstation. Usually, when working with a version control system, you work on your local machine. In webdevelopment, this is a little trickier than in application development, but not a lot. The workstation version of Windows (XP pro, 2000 workstation) DOES have the irritating limitation within IIS of 10 concurrent users and only one active site at any time. For developing a website, this is usually not a problem. There are a few tools that can run in your tray and allow you to switch between sites easily. I use IISadmin.NET myself, but there are more. Using a tool like this makes developing on your local machine quite do-able.

If you have installed and configured Internet Information services (IIS) on your workstation, you can go to the wwwroot (c:\inetpub\wwwroot\ by default) and create a few folders for your different projects (that’s the way I work, YMMV). Set them up in the IIS console and fill the folders with your files. This is just plain old setting up IIS, I won’t go into that, there are enough sites explaining the procedure. Now, say for example I have a site called “pure”. I have the folder “pure” created under C:\inetpub\wwwroot\ and I have added my html/asp/js/css files to it. I activated the site in Windows IIS console (set the root folder to “C:\inetpub\wwwroot\pure\”), started the site and I checked to see if it worked by going to http://localhost/. Congratulations, you are now developing locally.

Anyway, back to the repository. Say I want to version-control this site with Bazaar. The first thing to do in Bazaar is to let bazaar know you want to version-control this directory. Start a command prompt, change directories to the folder you want to version-control, and initialise Bazaar:

cd C:\inetpub\wwwroot\pure
bzr init

Bazaar will have created a hidden folder called .bzr in the directory, and this is the only extra folder that it creates (As opposed to Subversion that creates a .svn folder in ALL your subdirectories aswell). This folder is actually your local repository. Now we’re ready to let bazaar know what files we want in this crispy new repository:

bzr add

You will see bazaar recurse through the subfolders of ‘pure’ and add all the files it finds. (You can exclude certain files if you wish, check the bazaar user manual to find out how). Okay, we’re still not done yet, bazaar knows what files to track, but these files have no ‘state’ yet. To give them an initial state, commit them to the repository by typing:

bzr commit -m "Initial import"

This will add the files in their current form into the repository. Always use the -m option to give your commit action a short description. This is version control 101; You have to know what you’ve done to any changed files, the comment after -m lets you describe what you’ve done.

Now, the advantage of working on a local webserver is that you have now already published the repository! If you have the .bzr file in the root of the ‘pure’ folder, it means that it can be reached from any other location that can reach your workstation via HTTP. You’ll have to decide for yourself what the security implications are in your situation, but for me this is a plus. I have a few workstations and a server, and this allows me to quickly pull a repository from my workstations.

Now, fire up homesite if you will and edit some of the files. Maybe even get some serious work done while you’re at it. After you’ve changed a couple of things and saved them, switch back to the command prompt and type:

bzr status

If all went wel, bazaar will tell you what has changed since your initial import. If you are happy with your work, tested it and you want to start on your next task or bug, you can commit these changes:

bzr commit -m "fixed a bug"

Bazaar will tell you what revision you’ve just commited and you can start with a clean slate (a new revision) for your next work (you can check this by running bzr status again, nothing will show up). Now to demonstrate what bazaar can do, you might want to check the difference between your current version and revision 1:

bzr diff -r1

You will see what has changed, in which files, by who and at what time. I have to admit though that this isn’t quite friendly to read. Not everything has to be command-line based though, and although Bazaar is, your DIFF/MERGE tool doesn’t have to be. I use Araxis Merge myself, and there is a plugin for bazaar that lets you use your own visual DIFF tool. For araxis merge do the following (after installing it ofcourse)

Install the Difftools GUI plugin (just copy the folder in the ‘plugins’ directory of bazaar: C:\Program Files\Bazaar\plugins\)

Add araxis merge to the PATH environment variable
Windows needs to be able to find the Araxis executable even if the command prompt is in an entirely different directory. Adding the folder to your PATH environment variable will do just that. To do this right-click on the computer icon on your desktop and choose ‘manage’. On the ‘advanced’ tab there’s a button ‘environment variables’. Click it and add “C:\Program Files\Araxis\Araxis Merge v6.5;” to the PATH variable under “system variables”. (Check the path, this is for MY version of Araxis Merge). Reboot or log out/in after changing the variable, or else Windows won’t pick it up.

setting the path environment variable

Configure araxis to ignore .bzr folders
Araxis needs to ignore the .bzr folder for it to work correctly. You can do this in Araxis itself under “view…options…filters”. Just add a type “exclude”, matches “folders” and pattern “.bzr”

araxis options

Now try it by using the following command:

bzr diff --using consolecompare.exe -r1

This should give you all the changes neatly summed up in araxis. To make things even easier, you can create an alias for comparing in araxis. You can create command aliases in the bazaar.conf file. You can find this file in windows under “C:\Documents and Settings\[YOUR USERNAME]\Application Data\bazaar\2.0”
Just edit the file with a text-editor and add the following lines:

[ALIASES]
vdiff=diff --using consolecompare.exe

Now try it by typing the following statement in the command prompt:

bzr vdiff -r1

Pretty easy he?
well that’s enough for one evening. I’ll post the rest of my experiences with bazaar under windows in a next post.

Advertisements

Tags: , , , ,

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s


%d bloggers like this: