33

Since they have supposedly integrated most of the Power Tools functionality into VS2017, the new command "tf unshelve" does not work the same as the old command "tfpt unshelve" to move shelvesets to another branch, as you cannot add a source and a target using the new command. I really don't want to have to install VS2015 on my laptop just to move a shelveset. Does anyone know how to do this with VS2017? I'm having a hard time believing this is no longer possible.

Any assistance is greatly appreciated!

riQQ
  • 9,878
  • 7
  • 49
  • 66
Rani Radcliff
  • 4,856
  • 5
  • 33
  • 60
  • 1
    Related question: https://stackoverflow.com/questions/43747848/tfpt-exe-on-visual-studio-2017 – Neil Aug 02 '18 at 16:16

9 Answers9

36

I absolutely agree this is a greatly missed feature in 2017 and up. After too many times of doing this manually, I decided to add it to my (free) Visual Studio Extension called 'MultiMerge'. You can now right-click a shelveset and choose your target branch. There's a VS2017 version and VS2019. Or you can simply choose this extension using Tools and Extentions menu in Visual Studio.

Feel free to rate the extension, and let others find it more quickly:)

Dutchman
  • 800
  • 8
  • 11
  • 1
    I tried this and get: "There is no working folder mapping for $/branch/shelveset/is/in/and/first/shevled/file/path" I have multiple active workspaces for this branch. Using "Unshelve to branch" from VS2017 with the source workspace project loaded. – tukra Sep 19 '19 at 18:11
  • 2
    Sorry Mate, sounds like you got a complex shelveset. The plugin will try to figure out which workspace to use, and uses the first workspace that matches the first file in your shelveset. It does not check if all files in you entire shelveset are mapped. If you can pass on what code I should be using, with the ONLY starting point a List of PendingsChange(in namespace Microsoft.VersionControl.TeamFoundation.Client) I'm all ears. The only workaround I can offer is: limit your WorkSpaces. I always (15+ years) use a single one, which maps everything (huge sourcebase) and that works like a charm. – Dutchman Sep 20 '19 at 22:36
  • 1
    looks like renames get translated into just adds... – jmoreno Jul 24 '21 at 19:54
  • 1
    @Dutchman just another upvote and thanks for this - using your extension in VS2019 just worked great for me to unshelve to a different branch. – G_P Aug 19 '21 at 21:00
  • @Dutchman I'd really appreciate a release for VS 22. – scor4er Aug 21 '21 at 20:26
  • 2
    @scor4er There is a 2022 version but I haven't used it: https://marketplace.visualstudio.com/items?itemName=Jesusfan.MultiMerge2022 – eyelesscactus54 Jul 15 '22 at 18:05
  • @eyelesscactus54 Have just tried the VS2022 version, it works great! – MichaelEr Oct 02 '22 at 19:27
  • Works like a charm on VS2022! Many thanks! – greijner Jun 09 '23 at 07:22
10

Another WORKAROUND...

  1. Check in the changes from existing shelveset (Changeset 1)
  2. Merge the changes to the other branch and check in (Changeset 2)
  3. Rollback the changes from Changeset 1.

This keeps changes from changeset 2 and rolls back the original branch.

This process may not work for every company and their policies but it does work. I don't like it but sometimes it is necessary.

Nathan
  • 789
  • 11
  • 20
  • 2
    I upvoted this. I don't like it, but after spending hours on other things this really is the only thing that works and saves time. I would say that depending on the speed of your team, you may want to check in your change (changeset a), and roll it back immediately (changeset b) creating back to back change sets in the old branch. Then just merge changeset a into your new branch and work with it. You now have time to debug it locally, test build and stuff without having to get it right quickly before anyone tries to use changeset a on the old branch incorrectly. – Jroonk Dec 15 '18 at 04:01
  • So easy. Thank you. – Francesco B. Jul 31 '19 at 08:09
  • Easiest and clean way if team allows. – Mujtaba Haroon Mar 09 '22 at 23:14
6

Unfortunately move Shelveset to Another Branch with the command "tftp unshelve" or "tf unshelve" is still not supported for now in VS 2017.

There's already a feedback submitted here to track that, just as Youhana Naseim [MSFT] mentioned below (source here) :

For VS 2017 we do not have a power tools release. We are constantly evaluating the features that are still missing in the product. The three most notable ones are:

  • TFS Windows Shell Extensions integration

  • Find by Status for server workspaces

  • Unshelve /migrate

So as a workaround, you can try below ways:

