Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Subversion can't merge after a move

Tags:

svn

svn-merge

I'm very new to Subversion, but I've used other revision control systems like ClearCase for years.

My boss asked me to fix this project so that it could be built with Maven instead of Ant. One of the important things I had to do to was to move src/com to src/main/java/com, and move test/com to src/test/java/com, which I did using the svn mv command. I foolishly assumed that since I used Subversion commands to move the directories, that Subversion would then know that things had been moved. And when I merged my branch into the trunk, it appeared to work. But now somebody else just finished work on a branch that he branched off before my work. So we go to merge his stuff into trunk, and basically Subversion appears to think “ok, he made changes to src/com/foo/bar/baz.java, but that directory doesn’t exist any more, so it’s irrelevant, so discard it” instead of what I expected, which was “ok, he made changes to src/com/foo/bar/baz.java, but src/com has been moved, so I need to merge that into src/main/java/com/foo/bar/baz.java.

Is there a way to make Subversion do the revision management, or am I going to be manually merging this guy’s changes for the next two days?

like image 429
Paul Tomblin Avatar asked Jan 14 '10 13:01

Paul Tomblin


People also ask

Can svn merge be undone?

If you don't like the results of the merge, simply run svn revert . -R to revert the changes from your working copy and retry the command with different options. The merge isn't final until you actually svn commit the results.

What is reverse merge in svn?

Reverse merge In SVN SVN will keep common file contents in working copy from the specific revision of file and HEAD revision of working copy. if it is folder level. In SVN reverse merge, if not file found in the specific revision, it keeps the working copy as it is.


2 Answers

To answer your question directly:

Is there a way to make Subversion do the revision management, or am I going to be manually merging this guy’s changes for the next two days?

You should be able to make it a little bit easier on yourself.

One thing that you can do to alleviate some of the pain (assuming a layout as follows)

/branch/foo/src/com
/branch/foo/test/com
/trunk/src/main/java/com
/trunk/src/test/java/com

Before you moved src/com to src/main/java/com and test/com to src/test/java/com you could have done:

cd $TRUNK
svn merge -r N:M http://server/branch/foo .

What you could do now is:

cd $TRUNK
svn merge -r N:M http://server/branch/foo/src/com src/main/java/com
svn merge -r N:M http://server/branch/foo/test/com src/test/java/com

Hope this helps to save you some time.

like image 111
Paul Wagland Avatar answered Sep 25 '22 19:09

Paul Wagland


This sounds like a one-time problem. I suggest you could use svn diff > /to/some/file.patch (or normal diff) to save his changes to a file, then apply it on your moved trunk with patch -p0 < /to/some/file.path.

like image 37
BastiBen Avatar answered Sep 24 '22 19:09

BastiBen