TortoiseSVN Tree Conflict: can't choose remote file
Asked Answered
M

3

10

Here's the scenario:

  • User1, Branch1: adds "abc.def"; commits.
  • User2, Branch2: adds "abc.def" (same file name, but more details in the file); commits.

Now User1 wants to merge the updated version of the "abc.def" file. So (using TortoiseSVN 1.7.10), User1 starts in the Working Copy of Branch1, selects Merge... -> Reintegrate a Branch, then chooses Branch2 and selects Merge. Predictably, a "Tree Conflict" results, with this text:

The last merge operation tried to add the file 'abc.def' from Branch2, but the file was already added locally. How do you want to resolve this conflict?

But the only choice is a single button labelled Keep the local file. There is no option to choose the remote file, which is the one that User1 really wants.

enter image description here

What am I doing wrong here, and how do I fix it? More specifically, how do I get User2's version of the file into Branch1?

(Of course, I'm sure User1 could manually delete the file prior to merging, but that obliterates any history that User1 may have wanted to preserve. Plus it's just a clunky workflow, particularly when there are numerous files in this predicament.)

Unfortunately, this scenario isn't even mentioned in the TortoiseSVN documentation on Tree Conflicts

UPDATE:

In addition to choosing "Reintegrate a Branch" I have also tried "Merge a Range of Revisions" and "Merge two different trees". For the latter case, I chose the remote branch (Branch2) as the "Start" and the local branch as the target (Branch1; choosing the Revision prior to the addition of the file.) I got the same result in all cases: Tree Conflict with no option to select the User2 version of the file.

UPDATE #2:

According to the documentation, there should be "a checkbox in the merge progress dialog called Merge non-interactive", which, if unchecked, supposedly opens the "Merge Conflict Callback Dialog" during the Merge. However, I cannot find any such checkbox in the merge process. Where is it?

Masseur answered 22/5, 2017 at 16:52 Comment(4)
Do you have the option to force the merge? (I'm running 1.9 so I'm not sure if it changed) Also, when you say User1 had added the file to the branch, do you mean SVN added/committed or just created locally?Heptamerous
@whrrgarbl: No, I can't force the merge. That's the problem. Are you saying this scenario plays out differently with 1.9? As for your second question: both User1 and User2 create the file and add/commit. (Updated my post to clarify.)Masseur
@whrrgarbl: If its true that 1.9 has fixed this flaw, and you can demonstrate with a screenshot of the resulting Merge dialog, I'll be happy to award you the bounty.Masseur
Thanks for the clarification! In 1.9 the merge dialog includes a checkbox for "Force the merge".. but unfortunately it does not work like I thought it would in this scenario (somehow it's modifying the file but yet it still has Branch1 version??). hmmm!Heptamerous
H
2

I was able to merge from one branch to another in version 1.9 of TortoiseSVN with the following procedure.

Setup

With a test repository, I did the following steps:

  1. Create a branch, "first"

  2. Create a file "doc.txt" with contents "FIRST" in the new branch first doc

  3. Add and commit the file to the new branch

  4. Create a branch, "second"

  5. Create a file "doc.txt" with contents "SECOND" in that branch second doc

  6. Add and commit the file to the new branch

So my structure looks like:

branches/
    first/
        doc.txt => "FIRST"
    second/
        doc.txt => "SECOND"

Merging

In this example, my goal is to get the contents of second/doc.txt into the first branch.

  1. Right-click on the first branch folder, and select TortoiseSVN > Merge...

  2. Select "Merge two different trees"
    merge dialog

  3. Fill in the "From" box with the URL for /branches/first, and the "To" box with the URL for /branches/second.
    enter image description here
    (This is where I got tripped up originally - I thought it would be the opposite! The docs explain: "This may sound wrong, but remember that the trunk is the start point to which you want to add the branch changes.")

  4. Hit Next and try a test merge if you want. It should show that "doc.txt" is replaced, with no tree conflicts. For this example the default merge options were fine.
    merge options

  5. Do the merge and check the contents of first/doc.txt - it should now read "SECOND".
    merge results

  6. Run an update and then commit the first folder to save the merge to the repository!
    commit results

Complete log:
repository log

Heptamerous answered 9/6, 2017 at 2:18 Comment(5)
Well, I'm afraid I can't seem to reproduce your results. I've tried it several times. The first time I neglected to select "Force Merge" and I got a tree conflict. The second time I made sure to select Force Merge, and the result was a message that SAID it replaced the file -- but the contents were still from the first branch.Masseur
I went ahead and awarded you the bounty because it was about to expire anyway. I'm out of time to work on this tonight, but I will play with your instructions again tomorrow. Thanks for your effort!Masseur
@Masseur Hm, did you make sure to put the branch names in the right order? I had that happen too before I realized they were opposite.Heptamerous
Oh man, thanks! I will do my best to get you some screenshots tomorrow if that will help :)Heptamerous
@Masseur I just redid the exercise and took screenshots, plus some corrections. Hope it works now, sorry for the delay!Heptamerous
U
0

Reintegrate a branch vs merge a range of revision

I think what you want to do is merge a range of revisions first and then merge the branch back into the tree.

Unsound answered 30/5, 2017 at 10:56 Comment(1)
No, I still get the same results: The Tree Conflict dialog box still doesn't give the option to replace the local file with the remote one from the other branch.Masseur
T
0

There is a dialog called

Merge Conflict Callback Dialog

enter image description here

Relating this issue:

the Merge Conflict Callback Dialog should come up - when merging multiple revisions via "Merge a range of revisions" - when merging via "Reintegrate a branch"

at the moment the Merge Conflict Callback Dialog only comes up in the first case.

It will be included in the upcoming 1.6.0 release.

That allows to you to select the repository change instead yours

Territory answered 2/6, 2017 at 16:2 Comment(1)
I am already using v 1.7, so I am afraid this answer (along with the thread that you linked to) does not address my situation, unfortunately.Masseur

© 2022 - 2024 — McMap. All rights reserved.