views:

338

answers:

3

Currently I am working on a project that uses TFS as source control. I am in the middle of implementing a piece of functionality, but am blocked by work that needs to be done by outside resources. Since the functionality is not fully complete, I can't check in the changes without breaking the build. So instead of waiting a couple days while the blocking work is finished, I want to work on some defects.

To do this work in isolation from my other changes, I am working the defects in a second workspace I just created.

After using a second workspace to isolate my changes, a coworker asked me why I didn't just shelve my changes. After doing some reading on shelving, it looks like this is preferred solution to situations like mine. My question is what situations, if any, would you create multiple workspaces and what situations should you use shelving? There are some posts about shelving, but I don't see very much on the subject of workspaces.

By the way, I got the idea for creating a second workspace here.

+1  A: 

Shelving is the ideal option. Shelving allows you to make changes en masse in TFS outside the regular build, and retrieve them later by name. Multiple workspaces is not a solution for what you're doing. Multiple workspaces are good if you're maintaining different versions of a product and need to work on them, e.g. let's say you have a 4.0 and a 5.0 product and need to apply a security fix to both versions. Shelving is great when you want to make changes but not commit them immediately.

Nissan Fan
Isn't branching used for working on multiple versions? Or would an individual have a separate workspace for each branch?
JChristian
Yes, but you would use different workspaces to get to each branch.
Nissan Fan
+1  A: 

You are talking about two completely different concepts here. When you shelve code, you are saving it to TFS, but not checking it in to any particular branch. Creating a different workspace just sets up a new local folder on your development machines and saves the files in your branch there. When you do a check-in, you still could have conflicts.

Why not create a new branch of your code. You can work on that branch and check in without stepping on anyone else's changes, because you are checking in to your own branch of the code. Then, when you have completed your changes, and others have completed their's on the main branch, you can merge your changes into the main branch.

Randy Minder
I hadn't thought of creating another branch. Are you suggesting that I should have created a second branch for the blocked functionality I was working on and then use the main branch to work on defects?
JChristian
@JChristian - I'm not saying you should have. But an alternative would have been to create a branch either for you to work on, or for the outside resources to work on, and then merged them together when done. I've often done this when either working on the next release of an app, of if the changes I'm going to make on the current release are significant, and I wanted to work on them in isolation.
Randy Minder
+3  A: 

A new branch would probably be the best way to go. But, to answer your question, one of the key differences between shelving and just using a differnet workspace is that when you shelve, you push your code back to TFS, so it is backed up. Whatever is in your workspace is just what you have on your machine -- if you lose it, it's gone.

We use branching a lot in my shop, and as a result, I haven't seen many uses for shelving.

However, I have found one case where it has been very useful to me: I often bounce between 2 different development machines (one at the office, one at home, connected via VPN). If I am working on something, and I want to transfer it from home to work, or vice-versa, I often use shelving. I can shelve it from one machine and un-shelve it from the other. I do this when I am in the middle of a change, and checking in would break the build or otherwise interrupt other developers.

JMarsch
Ah, so I should at least shelve my changes on my original workspace to backup the changes. Also, good point about using shelving to move changes between PCs. I could see that being very useful.
JChristian