'SVN Merge of Moved Source Code Files
I feel like I have the simplest use case in the world with SVN:
- I have a file, 
Test.javaintrunkof SVN. - I branch 
trunktodev-branch. - I move 
Test.javaintocom/mycompanyfolder intrunk. - I change 
Test.javaindev-branch. - I merge 
dev-branchtotrunk. - Tree conflict results.
 
Why, oh why, can't SVN handle this? Are we doing something wrong? This feels like it should be easy and yet every engineer at my company is stymied.
Looking for SVN-oriented answers here (not 'move to git', etc).
Solution 1:[1]
In SVN a move is a delete and an add. When you merged in the branch it would do the add part of your move, but it couldn't do the delete because of the conflict. You now have to resolve the conflict manually by
- Copying your 
Test.javatocom/mycompany/Test.java, overwriting the old one. That resolves the conflict with that file. - Delete the 
Test.javafile from the old place. That is the manual way to do the delete part of the change set that SVN couldn't do when you did your merge. Use thesvn delete Test.javacommand. - Tell SVN the conflict is resolved and that your working directory is correct with 
svn resolve --accept working .The dot at the end is for the current directory - Tell SVN that the 
Test.javafile's conflict is also resolved withsvn resolve --accept working Test.java 
Then you can commit your merged version and you are back in sync with the repository.
Solution 2:[2]
In SVN 1.14, this merge should work fine. SVN will be able to detect the moved folder in trunk. So simply doing a merge would have been fine.
But if this is not the case, the alternative would be to merge the trunk 'tree change' into the branch first and then merge the branch into trunk again. So basically you align the branch with the newest changes in trunk (so the folder would have been created and the file moved into it), and then only merge back to trunk.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source | 
|---|---|
| Solution 1 | David Harkness | 
| Solution 2 | Wasted_Coder | 
