Tag Archives: TFS

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.

Change is always inevitable and Changeset makes sense.

Let me start with a question for which I created a small poll. Please select an option to vote and then read further.

If you have not voted for option “You edit single file to resolve the issue/bug.” then you might be facing the pinch for a logical grouping of changes done to fix a bug. Team Foundation Server takes it to the level of logical grouping of changes.

Any piece of functionality we build for a software requires multiple files, until and unless you throw away all the design principles and write code in a single source file. Each and every activity in software development is a change, whether you add some files, delete some or edit some. Everything said above in TFS system needs to be checked-in, so when you see the check-in window it is visible as a pending change, ready to be committed to the source server (Pending Add, Pending Delete, Pending Edit).

Changeset is a logical grouping of the changes you do in source control, it is essentially a collection, what needs to be in the collection is ultimately controlled by the developer. So it is the responsibility of the developer to select the pending changes which would be eventually committed to the source control server.

image

Notice the Change types “edit”,and “add” in the screenshot above. These changes can now be checked-in as a set which we typically refer to as a “Changeset”. When I said that what contains inside a change set is controlled by developer earlier in this post, I meant that you can select which objects you want to check-in controlled by the checkbox besides every element in the above dialog.

Changeset is a linkable entity, meaning you can associate them as links with work items in TFS. Why is this important? The answer is simple, you never do any change in a software without a purpose when you consider the complete ALM picture. Each work item type, defines a purpose in the software development methodology. This helps us in understanding the purpose of source code changes, as to why we did a particular change, what was the intent behind and some more artefacts (like effort spent, developer comments, to which product functional area it corresponds to, to which release etc., will we dive into these details later in some future posts when we do a deep dive with work items).