Geeks With Blogs

News




View Tarun Arora's profile on LinkedIn

profile for Tarun Arora at Stack Overflow, Q&A for professional and enthusiast programmers

Tarun Arora - Visual Studio ALM MVP ALM, Agile, Automation, Performance Testing, Software QA, Cloud, ...

Often i have seen fellow developer working on one branch and later realizing that they intended to check in the code in a different branch, a simple example, working on the MAIN branch and later realizing that the code needs to be checked in to the QA branch. TFS power tool comes to your rescue… when you need to unshelve to a different branch.

 

The power tool command /> tfpt.exe unshelve can be handy for the following,

  • Allows a shelveset to be unshelved into a workspace with pending changes.
  • Merges content between local and shelved changes.
  • Allows migration of shelved changes from one branch into another by rewriting server paths.
  • Allows changes from an already-unshelved shelveset to be undone, cleaning up pending adds, and preserving other existing pending changes in the workspace.

Download and install the latest TFS Power tools http://visualstudiogallery.msdn.microsoft.com/c255a1e4-04ba-4f68-8f4e-cd473d6b971f 

image

Below is a list of features that are installed with the March 2011 Power tool installation.

image

Once the installation is complete, go to the cmd and type />tfpt.exe

image

we are interested in />tfpt unshelve to achieve unshelving of a shelve set to a different branch

image

Syntax

/>tfpt unshelve [shelvesetname[;username]] [/nobackup]
                     [/migrate /source:serverpath /target:serverpath]

shelvesetname          The name of the shelveset to unshelve
/nobackup              Skip the creation of a backup shelveset
/migrate               Rewrite the server paths of the shelved items
                        (for example to unshelve into another branch)
/source:serverpath     Source location for path rewrite (supply with /migrate)
/target:serverpath     Target location for path rewrite (supply with /migrate)
/undo                  Undo pending changes from an unshelved shelveset
/batchsize:num         Set the batch size for server calls (default 500)

 

Sample

/> tfpt unshelve “MySampleShelveName” /migrate /source:”$/MyTeamProject/TheOrigionalBranch” /target:”TheDestinationBranch”

Catches

If you get the error => "unable to determine the workspace"

NOTE: Take the latest from your source control and “cd” to a local path that is mapped to the target workspace. Also ensure that the current working directory is mapped, you can run "tf workspace" and see if the target folders are mapped.

Have you tried this yet?

Digg This
Posted on Monday, June 6, 2011 9:34 PM TFS2010 | Back to top


Comments on this post: Unshelve shelveset created from one branch to another

# re: Unshelve shelveset created from one branch to another
Requesting Gravatar...
Excellent post! My boss told me to use TFPT to move a shelveset to a different branch, and your instructions were perfect.
Left by Brian D. on Jun 27, 2011 6:04 PM

# re: Unshelve shelveset created from one branch to another
Requesting Gravatar...
Great Brian! Glad this helped.

Cheers, Tarun
Left by Tarun Arora on Jun 27, 2011 6:46 PM

# re: Unshelve shelveset created from one branch to another
Requesting Gravatar...
Thanks for posting this. Helped out in a pinch.

Jesse
Left by Jesse Foster on Oct 06, 2011 4:00 PM

# re: Unshelve shelveset created from one branch to another
Requesting Gravatar...
Hi Jesse,

Thanks for your comment. Glad to know that it helped. Wouldn't it be great if microsoft made this accessible from the TFS UI itself!

Cheers, Tarun
Left by Tarun Arora on Oct 06, 2011 4:04 PM

# re: Unshelve shelveset created from one branch to another
Requesting Gravatar...
I tried this and somehow I am getting error "No whelvesets found matching....." , but I am providing the correct name. I tried providing username along with domain, but still does not work for me. Please let me know what to do. Thanks.
Left by Ranjith on Oct 12, 2011 8:36 PM

# re: Unshelve shelveset created from one branch to another
Requesting Gravatar...
Hi Ranjith,

Expect to get this error message if the shelveset name is incorrect. Can you verify that the shelveset name is correct and that you keep it in quotes if it has a space inbetween. You can also use the below command to verify that the shelve exists and that you can see the details.

tf shelvesets [/owner:ownername] [/format:(brief|detailed)]
[/collection:TeamProjectCollectionUrl]
[/login:username,[password]] shelvesetname

HTH
Cheers, Tarun
Left by Tarun Arora on Oct 13, 2011 9:29 AM

# re: Unshelve shelveset created from one branch to another
Requesting Gravatar...
Nice feature, although the migrate part does not work for me at all.

I provide arguments as explained above. I get no error messages. When I execute the command a GUI like the one in VS2010 pops up, and my shelveset ends up in the source branch. I have no pending changes at all in neither source and target branch.

A great feature but it would be even better if it worked.
Left by Rdunzl on Nov 01, 2011 11:02 AM

# re: Unshelve shelveset created from one branch to another
Requesting Gravatar...
Hi Rdunzl,

Thanks for your comment. Please throw me a bone, share more details. The feature works like a charm. If you can share more details about your scenario,
- Shelveset name
- Branch where you have changes
- Branch where you are moving the changes to
- Are they both in the same team project?
- The command you are executing and what path are you executing it from

I will be able to help. Thanks once again for writing in, hoping to help you resolve the issue.

Cheers, Tarun
Left by Tarun Arora on Nov 01, 2011 11:05 AM

# re: Unshelve shelveset created from one branch to another
Requesting Gravatar...
I'm getting the error "The server path component of /source:serverpath was not a valid server path." I followed the instruction as listed. Do you know why this is not working?
Left by Linh Tran on Dec 13, 2011 8:54 PM

# re: Unshelve shelveset created from one branch to another
Requesting Gravatar...
When specifying the serverpath, place the entire path name within quotes, for example:

tfpt unshelve shelvesetname /migrate /source:"$/Project/RootSourcePath" /target:"$/Project/RootTargetPath"

Also, ensure that you run this in the target workspace path else will not work.
Left by Tarun Arora on Dec 13, 2011 8:57 PM

