TFS baseless merge - tfs

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.

Related

How to do a baseless merge or otherwise take away the need for a baseless merge?

I have created a branched copy of my main production code-base so that I can safely perform development.
This involved creating a Main branch (the parent) and then another branch on the same level for my development called Dev(the child).
I have managed the merge the content from my child branch to my parent branch.
However, when I try and merge from my parent branch to my non-branched Production code base, I encounter problems.
I have attempted peforming a baseless merge using the Developer Command Prompt for Visual Studio 2017 Professional edition.
Do I need to do anything else such as converting my Production Code base to a branch. Then to re-parent the main branch and choose the new Production Code base branch as a parent, and perform the remaining merge that way ?
Is that the best way to accomplish my final merge ?
First, if your Production Code base are still folders not a branch. You should convert them to a branch first.
In TFVC, you could only merge to directly related branches(parent or child). There is no merge relationship between main branch and new Production Code branch in your case . You have to perform a baseless merge through tf merge command.
tf merge /baseless <<source path>> <<target path>> /recursive
/baseless
Performs a merge without a base version. That is, allows the user to
merge files and folders that do not have a merge relationship. After a
baseless merge, a merge relationship exists, and future merges do not
have to be baseless.
Note Baseless merges cannot delete files in the target. You can manually carry over such changes.
If you want to reparent to other branch, you must set a relation ship between the 2 branches first.
In other words, you still need a baseless merge first. Afraid, we could not take away the need for a baseless merge. As for how to reparent branch in TFVC, you could refer my answer in this link: TFS reparent to be a grandchild

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/

HowTo: correctly synchronize TFS branches with missing changesets?

Background
If I merge our main branch to our development branch, TFS will state that there are no changes to commit. And yet, a file level comparison (using WinMerge) clearly shows that there are differences (e.g. files missing, files with different content, etc.).
In short, our main and development branches are no longer in sync which is most likely due to changesets that were lost during previous TFS migrations.
Question
What is the best way to produce the following?
Synchronizing the main and development branches by: performing all of the necessary insert/update/delete operations on the development branch. (i.e. main is the master copy).
At the end of the process WinMerge should indicate that there are zero (0) differences between the two branches.
Keeping the development branch history intact.
Notifying TFS that the development branch is now fully synchronized with main so that:
TFS won't try to merge older development changesets with main
only future changes to development will be pushed to main during a merge operation.
TFS is not my area of expertise - any guidance that you can provide would be greatly appreciated.
Context
Visual Studio 2015
TFS (version 14.95.25122)
References
Merge Command
"Performs a merge without a base version. That is, allows the user to merge files and folders that do not have a merge relationship. After a baseless merge, a merge relationship exists, and future merges do not have to be baseless."
Although Development was branched from Main, it looks like this might address my lack of history (i.e. missing changesets) problem.
TFS Merge: Best Practices
TFS: Overwrite a branch with another
tf merge A B -r -force -version:T
I don't think this will work for us because changesets are missing.
When TFS does a merge, it bases the merge on prior merge history, not on the actual contents of the source and target files.
This issue may by caused by picking keep target when perform merge or at one time, a merge with the discard option performed (using the command line TF merge /discard).
To solve this issue, you can try to:
Use the /force option with the tf merge command. If there is a changeset that was previously merged (perhaps incorrectly) and you want to merge it again. The /force flag ignores merge history that indicates a particular changeset was previously merged from source to target, and merges the changeset again.
Undo the previous merge using Rollback. If you've recently done the merge in which changesets have been discarded. Find it in the history, rightclick the changeset and pick Rollback and check in the code that has been undone.

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.

Resources