views:

1418

answers:

2

I have the following scenario:

A user shelves some changes. Time goes by and a new branch of the product is created. Later, it is determined that the shelveset contains code, that we will need in the new branch.

By default; Visual Studio can only restore the shelveset changes to the location where they were shelved from. Is it possible to restore my shelveset in the new branch ? I do not want the code to be checked into the original branch, as it would break stuff.

+1  A: 

It appears it cannot. Shelves are very limited.

Worse. When you have newer versions of files in your working copy than the ones shelve is based on, unshelve reverts to the older version instead of doing merge. And it's dumb as it reverts only files changed in shelve, not all branch. You need to remember to Get latest version before doing any work with unshelved code.

I think you'll have to move your changes manually. You can help yourself using some diff/patch tools.


At first I thought shelves were a neat feature. Now I think they are almost useless. Better and cheaper support for branching would eliminate any need for them.

I only use them to backup my current working copy when:

  1. I go home for the day (and I've yet never needed to unshelve them the next day)
  2. When I discover some minor bug while working on something bigger and want to have a clean checkin fixing it before commiting rest of my changes (so I shelve my work just for a few minutes).

In all other situation I use real development branches. You can use TFS's merge and baseless merge features with them. Still slow and pain in the a** but much better then manual moving changes with WinMerge, kdiff or whatever you use. They keep real history and let others really cooperate with you. And you can (with some effort) keep them in sync with mainstream development.

Tomek Szpakowicz
-1 because this answer is a lot of anger about something that can be done.
antik
Thank you for expressing your opinion. If my answer sounds angry it's because I have to work with TFS and it simply isn't my favorite tool.Now I see it can be done with some power tool.1) I couldn't find this option when I needed it and 2) I don't think it invalidates my comment about shelve's usefulness as a feature. You don't need shelves in git or mercurial, do you?
Tomek Szpakowicz
I agree about shelve sets. They seem great at first, until you actually have to use them.It is nice to have command line tools to make it more useful, but for the price of TFS I would expect it to be integrated into VS.
Jason
In order to be able to work with shelves at all, I always name my shelves after which revision I am at when creating the shelveset. Then, before getting an old shelveset, I 'Get specific version' on the source tree.
Robert Jeppesen
@Robert: Good tip. Thanks.
Tomek Szpakowicz
+7  A: 

It is possible with the TFS Power Tools.

See: http://stackoverflow.com/questions/117337/can-i-unshelve-to-a-different-branch-in-tfs-2008

Note the "migrate" option.

iammichael