gitvisual-studioversion-controltfvcdiffmerge

How can I fine tune what Visual Studio considers a merge conflict when using TFS?


I am attempting to merge a small amount of code changes from a branched file to a trunk file that has been heavily modified (mostly by adding cases to a switch). When I am attempting to merge the code, I am merging from the older file to the newer file (from less cases to more cases). When I tell visual studio to merge from the branch to the trunk, it is getting rid of all of the updated (new) cases and replacing the last (new) case with the case that was added in the branch. EX:

TRUNK:

 SWITCH(var){
     CASE(123)
        thing = "bnm"
     BREAK  
     CASE(124)
        thing = "gjh"
     BREAK  
     CASE(125)
        thing = "sdf"
     BREAK  
     CASE(126)
        thing = "asd"
     BREAK  
     CASE(127)
        thing = "qwe"
     BREAK  
}

BRANCH:

 SWITCH(var){
     CASE(123)
        thing = "bnm"
     BREAK  
     CASE(124)
        thing = "gjh"
     BREAK  
     CASE(325)
        thing = "poi"
     BREAK
}

MERGE RESULT:

 SWITCH(var){
     CASE(123)
        thing = "bnm"
     BREAK  
     CASE(124)
        thing = "gjh"
     BREAK  
     CASE(325)
        thing = "poi"
     BREAK
}

DESIRED RESULT:

 SWITCH(var){
     CASE(123)
        thing = "bnm"
     BREAK  
     CASE(124)
        thing = "gjh"
     BREAK  
     CASE(125)
        thing = "sdf"
     BREAK  
     CASE(126)
        thing = "asd"
     BREAK  
     CASE(127)
        thing = "qwe"
     BREAK  
     CASE(325)
        thing = "poi"
     BREAK
}

What I want to happen is for it to isolate the new case and move it into the switch. I was hoping there is a way to manually decide how to merge the files or a way to "teach" the merging tool how to handle large changes.

In the example, the only things that differ from case to case are the values within the case (CASE(value)) and the value assigned to thing. Also, there are never any merge conflicts detected.

If there is no way to fine tune the compare tool, are there any other tools that are great at automerging?

UPDATE: This is only an issue when you do a baseless merge. If you do not do a baseless merge, it works fine


Solution

  • Not short, there has no way to show merge conflict if only one side has updated.

    For your situation, the process seems to be: create/modify the trunk file firstly, then modify the branch file based on the trunk file.

    When merging branch file into trunk file, TFVC will compare changes between trunk file and branch file. Since the file was only updated in one side (update branch file by conparing with trunk file), so it will merge with the latest version (version from the branch file) by recursive merge strategy. And there is no way to show merge conflict for this situation.

    But since the merged file does not checkin automatically after merging, so you can edit the merged file with the content you need, then checkin the merged file into source control.

    enter image description here

    Or you can use the workaround as below to merge with conflict:

    Create another branch (assume branch2) from the trunk file -> checkin changes for branch2 -> merge branch file into branch2 file -> there will show the merge conflict -> then merge with the version you want.

    Note: for git, it will also merge with recursive merge strategy and without merge conflicts.