TFS Unmerged Changes - tfs

I use a simple branching strategy where I have a trunk. i branch from that trunk into multiple development branches. Once dev is done I merge the dev branch back into main.
I'm looking for a way to produce an automated report that would tell me which branches have changes that have not yet been merged back into the trunk.
I'm sure there is a way to do this with either tf.exe or the tfs database.

I found Derek's answer to be correct, but there was a small syntax problem in the call to tf.exe.
The correct syntax is:
tf.exe merge /recursive /candidate "$/Source/Branch/Location" "$/Target/Branch/Location"
This should be run from within a mapped TFS workspace folder, or you may get the error: "Unable to determine the workspace."
You can alternatively use the "workspaces" action on tf.exe before the merge call to specify a collection to target if the machine you're running from has no mapped workspaces.

You could use the API... but it would be easiest to just use tf.exe. I used to have a Powershell script that I executed once each development cycle to catch unmerged changes.
Use with vc or git (below example for vc):
tf.exe vc merge /recursive /candidate "$/source/BRANCH" "$/target/BRANCH"
You can get the skinny on all of the tf.exe merge options here:
http://msdn.microsoft.com/en-us/library/bd6dxhfy(v=vs.100).aspx

Related

TFS merge uncontrolled files and folders into TFS

I'm taking code from a 3rd party, and modifying it. The 3rd party puts out occasional releases, as a zip file, I want to keep my branch, stored in Team Foundation System, up to date with theirs. But I don't see any point of keeping their main trunk in my source control, just so I can merge it into my branch. Is there any way I can just do some kind of baseless merge from their files I download into my TFS branch?
I tried this:
tf merge /baseless "C:\localpath\to\third-party-release-2.0" "C:\localpath\to\mybranch"
and this:
tf merge /baseless "C:\localpath\to\third-party-release-2.0" "$/serverpath/to/mybranch"
and both tell me
No appropriate mapping exists for
C:\localpath\to\third-party-release-2.0.
The merge command applies changes from one branch into another.
According to your command, you are trying to merge something from local to your server branch. This is not supported in TFS. You may need to check in your C:\localpath\to\third-party-release-2.0 into TFS source control first. More info about tf merge command from MSDN.

Teamfoundationserver branching not working in any form

