0

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

DaDuStMaN20
  • 137
  • 2
  • 11
  • I do not know of anyway to get you version control to merge like that. Typically version control expects you to create the final version of the file. Some times if 2 users work on the same file the merge tool will ask you to resolve a conflict that cannot be merged manually – Ken Tucker Jun 14 '18 at 01:20
  • Have you been merging trunk to the feature branch. Were there conflicts? – max630 Jun 14 '18 at 07:03
  • @DaDuStMaN20, Would you please share the latest information? Do you resolve this issue now? – Jack Zhai Jul 09 '18 at 03:04

1 Answers1

0

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.

Marina Liu
  • 36,876
  • 5
  • 61
  • 74
  • Is there a way to be able to move the changes from one side to the other in the comparison view? An easy way without copy and pasting it. I just want to be able to move and isolate changes from one side to another. Is there a way to merge from trunk to branch? When I tried, it said that there were no changes to merge. (source: trunk Target: branch) – DaDuStMaN20 Jun 14 '18 at 02:13
  • Since branch file has the latest version and the trunk file does not have latest version, so when you merge opposite (merge trunk file into branch file), there will show no changes to merge. – Marina Liu Jun 14 '18 at 02:30
  • And I added a workaround to merge with the version from trunk and branch by creating a new branch2 from trunk. You can have a try. – Marina Liu Jun 14 '18 at 02:34