Tag Archives: Shelve

Shelving and Unshelving– A source control option with some practical usage.

In TFS version control sub-system, there is a feature for Shelving and Unshelving your pending changes. This is quite a useful operation in source control with a variety of applications. In this blog I will show some scenarios where this operation can be helpful.

Picture yourself in your day-to-day work. And your Boss comes to you when you are really in “The Zone” (I use this term referring to a time-frame when my productivity for the day is the highest, when I am able to code what I think, and more importantly when I don’t like to be disturbed while coding). So  you Boss is at your desk and you have the following conversations:

Scenario :

Boss: “Hey I have got this new feature which I want you to start off immediately.”

You: “Yes, but I am in middle of the feature you already said is most important.” Surprised smile

Boss: “Yes, that’s true, but this new one is more important than the one you are doing.” Sarcastic smile

You: (Thinking I don't know smile) 1

Boss: “Please stop everything, and do what I say.”

You:(Thinking I don't know smile )  2

Boss: “If possible take help of other senior developers too, and try to do it by the end of the day.”

You: (Thinking I don't know smile) 3

You are Thinking Part 1: While you are thinking, your boss has already overruled your current work. He has prioritized your existing work, he also didn’t tell what to do of the work done so far (you are at this point when you are thinking for the first time). You are trying to understand the new work in front of you and trying to find a possible solution.

You are Thinking Part 2: When your Boss says “stop everything”, you are at point 2 thinking what will happen to work done so far. I don’t remember whatever I changed (considering I don’t use any version control). I need to revert back to a state where everything was working fine, and then code the new requirement (More Important than the Most Important).

You are Thinking Part 3: When your Boss says “take help from senior developers”, you are really in mayhem. How would you do that? The senior developer might not have anything related to the new development. How will he do my code review? How will I.. And you are in a endless thought process.

This is what happens when your Boss leaves,

You: @#$@#$#%@#%@#$%@#$%@#$%@#$%@#$%@#$%

Ok, there is a way out if you are using version control in TFS. TFS provides what is called as Shelving (put whatever you changed in a cold box), and Unshelving (take out stuff form cold box and continue). It is just like you hibernate your OS, it remembers all the state you were in and then when you reconnect back all the programs are open.

For more information on shelving, and unshelving read the following link:

http://msdn.microsoft.com/en-us/library/ms181404(v=vs.80).aspx

Now when you are empowered with this new information, let’s see how your conversation would be:

Updated Scenario :

Boss: “Hey I have got this new feature which I want you to start off immediately.”

You: “Yes, but I am in middle of the feature you already said is most important.” Surprised smile

Boss: “Yes, that’s true, but this new one is more important than the one you are doing.” Sarcastic smile

You: (Thinking I don't know smile) 1 (You have the liberty to think without worrying about How would I questions !!!)

Boss: “Please stop everything, and do what I say.”

You:(Thinking Winking smile ) 2 (You can shelve your changes and get the version which was running just fine before you started to implement this feature.)

Boss: “If possible take help of other senior developers too, and try to do it by the end of the day.”

You: (Thinking Winking smile) 3 (You can shelve the changes for review with your senior developers, who can unshelve and do a code review for you.)

Note: The TFS build system also allows to execute a shelveset merged with the sources present on the server. By doing so you can verify the integrity of the shelveset with respect to your stable version of the source code.

Conclusion: Shelving and Unshelving are really powerful features of the TFS version control system. They save a lot of time from code backup nightmares, working on prototypes, sharing your source code for code-reviews, suspending and resuming code activities. Fortunately, the version control plug-in from To-Increase for Microsoft Dynamics NAV enables the developers to perform Shelving and Unshelving, contact To-Increase for a demo and unleash the power of version control for Microsoft Dynamics NAV.