# re: Unshelve shelveset created from one branch to another
Requesting Gravatar...
Thanks for the response Tarun. However, I do have quotes in my paths and also, I copied the path as they would appear from TFS (e.g. "$/folder/sourcefolder" and "$/folder/targetfolder). This i very odd.
Left by Linh Tran on Dec 13, 2011 9:01 PM

# re: Unshelve shelveset created from one branch to another
Requesting Gravatar...
I also, cd to the target workspace folder prior to running the command.
Left by Linh Tran on Dec 13, 2011 9:01 PM

# re: Unshelve shelveset created from one branch to another
Requesting Gravatar...
Hi Linh,

Sorry to hear that. Can we try everything from scratch, let's start with a very simple example, if this works we know the problem is not with the steps,
1. Open up visual studio command prompt and type tf.exe shelvesets /? can you see your shelveset in here?
2. tf dir /? both the source path and the target path to verify they are recognized by the server.

If both step 1 and 2 are success, tfpt command should work, even if the "CD" workspace path is incorrect but the shelveset name, source, target path and connectivity to tfs server is available you will get the pop up message.
Left by Tarun Arora on Dec 13, 2011 9:25 PM

# re: Unshelve shelveset created from one branch to another
Requesting Gravatar...
Hi Tarun,

When I ran the unshelve command, the pop message did come up w/ the shelveset details. However, when I clicked to "Unshelve", the command gave me the error "The server path component of /source:serverpath was not a valid server path."

Regarding the 2 instructions you gave me above, does it matter which directory I'm in?
Left by Linh Tran on Dec 13, 2011 9:46 PM

# re: Unshelve shelveset created from one branch to another
Requesting Gravatar...
Hi Linh,

The pop up showing up is a step in the right direction. Then it is absolutely worth trying point 2 to validate whether the target path is correct.

tf.exe can be run only from the path "C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC>"
Left by Tarun Arora on Dec 13, 2011 9:49 PM

# re: Unshelve shelveset created from one branch to another
Requesting Gravatar...
the command:
tf dir /? <target>

gives me this message:
------------------------
TF - Team Foundation Version Control Tool, Version ....
Copyright....

Displays all or part of the contents of a Team foundation version control server

tf dir itemspec ....

Versionspec:
....
...
..
---------------------
I don't see whether it says the path is recognized by the server. I get the same message if i put in the source path. Am i doing something wrong?
Left by Linh Tran on Dec 13, 2011 9:55 PM

# re: Unshelve shelveset created from one branch to another
Requesting Gravatar...
Surprising enough! This means the command is able to resolve the source and the target paths. I can't think of any other reason of failure migrating shelveset between branches.

It might be worth trying this on a separate branch or machine to ensure its not a permission issue.
Left by Tarun Arora on Dec 13, 2011 9:59 PM

# re: Unshelve shelveset created from one branch to another
Requesting Gravatar...
Ok just figured i had it backwards:

tf dir <server target> ?/

gives me "unable to determine the source control server"
Left by Linh Tran on Dec 13, 2011 10:01 PM

# re: Unshelve shelveset created from one branch to another
Requesting Gravatar...
The format in the command is flawed. The command should look like below,

C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC>tf.exe dir itemspec /folders /recursive /collection:"https://avanade.tfspreview.com/defaultcollection"

replace the /collection:"" with the URI of your team server.

If you can see the server path you are trying to map to in the unshleve command when u execute the above command, it should work!
Left by Tarun Arora on Dec 13, 2011 10:06 PM

# re: Unshelve shelveset created from one branch to another
Requesting Gravatar...
I am able to view the folders under defaultcollection. However if, I try to view the stuff in one of it's child folder, it gives me an error that it doesn't exist. Is there something wrong w/ my syntax?

e.g. "https://avanade.tfspreview.com/defaultcollection/childfolder"

Left by Linh Tran on Dec 13, 2011 10:37 PM

# re: Unshelve shelveset created from one branch to another
Requesting Gravatar...
Linh,

"https://avanade.tfspreview.com/defaultcollection" is the URI of the TFS Server. "https://avanade.tfspreview.com/defaultcollection/childfolder" will not map to the child directory instead make the tfs uri (Server connectivity address) in correct.

Another thing that crosses my mind, have you performed a get latest on the workspace and made sure that the server path maps to the workspace?
Left by Tarun Arora on Dec 13, 2011 10:42 PM

# re: Unshelve shelveset created from one branch to another
Requesting Gravatar...
I am able to get latest and the defaultcollection maps to a folder on my local computer. The folder i'm workin on is a child folder within defaultcollection.
Left by Linh Tran on Dec 13, 2011 11:42 PM

# re: Unshelve shelveset created from one branch to another
Requesting Gravatar...
Shelve name: test
Shelve owner: miket
Source Location: $/docs/sourcefiles
source local: C:\docs\sourcefiles
target Location: $/docs/targetfiles
target local: C:\docs\targetfiles

I cd to the target path which is C:\docs\targetfiles

I then run this: "C:\Program Files (x86)\Microsoft Team Foundation Server 2010 Power Tolls/tfpt" unshelve "test";miket /migrate /source:"$/docs/sourcefiles" /target:"targetfiles"

does this sound right? This didn't work and I tried changing the target to "$/docs/targetfiles" and that doesn't work either. I also tried "C:\docs\targetfiles" as the target and no avail.
Left by Linh Tran on Dec 14, 2011 12:03 AM

# re: Unshelve shelveset created from one branch to another
Requesting Gravatar...
I just figured this out. I took out the quotes from the sourcepath and the targetpath and it worked. Thanks for the help.
Left by Linh Tran on Dec 14, 2011 4:02 PM

# re: Unshelve shelveset created from one branch to another
Requesting Gravatar...
Thanks for writing back! I am sure some one else would definately benefit from this. :-]
Left by Tarun Arora on Dec 14, 2011 4:04 PM

# re: Unshelve shelveset created from one branch to another
Requesting Gravatar...
Tnx!

The problem I had was also "Invalid source path" and "Could not find shelve"

Solution for me:
1.ShelveName without quotes
2.-Open up both source and target in VS, to authenticate on both branches.(I even kept em open)
3.Try source and target without quotes 1 time, after that it worked WITH quotes also. (I had a blank in my name so I had to try it)

I think 2. was the critical thing.
Left by J on May 03, 2012 2:50 PM

# re: Unshelve shelveset created from one branch to another
Requesting Gravatar...
I had "unable to determine the workspace" error despite running from a directory that I verified was mapped. It turns out the problem was the the "tftp.exe" was actually running the TFS Power Tools 2008 version (which I never bothered to uninstall) instead of the TFS Power Tools 2010. Apparently the older version was in my path.

