views:

89

answers:

3

I've been working on a feature in an SVN branch for a while. Periodically, I merged changes from trunk into my private branch so I could get everyone else's changes using the procedure described here. That seemed to work fine.

Now I'm ready to merge my changes into trunk. I'm trying to do this by merging the range of revisions starting from the point I branched and ending with HEAD of the branch. But when I try to do this, SVN reports numerous tree conflicts. It looks like every file that was added in trunk (and merged into my branch) is in conflict.

I was hoping that by merging periodically from trunk into my branch, the merge going in the opposite direction would be trivial. Apparently not. What am I doing wrong?

+3  A: 

You need to re-integrate the branch. Also, when you merge the trunk back into your branch, you should have merged with ancestory otherwise SVN doesn't know what revisions have been merged.

DaveShaw
This link was very helpful. Since I am working with a pre-1.5 SVN server, I needed to use the "2-URL" merge command, which worked perfectly. Thanks!
Rob H
Upgrade from 1.4 if you possibly can -- merge support is vastly greater in 1.6 (or even 1.5) and this will be much more painless.
the_mandrill
+1  A: 

You need to re-integrate the branch into the trunk. Start with a clean checkout of the trunk and then you should merge (or reintegrate if you are using TortoiseSVN) the branch into the trunk.

It is quite probable that you will have a few conflicts during the merge. Having conflicts does not mean there is a problem. Just resolve these before committing back to the trunk.

Also, it could be that you/server/repository are using an old version of SVN (pre 1.5) that did not have merge tracking. This could be the source of loads of conflicts because SVN wouldn't know about all the revisions you merged into your branch and would try to merge changes from those revisions into the trunk for a second time. Merge tracking helps SVN to ignore changes to your branch that are already made in the trunk.

Jaco Briers
A: 

Assuming you are using some version of Subversion that support merge tracking (v1.5 or higher), the magic you need is a "re-integrate merge".

There are a few different kinds of merges in SVN, and a "re-integrate merge" is different from the "incremental merges" you've been performing to keep your branch up to date. In short, an incremental merge (which is the default kind of merge) brings across changes on a revision-by-revision basis. If you try one of these merges when going back into trunk, you'll be bringing back into trunk both changes that you have made in the branch, PLUS all of the changes that originated in trunk that were brought into your branch. That's why you are seeing conflicts.

The SVN book explains this pretty well; read this section carefully to get a better handle on this.

Matt Dillard