Friday, October 7, 2011

Getting the grip on your version control

I have recently been working with several different open-source projects that are available on Google Code, Github, CodePlex etc. The projects tend to use different software for managing version control, which in turn requires multiple SCM clients to be installed on the development system.

Version control software commonly used in open-source projects today include Subversion, Git and Mercurial. By default, the version control software is accessed through command-line interfaces. However, there are several different GUI wrappers available to facilitate the version control management. On Windows, different flavors of Tortoise are predominantly used. These tools are primarily shell extensions, enabling version control management inside Windows Explorer. TortoiseCVS for CVS version control was first in line, and it has inspired or formed the basis to followers like TortoiseSVN, TortoiseGit and TortoiseHg.

The various Tortoise tools makes version control management much easier and more efficient, and there is normally no problem having several of these tools installed at once on the same computer.

There is one annoying issue though: all the above tools use the same icons and icon overlays in Windows Explorer. It is therefore not immediately possible in Windows Explorer to determine which version control software that is being used to manage a specific folder.


Of course, if you enter the folder the version control administration sub-folders (.svn, .git, .hg, etc.) will be listed if you have configured Windows Explorer to display hidden folders. But this is a sub-optimal behavior; ideally the version control software should be detectable through some indication in the Windows Explorer list, or when hovering the mouse over the folder in question.

In case someone had experienced the same annoyance as I and found a workaround for it, I posted a question on the subject at StackOverflow. I got a few answers primarily explaining why the same icon overlays are used, but then I also got an eye-opening answer from Stefan K√ľng, lead developer of TortoiseSVN. Stefan suggested me to customize the version controlled top folder using the approach described here. This was exactly what I had looked for: a method for customizing the folder layout and provide explanatory text in the tool-tip when hovering over the folder with the mouse pointer!

My only remaining concern now was that I would have to do this customization manually for each version controlled folder, which would be quite tedious and error-prone when a large number of projects are involved.

But then, what do developers do, if not implementing solutions to repetitive problems?

Thus, I took the bull by the horns and came up with a simple yet efficient console application for managing the folder customization. The application identifies the version control software used in the specified folder, adds a tool-tip and sets the folder icon to indicate which software that is being used to version control the folder. Currently, the application identifies Subversion, Git and Mercurial, but if the conditions are right (version control administration files in a sub-folder with a fix name) it is a straightforward task to extend this list of software. The application source code is available under an open-source license (Eclipse Public License version 1.0) and can be obtained from here.

After running the application on the version-controlled folders in the image above, Windows Explorer will (after a few refreshes) provide the following display:


Hovering with the mouse pointer over a version control decorated folder will clearly indicate the version control software being used:


It is even possible to run the folder decorator application without changing the folder icons. If the icons are not available in the same directory as the folder decorator application, the classic folder icon will be maintained but the tool-tip will still be updated.

The icons have been obtained from the Open Icon Library. The Subversion icon is "Sub-optimal"; I was not able to find a better redistributable Subversion icon. For personal, non-redistributable use, a more identifiable Subversion icon is available here. If you so wish, download this Subversion icon file instead, rename it to svn.ico and replace the existing Subversion icon in the Visual Studio project with the downloaded one.

Happy version-controlling!

No comments:

Post a Comment