Converting folder copies to branches in TFS 2010 - tfs

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

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.

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.

Is there an easy way to create a patch in one branch and then apply it to another branch in TFS 2010?

I have two service pack branches coming out of one ‘main’ branch in TFS 2010. I want to ‘transport’ a change set from one service pack branch to another without promoting it through the main branch and without doing baseless merge.
The ‘main’ branch contains a conflicting change set that I don’t want to merge with the change set from the first service pack branch. I want the second service pack branch to receive that change set in unmodified form.
The baseless merge will create a link between two branches. I don’t want such link to appear in the merge dialog.
Is there an easy way to create a patch in one branch and then apply it to another branch? Something like in Subversion.
P.S. I’m not going to change branching structure to accommodate this one scenario. The overall structure is way more complex that what I described and it accommodates a number of releases, service packs, sub-releses, and etc. It follows the well-known branching guideline.
So you have something like this:
------------------------------------> MAIN
\ \
\ \
A B
You can make a B' branch out of B:
------------------------------------> MAIN
\ \
\ \
A B
\
\
B'
Then make a baseless merge from A->B'. After that make a merge B'->B. Go ahead & destroy B'. Though I haven't ever done this, it should work.
One approach:
Map both branches (A and B) into separate folders on your PC.
Locate the changes in A that you want to merge into B (look at source control history for the branch, locate the changeset(s) and double click them to list the chnaged files), and check them out in the destination branch. (Alternatives: Check out all the files - TFS will discard unchanged files when you check in. Or unplug your network cable and then run VS and it'll go offline. After merging use File>Source Control>Go online to go back online and check out any changed files)
Use a merge tool (I'd recommend Beyond Compare, Araxis, but anything aside from the terrible ones that ship with VS should do) to merge from each file in branch A to the eqiuivalent file in branch B
Build and test branch B
Check in
This avoids using TFS to do any of the merging, so it won't know that it's a merge. It will just think you've written a lot of code in branch B rather fast :-)
Another approach:
Merge the changeset into your main branch from A. During the merge, include both variants of the code and add #if commands around the new and old code blocks so that they coexist side by side, and the service pack is "enabled" in the main trunk by a simple define. By default this define should not be defined, so the binary output by the main branch code is unaffected. i.e.
#if SERVICE_PACK_A
...ServicePackA code...
#else
...original Main branch code...
#endif
Now merge the change down into branch B
My answer is similar to Jason Williams's. If you want to stay "inside" TFS then you only have 2 options. Perform the baseless merge, or merge from A to Main and then from Main to B.
As you don't want to do either of these, then you'll need to perform the merge "outside" of TFS.
Tools you'll need:
Team Explorer, Team Foundation Power Tools, a 3rd party merge tool. I like Sourcegear DiffMerge (cos it's free) but Araxis, Beyond Compare and Winmerge will all work just as well. (as an aside you can configure TFS to use a 3rd party merge tool(Thanks again Jason!))
Get Latest on both service pack branches
Check out the target branch
Use the merge tool to do a folder comparison between the 2 local folders
Merge the appropriate changes from A to B
On the command line run tfpt uu against the local copy of B, this will undo the checkout of any files that haven't changed as part of the merge. (this requires that the TFS Power tools are installed.)
Check in the pending changes in B
It's not great but I think it's the only way to do what you're trying to achieve
Actually I was pointed to another solution that I like too.
http://geekswithblogs.net/TarunArora/archive/2011/06/06/unshelve-shelveset-created-from-one-branch-to-another.aspx

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

Resources