Monday, October 18, 2010 9:47 PM
bcampbell
Migrating a Shelveset from One Branch to Another
There’s a very nice list of utilities the Visual Studio 2010 Power Tools brings to the table. It would definitely benefit any developer using VSTS 2010 to get the power tools installed and bring themselves up to speed on the capabilities available.
However, there’s one particular nugget that is very helpful when it comes to projects that have a branching strategy in place. And that’s migrating shelves from one code branch to another in your repository. For more on proper branching strategies, see the Visual Studio 2010 TFS Branching Guide on CodePlex.
Some of the power tools available are only available from the command line out of the box. This one falls into that category. So to start with, bring up a Visual Studio command prompt. The easiest way is to hit the Windows key and type “command” in the search box:
To see your available options and the nomenclature of the unshelve command, type in “tfpt unshelve /?”:
Pretty simple and straightforward. But here’s a snip for you to copy/paste into the command line, just replace the tokens accordingly:
tfpt unshelve “<your shelveset name>”;<TFS Username> /migrate /source:”<serverPath>” /target:”<serverPath>”
Of course, I included the double quotes because more often than not, shelveset names as well as server paths have spaces in the text.
Here’s a sample with tokens replaced:
tfpt unshelve “Latest - Pre v1.0 to v2.0 Branch Migration”;joedeveloper /migrate /source:”$/trunk/v1.0/Source” /target:”$/trunk/v2.0/Source”
It’s that simple. However, there’s one caveat: You may receive an error telling you, “Unable to Determine the Workspace”. The easiest way around this is to run the unshelve command directly from one of your local directories that’s mapped to your local drive. In my case, I typically just run it from the source directory that’s mapped to the source server path. So in the above example, I would navigate to the “C:\Projects\MySoftware\trunk\v1.0\Source\” directory from the VS command line before running the unshelve command.
From there, you’ll receive dialog prompts similar to those in Visual Studio asking you to perform a merge. Follow the instructions, and you should start seeing confirmations in your command window for every file merged:
If you have local changes in the target directory, you’ll need to resolve them manually. From there, your merge of your shelveset from the /source to the /target will be complete.