I recently read about shelving and thought it was a fantastically useful concept. So, the next time somebody came to me with a bug in my application, I shelved the extensive work I was doing to it, fixed the bug (made ~30/40 changes to classes and did some refactoring too) and checked in the fixed code.
I now want to unshelve the code I was working on, but preserve the changes I have made also. The problem is, I have made these extensive changes to the files on the server, these changes have not been made to the shelve.
What can I do here? It seems like it’s going to take hours/days to merge everything again. I know Eclipse has a wonderful feature where you can compare two files, and for each change decide whether you take the version on the server or the local version. Something like that where I could choose either the version in the shelve or the local version would be perfect.
Is there anything that could make my life easier here or am I doomed to look through the shelveset, at each file with conflicts, look at the server version, look at the local version, copy the parts of the local version into a notepad file, copy them into the server version…etc etc. It seems a horrible mess.
Can anyone help me out ?
You should not be required to choose only the server version or the local version. You should be able to instead resolve the conflicts using a 3-way merge tool like you’re used to.
It sounds like you’re following the recommended practice here:
If you were then to unshelve that existing shelveset, your changes will again be against version 2, meaning when your changes are pended against a version that’s not latest:
Understandably, this means you have a conflict. You’ll have the ability to resolve these conflicts when you do a Get Latest or a Checkin. These should be shown in a view in the bottom of Visual Studio:
As you note, there are the options to Take Server Version and Keep Local Version. But you should also be given the opportunity to AutoMerge (if the changes could be automerged, ie, you don’t have regions of the file that have changed in both the server and the local file) and Merge Changes In Merge Tool (which will open a 3-way merge tool.)
If you select Merge Changes In Merge Tool, you will be given the built-in 3-way merge tool:
If you don’t like the built-in 3-way merge tool (I don’t like the one included in 2010, VS 2012 includes a much nicer experience), you can plug in any 3-way merge tool in the Visual Studio Options:
If the option to Merge In Merge Tool is completely lacking, it’s possible that TFS thinks that you’re working on binary files. In TFS, when files are marked as binary (more accurately, when “File Merging” is set to “Disabled”) then you will not be given the option to automerge these files, or to merge them in the merge tool. This is an optimization to avoid downloading two extra copies of large binary files during conflicts, and to avoid trying to cram them into the merge engine.
You can configure the filetypes that are “not mergeable” by opening Team Explorer, right clicking on your Project Collection and selecting Team Project Collection Settings > Source Control File Types… Ensure that the type of files that you’re working with are listed as “mergeable” in this dialog: