SVN tree conflict when merging renamed folder
Asked Answered
F

2

12

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?

Fluor answered 11/2, 2015 at 21:59 Comment(1)
Ah sorry. TortoiseSVN 1.8.10, Subversion 1.8.11. @bahrepFluor
D
10

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).

Driftage answered 13/2, 2015 at 8:21 Comment(2)
looks like that procedure did the trick. Thanks for spelling it out for me!Fluor
There is a reason everyone moved to git.Bibliolatry
P
0

You can do it on the command line this way. The equivalent steps should work with TortoiseSVN or other clients.

Say the rename was done in revision 1000 in trunk, and you're merging trunk into Branch-B:

# merge everything before the rename
svn merge ^/trunk@999
svn commit -m 'merge from trunk up to 999'
svn update

# merge everything starting with the rename
svn merge ^/trunk
# for tree conflicts on directories, accept the incoming deletion, and make note of the path

# for each tree conflict, take your changes to the old folder,
# and re-apply them to the new folder using a two-URL merge,
# then delete the unnecessary mergeinfo.
# e.g. for Folder1 vs Folder1-renamed:
svn merge ^/trunk/Folder1@999 ^/branches/Branch-B/Folder1 ./Folder1-renamed
svn propdel svn:mergeinfo ./Folder1-renamed

svn commit -m 'merge from trunk'
Priory answered 9/7, 2021 at 18:59 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.