Local workspaces in TFS11

The concept of Workspace is a key point in Team Foundation Server, it represents the mapping between a local version and server version of source control of a Team Project. The Workspace model of TFS was somewhat criticized in the past, because it is logically Server Side, because TFS Server, in each moment, knows the situation of each workspace.

This choice has, (as any choice in real life :) ) good and bad point. The good point is that Get Latest operation are really quick, because the server knows the situation of your workspace and can simply send you all files that were modified since the previous Get operation. The bad part is that, if you delete a file from windows explorer, when you issue a Get Latest it is not downloaded again, because the server really believe that the file is in your workspace (you can solve such inconsistencies with tfpt scorch command from power tools). Another annoying problem is that all files are read-only on disk, because before starting a file modification you should contact the server to do a Check-Out operation. This does not mean that the file is locked, just that you need to make the server knows the fact that you started modifying that file.

On the contrary, subversion uses a different type of mapping, based only on local version of files. A local folder mapped to a subversion repository contains a special folder called .svn, where subversion stores lots of information about the situation of the local mapping of the sources

image

Figure 1: Screenshot of a .svn folder of subversion repository

In previous subversion mapping structure (it was changed last year), you have a .svn folder for each subfolder of your local copies of the sources.

With such a structure if you delete a file and issue an Update, client component of subversion scans the directory, find the differencies from the server version, verify that a file is missing and restore it from the server version. All files are not readonly, because you can simply open notepad and edit a file. When it is time to Commit modification to server, the client component of subversions simply checks all files that are different from the latest update and consider them to be candidate to be updated on the server.

This approach is good until you start to have huge repository, not only because the .svn folder contains the copies of all the file, but because each update or commit operation actually scans all folders to understand what to do. I have a big project in subversion where the first update operation of the trunk needs about a couple of minutes on a computer with a  standard 7.200 RPM disk and about 2 seconds on my Vertex 3 SSD. This demonstrates how huge is the Disk Activity with such a mapping model of your source control.

Luckily enough, we have now really good SSD at very low price and disk activity is not a problem anymore, so be happy to know that in TFS11 a new version of workspace was introduced, called Local Workspace, and this is actually the default workspace model in TFS11.

image

Figure 2: Local workspace in action.

A local workspace is really similar to a subversion workspace, it has a $tf hidden folder that contains information on the local workspace.

image

Figure 3: The $tf folder in a local workspace

You can add a file outside Visual Studio, and during check-in operation you will find detected changes in Team Explorer

SNAGHTML5b6623

Figure 4: Detected changes during a check-in operation

This means that VS is able to recognize files that were added outside VS, simplifying a lot offline operations.

Gian Maria

Published by

Ricci Gian Maria

.Net programmer, User group and community enthusiast, programmer - aspiring architect - and guitar player :). Visual Studio ALM MVP

6 thoughts on “Local workspaces in TFS11”

  1. Thanks Gian, I read about local workspace before but I didn’t know how it works till you describe the hidden folder, I already also have good experience with subversion, so it’s very clear for me now ,really thanks, Keep up the good work!

  2. Thanks :).

    Actually the local workspace is the default because it is the most intuitive to work with. Many people criticize TFS source control because it is not so intuitive, files are read-only on disk, working offline is quite difficult, etc etc. In 2012, with SSD and fast connection I think that the reasons behind the “classic” workspace are gone, at least in standard projects.

    The only drawback is that local workspace is not compatible with Visual STudio 2010, but you can still work with VS11 on 2010 solutions without converting. :P

  3. Does this also detect a change to a file? I’m thinking of the example where a change (edit) to file occurs outside of TFS.

    Thanks

    Jeff

  4. Yes, it detects both new files and changes to files done outside Visual Studio. You can open a file with notepad, edit and save, then from team explorer you will see that files as modified and ready to be checked-in.

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.