It would be nice if it gave some error about a version mismatch when trying to use TFTP on a path mapped using a new version of TFS, but it just says "unable to determine the workspace"

If anyone else runs into this problem make sure you are running the correct version of tftp.exe
Left by Derek Johnson on May 24, 2012 6:59 PM

# re: Unshelve shelveset created from one branch to another
Requesting Gravatar...
Thank you.
Left by .net developer on Jun 05, 2012 8:51 PM

# re: Unshelve shelveset created from one branch to another
Requesting Gravatar...
I was getting the error
No shelvesets found matching "ProvidedShelveSetName";MyUserName

Error was providing the ShelveSetName with the quotes (thx to above post for pointing it out)

Line should be:
tfpt unshelve MySampleShelveNameWithoutQuote /migrate /source:”$/MyTeamProject/TheOrigionalBranch” /target:”TheDestinationBranch”
Left by bob leponge on Aug 01, 2012 11:47 PM

# re: Unshelve shelveset created from one branch to another
Requesting Gravatar...
Actually, my above post is wrong : source and target needed to be without quotes as well to work

As In :

tfpt unshelve MySampleShelveNameWithoutQuote /migrate /source:$/MyTeamProject/TheOrigionalBranchNoQuote /target:TheDestinationBranchNoQuote

Otherwise, I was getting

The server path component of /source:serverpath was not a valid server path.

TFPT is version :
10.0.40301.0
Left by bob leponge on Aug 01, 2012 11:55 PM

# re: Unshelve shelveset created from one branch to another
Requesting Gravatar...
Thanks a lot, Tarun. The migration feature for shelvesets across branches worked like a charm. Your documentation is to be commended.
Left by BG on Aug 20, 2012 6:42 PM

# re: Unshelve shelveset created from one branch to another
Requesting Gravatar...
@BG - Thanks a lot for the feedback!
Left by Tarun Arora on Aug 21, 2012 8:31 AM

# re: Unshelve shelveset created from one branch to another
Requesting Gravatar...
Wow! I was dreading that I'll have to copy paste all my changes from one branch to the other. Thank God I stumbled upon this, and it worked perfectly! Thanks!!
Left by Shachi on Aug 23, 2012 8:13 AM

# re: Unshelve shelveset created from one branch to another
Requesting Gravatar...
@Shachi - Glad it works for you! It is one of those hidden gems :-)

Cheers, Tarun
Left by Tarun Arora on Aug 23, 2012 9:05 AM

# re: Unshelve shelveset created from one branch to another
Requesting Gravatar...
Thanks for that. Though I don't see this as a hidden gem. I think it should be standaard in TFS. It's just another pain when using TFS. Something you don't have with SVN, Git or Hg.
Left by Peter on Nov 14, 2012 8:27 AM

# re: Unshelve shelveset created from one branch to another
Requesting Gravatar...
This post was very helpful!
But i have a few doubts...
I have a shelveset that contains more than 1 change.(I edited around 4 files and made it as a shelveset)
then i executed the above command
tfpt unshelve “MySampleShelveName” /migrate /source:”$/MyTeamProject/TheOrigionalBranch” /target:”TheDestinationBranch”
It prompted me with a window. i gave the /noprompt option to the above command. it didn't unshelve my shelveset. instead it gave a message "The shelveset had a number of pending sets that was not exactly one." Is there anyway to unshelve multiple changes without being prompted?
Left by Varun on Nov 29, 2012 4:55 AM

# re: Unshelve shelveset created from one branch to another
Requesting Gravatar...
Thanks a ton man.. worked perfectly fine for me.. saved me a lot of effort and time..
Left by Ankur on Dec 12, 2012 12:59 PM

# re: Unshelve shelveset created from one branch to another
Requesting Gravatar...
Excellent post. was really very useful
Left by Ravi on Dec 28, 2012 5:00 AM

# re: Unshelve shelveset created from one branch to another
Requesting Gravatar...
I had a strange problem: the program appeared to make all the changes correctly, including the GUI parts, but then the changes never actually took place. It turns out I uses backslashes instead of slashes in the target and source paths, causing it to silently fail.
Left by Alan on Jan 14, 2013 6:11 PM

comments powered by Disqus

Copyright © Tarun Arora [Microsoft MVP] | Powered by: GeeksWithBlogs.net | Join free