I have tried branching in a very simple sample project and it worked. Now I want to branch a real life project and it is simply not working.
When I try to branch the whole team project, tfs tells ask for a destination. If I choose a new destination it tells me, that the destination does not exist. If I create a new one and point to it, it tells me that the folder already exists.
When I try to branch the team project into a sub-folder within the team project it tells me that this procedure cant be done, fair enough.
But when I try to branch a single project within the team project to another sub-folder it tells me that there was no correct mapping ('keine passende Zuordnung', in German I don't know the exact English error message).
Any help on this is very appreciated. I fail to see, what I do differently here, then I did before in my test project.
Edit: As suggested I post an image of my project structure. The upper folder is my actuall project which I have converted from a teamproject to a branch. The second on is the destination folder which is empty.
When branching a whole team project ($/ProjectName), you either need to use the New Project Wizard to create a new project and specify that it should branch from your current project.
When branching a sub-folder of your team project, that should work, unless a parent of that sub-folder is marked as a branch root, in which case there is no location to branch to.
Any folder that either holds a branch root as a child, or has abranch root as a parent cannot be used to create a new branch:
On the commandline try running tf branches . from the folder that you want to branch (to see if it is part of a branch) and from the folder you want to branch to. If the target folder is already under a branch, you can't branch to it. You might need to use the Convert to Folder option in the Source control explorer to allow branches to be created there.
It looks like you've already created the target folder, and the target folder is already a branch. You haven't described how that came to be, if it's a result from a Branch action on the source folder, then instead of choosing Branch pick Merge instead.
If there is no relationship between the two folders then it won't be pre-populated in the list of possible merge targets. If you're using Visual Studio 2013 you can enter the path manually and TFS will create the relationship by doing a baseless merge. If you're using an older version of Visual Studio you may need to create this relationship from the commandline:
tf merge "$/TeamProject/Machinenzustandsanzeige" "$/teamproject/Machinenzustandsanzeige NC-Prä" /baseless /recursive /collection:{uri}
You can also destroy the target branch that you've created using the commandline and then re-attempt the branch, which should then succeed.
tf destroy "$/teamproject/Machinenzustandsanzeige NC-Prä" /recursive /collection:{uri}
tf branch "$/teamproject/Machinenzustandsanzeige;T" "$/teamproject/Machinenzustandsanzeige NC-Prä" /recursive /collection:{uri}
tf checkin "$/teamproject/Machinenzustandsanzeige NC-Prä" /recursive /collection:{uri}
In case the workspace isn't setup correctly yet you can either do it through the UI using the steps outlined here or from the commandline using:
tf workfold /map "$/teamproject/Machinenzustandsanzeige NC-Prä" c:\path\where\you\want\it
followed by:
tf get "$/teamproject/Machinenzustandsanzeige NC-Prä" /recursive
to effectuate the addition of the folder.
There is a very slim chance that the a-umlaut is causing the issue. Have you tried a path without special characters?
What you want to achieve is a standard operation and TFVC supports it, but somehow you ended up in a situation that is non-default. Even in such a situation you can get it fixed, but you might need to resort to advanced features such as /baseless or /force or tf destroy which are not available from the UI.

TFS merging from sub-child to main direclty

In my TFS source control repository I have three branches laid out like this:
MAIN
|
-> DEV
|
-> TEST
I want to merge directly from TEST to MAIN without merging through the DEV branch.
MAIN .......
| .
-> DEV .
| V
-> TEST
I'm unable to find an easy way to achieve this. Please help me find out whether this is possible.
This is possible but not recommended. This is what you'd call a baseless merge in TFS. Without installing any extensions to Visual Studio you can only perform this from the commandline.
Because TFS will not look up the common ancestor for the files being merged it will present every change as a conflict and will require you to manually merge each and every one of them. When merging through DEV TFS will be able to find the common parent and use that to do a 3-way merge.
Additionally, once TFS merges between two unrelated branches it will create a branch relationship between the two paths. Going forward it will show the path from TEST to MAIN as a valid merge direction.
There is an alternative to this in the form of a Shelfset Transplant. This basically shelves all the changed files and will allow you to apply the changed files to a different branch without creating a branch relationship.
If all of this doesn't deter you, then these are the ways to do it:
In the Merge window in Visual Studio enter the path you wish to merge to manually in the dropdown menu (VS2012 and up)
On the commandline use tf merge /baseless /recursive source target to create a new merge relationship.
Use the Visual Studio Power Tools' tfpt unshelve /migrate /source:<> /target:<> shelvesetname to unshelve changes from a shelveset created on one branch to another branch.

TFS Branch Merge on different branches

I've the following structure on TFS:
$Base
- $Dev Branch 1
- $Integration Branch 2
I would like to merge the changes on Dev Branch 1 to Integration Branch 2 so that build guys can kickoff Hudson build of this Integration Branch.
I'm using Visual Studio 2008 Team, and when I try to merch Dev Branch1 I can only see Base on Target Branch drop down.
Could anyone please advise how and if it's possible to merge between Dev and Integration branches above.
Thanks
There are a couple of ways to do this but neither are that great. For the first method you will need to install the TFS 2010 power tools
Use a shelve set. Start the merge from dev to base, resolve any conflicts. Do not check in the merge, instead shelve the changes. Then from the command line use tfpt unshelve "my shelve set" /migrate /source:$/teamProject/dev /target:$/teamProject/integration. This will migrate the shelved changes to the integration branch without having to commit the changes to the base branch.
Perform a baseless merge between dev and integration. You can do this by using the command tf merge $/teamProject/dev $/teamProject/integration /baseless /recursive once the baseless merge has established a branching relationship then you can do further merges through the UI. Be warned though that a baseless merge won't know about any files or folders that have been renamed or moved so you will need to make sure you take this in to account.
Personally I'd go for option 1 if it's a one time thing. If it's going to be something you think you'll need to do regularly then I'd do the baseless merge when all 3 branches are in sync I.e. just after you've merged from dev to base to integration. This should minimise any issues with the baseless merge.
You might also want to take a look at your branching strategy so that you don't need to perform complex merging operations very often. If you use an integration branch then it should have a direct relationship with any branches you need to integrate. Check out the ALM rangers branching guidance.
You can only merge to where the branch was created from. You would have to merge from Dev to Base and then again from Base to Integration.
If you want to merge from Dev to Integration directly then your Integration branch should be created as a branch from Dev not Base.

Orphan a branch in TFS

Suppose I create an experimental branch in TFS. Now, I am finished with the branch, and I want to keep it around, but it has diverged sufficiently from the source branch that I want to make sure that no one can merge it back on accident. Is there a command in TFS to sever a branch, so that there is no merge path back?
I'm not sure if this will prevent a merge but in TFS 2010 you can turn a branch in to a folder
Check out Buck Hodges blog on the subject
As far as I know, you can set permissions on a branch.

Resources