Tarun Arora

Visual Studio ALM MVP
posts - 58, comments - 187, trackbacks - 0

My Links

News


Tarun Arora is a Microsoft Certified professional developer for Enterprise Applications. He has extensively travelled around the world gaining experience learning and working in culturally diverse teams. Tarun has over 5 years of experience developing 'Energy Trading & Risk Management' solutions for leading Trading & Banking Enterprises. His passion for technology has earned him the Microsoft Community Contributor and Microsoft MVP Award.




View Tarun Arora's profile on LinkedIn

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

Tag Cloud

Article Categories

Archives

Post Categories

Image Galleries

Unshelve shelveset created from one branch to another

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

Print | posted on Monday, June 06, 2011 9:34 PM | Filed Under [ TFS2010 ]

Feedback

Gravatar

# re: Unshelve shelveset created from one branch to another

Excellent post! My boss told me to use TFPT to move a shelveset to a different branch, and your instructions were perfect.
6/27/2011 6:04 PM | Brian D.
Gravatar

# re: Unshelve shelveset created from one branch to another

Great Brian! Glad this helped.

Cheers, Tarun
6/27/2011 6:46 PM | Tarun Arora
Gravatar

# re: Unshelve shelveset created from one branch to another

Thanks for posting this. Helped out in a pinch.

Jesse
10/6/2011 4:00 PM | Jesse Foster
Gravatar

# re: Unshelve shelveset created from one branch to another

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
10/6/2011 4:04 PM | Tarun Arora
Gravatar

# re: Unshelve shelveset created from one branch to another

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.
10/12/2011 8:36 PM | Ranjith
Gravatar

# re: Unshelve shelveset created from one branch to another

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
10/13/2011 9:29 AM | Tarun Arora
Gravatar

# re: Unshelve shelveset created from one branch to another

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.
11/1/2011 11:02 AM | Rdunzl
Gravatar

# re: Unshelve shelveset created from one branch to another

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
11/1/2011 11:05 AM | Tarun Arora
Gravatar

# re: Unshelve shelveset created from one branch to another

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?
12/13/2011 8:54 PM | Linh Tran
Gravatar

# re: Unshelve shelveset created from one branch to another

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.
12/13/2011 8:57 PM | Tarun Arora
Gravatar

# re: Unshelve shelveset created from one branch to another

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.
12/13/2011 9:01 PM | Linh Tran
Gravatar

# re: Unshelve shelveset created from one branch to another

I also, cd to the target workspace folder prior to running the command.
12/13/2011 9:01 PM | Linh Tran
Gravatar

# re: Unshelve shelveset created from one branch to another

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.
12/13/2011 9:25 PM | Tarun Arora
Gravatar

# re: Unshelve shelveset created from one branch to another

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?
12/13/2011 9:46 PM | Linh Tran
Gravatar

# re: Unshelve shelveset created from one branch to another

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>"
12/13/2011 9:49 PM | Tarun Arora
Gravatar

# re: Unshelve shelveset created from one branch to another

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?
12/13/2011 9:55 PM | Linh Tran
Gravatar

# re: Unshelve shelveset created from one branch to another

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.
12/13/2011 9:59 PM | Tarun Arora
Gravatar

# re: Unshelve shelveset created from one branch to another

Ok just figured i had it backwards:

tf dir <server target> ?/

gives me "unable to determine the source control server"
12/13/2011 10:01 PM | Linh Tran
Gravatar

# re: Unshelve shelveset created from one branch to another

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!
12/13/2011 10:06 PM | Tarun Arora
Gravatar

# re: Unshelve shelveset created from one branch to another

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"

12/13/2011 10:37 PM | Linh Tran
Gravatar

# re: Unshelve shelveset created from one branch to another

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?
12/13/2011 10:42 PM | Tarun Arora
Gravatar

# re: Unshelve shelveset created from one branch to another

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.
12/13/2011 11:42 PM | Linh Tran
Gravatar

# re: Unshelve shelveset created from one branch to another

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.
12/14/2011 12:03 AM | Linh Tran
Gravatar

# re: Unshelve shelveset created from one branch to another

I just figured this out. I took out the quotes from the sourcepath and the targetpath and it worked. Thanks for the help.
12/14/2011 4:02 PM | Linh Tran
Gravatar

# re: Unshelve shelveset created from one branch to another

Thanks for writing back! I am sure some one else would definately benefit from this. :-]
12/14/2011 4:04 PM | Tarun Arora
Gravatar

# re: Unshelve shelveset created from one branch to another

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.
5/3/2012 2:50 PM | J
Gravatar

# re: Unshelve shelveset created from one branch to another

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
5/24/2012 6:59 PM | Derek Johnson
Post A Comment
Title:
Name:
Email:
Website:
Comment:
Verification:
 
 

Powered by: