Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SVN Merge of Moved Source Code Files

Tags:

merge

svn

I feel like I have the simplest use case in the world with SVN:

  • I have a file, Test.java in trunk of SVN.
  • I branch trunk to dev-branch.
  • I move Test.java into com/mycompany folder in trunk.
  • I change Test.java in dev-branch.
  • I merge dev-branch to trunk.
  • 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).

like image 763
Josh Harness Avatar asked Sep 07 '12 17:09

Josh Harness


People also ask

How do you merge a specific commit from one branch to another svn?

Have a local checkout of the branch to which you want to merge a range of revisions from a source branch. By default, "Merge a range of revisions" is clicked. Click Test Merge to check if it merges desired revisions/files.


1 Answers

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

  1. Copying your Test.java to com/mycompany/Test.java, overwriting the old one. That resolves the conflict with that file.
  2. Delete the Test.java file 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 the svn delete Test.java command.
  3. 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
  4. Tell SVN that the Test.java file's conflict is also resolved with svn resolve --accept working Test.java

Then you can commit your merged version and you are back in sync with the repository.

like image 159
maddoxej Avatar answered Sep 28 '22 11:09

maddoxej