Andy Li-MSFT
  • 28,712
  • 2
  • 33
  • 55
  • @Rani Radcliff Have you resolved the issue? any update? – Andy Li-MSFT Mar 28 '18 at 02:03
  • I have the same problem, but can't understand how `tf rename` can help. Can you provide a more detailed sample? – Jalal May 21 '18 at 15:04
  • 1
    Hello, I just want to mention that installing the 2015 Power Tools is NOT a solution - it will not install the tftp Exe if the Visual Studio 2015 is not on the machine! (I think) – ohnezahn Jul 27 '18 at 14:51
  • There now is a request that can be voted for on the new developer community site https://developercommunity.visualstudio.com/content/problem/342203/shelveset-migration-to-different-branches.html – JonoB Oct 22 '18 at 14:56
  • @JonoB - or you can upvote the issue thats already open on DevComm. (This answer's first hyperlink) – StingyJack May 06 '19 at 15:35
  • @ohnezahn if you find a machine with VS2015 on it and copy of the folder the extension installs - it will have a tf.exe in it, if you then do TF workspaces /s: that seems to make TFPT able to identify your workspaces and the shelvet merging starts working. However I'm finding that in any hard merges, it no longer will launch the configured diff tool – Peter Nimmo Mar 31 '23 at 14:21
5

Another probably easier way working with VS2019 is to copy/paste your source folder to the branch target folder and use

tf reconcile /promote

to detect all added or changed files.

Kelon
  • 821
  • 10
  • 10
2

Here's how I do it when I know the branch files can be overwritten directly by the shelf-set. If you need to merge, then use win-merge with directory compare to stitch things back together.

  • Close all instances of Visual Studio
  • Rename your local source directory to a temporary name
  • Open Visual Studio
  • Unshelve your changes normally - VS will recreate the directory structure with just your changes in it.
  • Copy all your changed files into your branch directory (overwrite read-only files)
  • Close visual studio
  • Rename your local source directory back to its original name (get rid of the one VS recreated)
  • Reopen your branch project
  • Two options now: you can go offline then back online again to let VS figure out what changed, or just check out your whole folder and then check in again. Just make sure you don't have anything else checked out before you do it!

It's a shame that this hasn't been put into VS as a native feature yet, but when you consider the complexity of un-shelving into a code merge, and preserving history, etc, the task becomes complex. Good luck!

Nick Pirocanac
  • 111
  • 1
  • 4
  • This did not work for me (VS2019), when I tried tried to unshelve my changes I received an error stating "No appropriate mapping exists for $/...." – Shaun May 17 '21 at 13:19
2

Multimerge extension (MultiMerge.2017, MultiMerge.2019) worked like a charm for me. (Or rather to the extent that TFVC tools as such cannot merge by reapplying a patch.)

No tfpt for VS 2017 and VS 2019. The unshelve /migrate command has not been incorporated into tf neither. So nothing that works out of the box as yet. (Last checked on v16.7.5)

Tomek Szpakowicz
  • 14,063
  • 3
  • 33
  • 55
  • Irony: Years ago I answered the same question for TFS 2005: no way out of the box. Then they added `tfpt unshelve /migrate` command and the answer was so heavily downvoted that I removed it. Now I am back to TFS after several years and I am looking at the same problem in the latest version. Good job! (I guess I need to relearn [git-tfs](https://github.com/git-tfs/git-tfs) just to stay sane.) – Tomek Szpakowicz Jan 08 '21 at 13:35
0

Until now (Feb 2020) TSPT is not available in Visual Studio.

The workaround i found is to create a new Branch and use a tool like WinMerge (http://winmerge.org) to compare and merge changes from Main to the new Branch then when it's all right undo the changes on the main branch.

0

Chiming in late on this one, but I got around it by getting the changeset I needed in branch A. Renamed folder to branch B. Now my new branch has the changeset I need. Then just force Get Latest under advanced to re-get the original branch A back as it was. My Branch B was brand new, so I didn't need anything else from it, not sure if that's the same situation for you, but was a quick enough fix.

Jeff
  • 387
  • 1
  • 3
  • 11
0

You can still use/install the last (VS2015) version of tfpt without installing Visual Studio 2015.

Download Microsoft Download for Team Foundation Power Tools 2015

RUn installer and select custom and unselect visual studio integration then complete installation (next next etc).

After installation then you can temporarily add tfpt to powershell path for that powershell session:

[System.Environment]::SetEnvironmentVariable('PATH',$Env:PATH+';C:\Program Files (x86)\Microsoft Team Foundation Server 2015 Power Tools\')

You can then run tfpt from the workspace directory.

I had to also update my workspaces from the server for the workspace to be recognised from the working folder (see tfpt unable to determine workspace):

tf workspaces /s:https://my.source.server.or.account.visualstudio.com

I could then run the unshelve command

cd c:\my\workspace\folder
tfpt unshelve "ShevesetName;UserName" /migrate /source:"$/Project/Source" /target:"$/Project/Target"
hallz
  • 236
  • 4
  • 6