Archive for the ‘Source Control’ Category

h1

Branching in source control musings

October 5, 2007

Every week I’ll be looking to share a particular topic that I’ve been thinking about usually based on a post from an interesting blog or article.

This week, the post that got me thinking the most was one on the coding horror blog entitled Software Branching and Parallel Universes.

In the current environment I’m working in there is no branching involved – all code is developed in the same common code and exclusive checkouts are used to ensure that no cross-over or interference occurs. This limits the opportunity for parallel development, but to be honest that isn’t really a factor with so many products for us to maintain at any one time – that is probably the defining factor in the lack of branching use.

That’s not to say it hasn’t been discussed and that initial discussions haven’t taken place on it. Unfortunately most of these discussions haven’t evolved into anything concrete, but perhaps the Coding Horror post will spark something into life for us.

Branch per Task
Every development task is a new, independent branch. Tasks are merged into the permanent main branch as they are completed.

This is probably the most appropriate to my current environment – we have internal web site projects (many of them!) that don’t really version… they get enhanced as new functionality is plugged in or change requests are developed and implemented.

A task orientated approach may prove very useful but it brings back questions that we have faltered on before (and effectively given up on).
Say we have a website – websiteA – and this has 5 common core class library projects that it shares with up to 10 other sites. A change request may result in a branch being created for websiteA-Change1045 (as an example) and this can be worked on in isolation.
However, invariably some changes require the common code to be improved upon in some way and here we will also have to branch each and every component library we wish to modify. Without a clear branching strategy we can see that this could get ugly.. especially as simply typing inside a file in VS2005 automatically checks out the file behind the scenes with no confirmation request.. this would be very easy to do on the existing “release/original” code for those libraries in source control.

I guess it is all about thinking ahead with that clear branching strategy and also what advantages this gives to the build features of Team Foundation Server that we currently use.
At present we cannot build to a UAT environment automatically due to the nature of the check-ins happening on the common code (they often occur post-development but pre-full integration testing).

On a lighter note, the post also suggests thinking about branching in terms of parallel universes:

Perhaps the most accessible way to think of branches is as parallel universes. They’re places where, for whatever reason, history didn’t go quite the same way as it did in your universe. From that point forward, that universe can be slightly different– or it can be radically and utterly transformed.

One of the recent definitive parallel universes is the Star Wars Infinities series from Dark Horse Comics.
It is silliness in a world that is revered by many and is a recommended read if not solely for it’s boldness in taking on the canon pedants.

h1

Undo a check out in Team Foundation Server source control

October 3, 2007

Almost every team that uses source control will inevitably find themeselves in a situation where a file is checked out and locked and needs to become available for someone to work on it. Often the person who has the file checked out is currently on holiday or has left the company or, as with our recent situation, the original machine used for the check out no longer exists.

In Team Foundation Server source control, the workspace is a local copy of the files on the server and this copy is isolated from any other changes that may occur on the files. You can in fact have multiple workspaces across different machines – something that happens frequently for contractors who hot-desk.
If one of these machines is rebuilt or simply dies, the original workspace relationship on the check out in source control remains and the file can never be checked in.

So how do you undo a check out?
First, you must have administation priviliges; secondly, if you are not in a domain-controlled environment (as is our situation) you have to be on the team foundation server itself.

Using the Visual Studio 2005 Command Prompt, you can make use of the TF command-line utility to issue a command to undo or unlock the check out.

In our experience, the Undo Command was the operation best served to reverse the check out and lock actions as this “removes pending changes from a workspace”:

TF UNDO $filepath$ /Workspace:$workspace$;$user$ /s:$server$

e.g. TF UNDO $/MyProject/Folder1/File1.cs
        /Workspace:MX4545;john.smith /s:http://myteamserver:8080

Note that you must specify the workspace and user that you wish to reverse actions for – if you are unsure of the current workspace that the file is checked out under, simply go into your source control and attempt to check the file out.
You will receive a warning informing you of the user and workspace the file is checked out to.

Note that when you run this command successfully what appears to be a yellow error comes up in the command window:
“The workspace MX4545;john.smith is not on this computer. Run get (get all if edits were undone) on the computer hosting that workspace to update it with the changes that have been made on the server.”
This is infact showing you that it was successful but the files for that workspace/user require a get latest to become up to date with your undo changes you have made.

An alternative method to unlock the file is the Lock Command:

TF LOCK $filepath$ /lock:none /Workspace:$workspace$;$user$ /s:$server$

… but we found this problematic due to the following note in the msdn documentation:

Having the Unlock other user’s changes permission set to Allow is required to remove a lock held by another user if you do not have Write permission for that user’s workspace.

One other handy command related to this is the Status Command with which you can obtain a list of all files checked out to a particular user – particlarly useful when a user no longer exists and you need to undo all files checked out by that individual.

Follow

Get every new post delivered to your Inbox.