Thursday, November 05, 2009

Visual Studio Team System and Cloak

When I first started using Visual Studio with TFS for a new position, I started reading the Team Development with Visual Studio Team Foundation Server guide since I had never used it before. I got about half-way though it before I started the new job and became so busy I no longer had time to finish reading it. Had I kept reading, I would have found a piece that talked about the “cloak” menu item when viewing your Source in the Source Control Explorer.

Say you have a root-level folder in Source Control with the following structure…

  • ProjectA
    • MainLine
  • Branches
    • v1.0
    • v1.0-SP1
    • v2.0

Rather than create a separate workspace mapping for each version, you would create a single workspace at the top level. This makes it easy to keep everything in sync by just performing a Get Latest operation on the ProjectA node and you will instantly have the latest for everything.

There are a couple of problems with the approach. First, what if you are currently only working on the MainLine version? Do you really want the previous 3 versions stored on your disk? If the project is small this might not add up to much, but if it’s a major project this can easily consume tens of gigabytes of space.

The second problem comes into play when performing a Get Latest operation. With everything mapped from the root-level node, TFS needs to contact the server and compare your workspace with the server in order to determine what has changed and what needs to be updated. If you are currently working only on the MainLine branch, do you want or care about the changes in another branch? (Veteran coders will know that you can perform a Get Latest on specific folders, but this sometimes leads to performing a Get Latest too low in the tree and missing required dependency updates from higher up).

The solution is to create a root-level workspace mapping as stated above. When you are prompted to perform a Get Latest, say no. In the Source Control Explorer window, right-click on any folder you don’t want included and select the Cloak menu item. This prevents the folder from being included in your workspace mapping and prevents it from being downloaded and subsequently updated every time you perform a Get Latest.

In our example, someone only working on the MainLine branch would cloak the Branches folder. If someone needs to be working on the MainLine as well as a previous version (like a Service Pack), they could cloak the individual branch folders they don’t care about.

Nice!

No comments: