Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SVN tree conflict when merging renamed folder

I'm using TortoiseSVN to merge into branch-B the latest changes from trunk, including a folder rename.

Before that, I reintegrated branch-A into trunk. In that branch, a folder had been renamed and changes had been made to the files in it. Branch-B contains different revisions to those files, but the folder still has the original name.

When merging trunk into branch-B, SVN simply adds the renamed folder as new, and reports a tree conflict on the originally named folder. The file revisions themselves are never merged and I'm left with both folders. I've tried multiple options to get the cleanest merge possible, while retaining all the appropriate svn:mergeinfo, but nothing seems to work.

Does anybody know the correct way to go about completing this merge cleanly?

TortoiseSVN 1.8.10, Subversion 1.8.11

Here's a visual:

/trunk (before reintegrating branch-A)
  /Folder1
    file1
    file2
    file3

/trunk (after reintegrating branch-A)
  /Folder1-Renamed
    file1-change1
    file2-change1
    file3

/branch-B
  /Folder1
    file1-change2
    file2-change2
    file3

TL;DR: How do I cleanly merge file revisions between two branches when the containing folder has been renamed in one of them?

like image 703
plwalsh88 Avatar asked Feb 11 '15 21:02

plwalsh88


People also ask

What is tree conflict in svn merge?

A tree conflict occurs when a developer moved/renamed/deleted a file or folder, which another developer either also has moved/renamed/deleted or just modified. There are many different situations that can result in a tree conflict, and all of them require different steps to resolve the conflict.

How can I see svn conflicts?

Step 1: View ConflictsSelect: (p) postpone, (df) diff-full, (e) edit, (mc) mine-conflict, (tc) theirs-conflict, (s) show all options: Subversion is complaining that there is a conflict with the README file, and Subversion does not know how to solve this.

How do I merge two svn revisions?

Examples. Merge a branch back into the trunk (assuming that you have an up-to-date working copy of the trunk): $ svn merge --reintegrate \ http://svn.example.com/repos/calc/branches/my-calc-branch --- Merging differences between repository URLs into '. ': U button.


1 Answers

There is no really clean way to resolve structural tree conflicts like this in Subversion. Basically, what you need to do is the following:

  • merge trunk into branch-B working copy
  • manually create a diff of the changes to file1 and file2 in branch-B and apply them to the corresponding files in the newly merged Folder1-Renamed directory
  • delete the now obsolete Folder1 directory
  • make sure everything still works
  • accept the current state as the correct one (see also http://svnbook.red-bean.com/nightly/en/svn.tour.treeconflicts.html)
  • commit

Sorry, it does not get easier than that with svn. I am a big fan of using Subversion for certain kinds of team setups, but the nightmare of tree conflicts (and their arcane and error prone resolution mechanisms) regularly make we want to cry (and switch to git for good).

like image 159
Michael Schlottke-Lakemper Avatar answered Oct 17 '22 00:10

Michael Schlottke-Lakemper