TFS merging from sub-child to main direclty - tfs

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.

Related

TFS - Make 2 Existing Folders related branches

I am working with TFS 2012 and wondering if I can accomplish something easily. I have two folders with several sub folders ... in a previous SC they were branches of each other.
Is there a way in TFS to make them have a "relationship"? I've used the "Convert to Branch" on both. When I try to "Merge", not surprisingly it has an "!" mark and says "A merge relationship does not exist between the source and the target. A baseless merge will be performed."
So is there any way to "create" that relationship? I realize I could delete one of the folders in TFS, create the branch, and then copy all the original files into the branch location and then check them in. But outside of that is there a way? I tried "Reparent" but the pick list is empty.
The trick is to go to the commandline where you can perform a baseless merge using:
Tf vc merge $/proj/branch1 $/proj/branch2 /baseless /recursive
After which you can use the reparent feature to setup the correct parent/child relation.
See also
https://alistairbmackay.wordpress.com/2014/01/15/tfs-reparenting-a-branch/

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.

Creating a TFS branch with same initial code base as second branch

Here is my current setup. (TFS2008)
I have a TRUNK with latest.
I have BRANCH-A off of TRUNK with only the production ready code merged in.
I would like to create a new BRANCH-B off of TRUNK but I don't want all the latest code, I only want what is currently in BRANCH-A.
After this is done I will be merging into both BRANCH-A and BRANCH-B from the TRUNK (so I don't want to branch BRANCH-B off of BRANCH-A.)
Thanks.
You need to perform a baseless merge. This sibling situation that you want to achieve is exactly what is described in How To: Perform a Baseless Merge in Visual Studio Team Foundation Server:
The process of merging items that are not directly branched from each
other is called a baseless merge. For example, you might want to merge
a change between two release branches, which are siblings of each
other, without merging up to the parent branch. You can only perform a
baseless merge by using the Tf merge command. You cannot perform a
baseless merge from within the Visual Studio IDE.
When you perform a baseless merge, TFS does not have any information
about the relationship of the files in the branches. For example, if
you have renamed a file, this will be viewed as a deleted file and a
new file will be added in the branch. For this reason you have to
perform more manual conflict resolutions than when you perform a
normal merge. However, you only have to perform this conflict
resolution once. After you have performed the baseless merge, TFS
records merge history and establishes a relationship between the
folders and files.
When you create BRANCH-B, you can either choose latest or a specific date/changeset/label. Take a look when you created BRANCH-A and create the BRANCH-B from the same date/changeset/label. As long as you haven't made any changes to BRANCH-A, you can create B to match.
Also, if you haven't already, take a look at the TFS 2008 Branching guidance. There is some great information and uses a pragmatic approach.
For TRUNK
On Create Branch you have option as a "Branch from Version" - by default By Latest Version is selected.
Select By changeSet or By Date

TFS baseless merge

I am merging two branches which do not have a parent child relationship. I have started with a single file to test if the merge is working properly before the actual merge. I am using tfs baseless merge in order to do this.The following is the command:
Tf merge /baseless C:\Inetpub\wwwroot\Test\CreateDescription.aspx.cs C:\Inetpub\wwwroot\Test1\CreateDescription.aspx.cs /recursive
Changes have been done in both the files. However in the resolve conflict dialog box I only see two options
1) Keep the changes in the target branch
2) copy code from source branch
Merge changes in merge tool is greyed out. What should I do in order to enable this option. I want to manually merge changes in the both the branches.
A simple way to do this would be to check out the file you want to be the target (i.e C:\Inetpub\wwwroot\Test1\CreateDescription.aspx.cs) and then use an external merge tool to merge the changes. I'm a big fan our SourceGear Diffmerge, mainly because it's free (as in beer). This will allow you to merge the files and resolve the conflics.
Once you've done this, you could run the baseless merge to establish the merge relationship between the branches and tell the merge tool in TFS to keep the changes in the target. You can also tell TFS to use DiffMerge as it's merge tool which might get rid of the problem all together.

Converting folder copies to branches in TFS 2010

TFS 2010 introduced the ability to convert basic folders into branches. The documentation also speaks of "reparenting a branch" (which does not appear in source control explorer context menu but is accessible only through File>Source Control> Branching & Merging ... hard to find ...)
Let's say I have folders A and A2 under source control.
A2 was COPIED from A some time ago, but is not a branch of A. It is just copied, added to source control and checked-in. Since they are not declared as branches, there is no history of merge operations between A and A2.
The commands "Convert to branch" and "Reparent branch" make me think that both A and A2 can be converted from basic folders to branches and A can be configured as the parent branch of A2, thus giving me the ability to use all the juicy branch features of TFS 2010.
I couldn't get this done. I converted both A and A2 to branches but there are no relations between them. While trying to "reparent" A2, I can not selected A as a parent branch.
How can I do this? If what I am trying to do is not possible, then what is "Convert to branch" and "Reparent Branch" good for?
Reading from different sources you should be able to use Convert to Branch and Reparent Branch after doing a baseless merge between the folders.
Do a baseless merge, but do not actually change any files:
tf merge /baseless /recursive /discard <source> <destination>
Update for VS2012 users:
Visual Studio 2012 does Baseless Merges, which can save time (no TF command line needed)!
I came across this when wanting to branch Master to a specific existing BugFixes folder, which I had converted into a branch.
Simply merge the two unrelated branches, Check In and then reparent.
Works like a whiz! This is what the baseless merge in VS2012 looks like. Thank you to Sahas Subramanian .
http://www.incyclesoftware.com/2012/08/baseless-merge-vs-2012-ui/
See http://www.incyclesoftware.com/2012/08/baseless-merge-vs-2012-ui/ for a walk through (
thanks for the image).
I've never done this before, but here is the link in msdn describing how to do this: http://msdn.microsoft.com/en-us/library/ms181425.aspx

Resources