tags:

views:

57

answers:

1

I have an SVN (1.6.12) project containing a trunk and one branch. I am trying to learn how merging works.

project
+ trunk (14)
+ branches
  + test-branch (14)

The numbers in parentheses are the revision numbers. I execute a merge from the trunk to the test branch using the the commands "cd branches/test-branch; svn merge svn+ssh://.../trunk" and commit the changes with "svn commit -m 'Merged trunk'". My directory structure now looks like this:

project
+ trunk (14)
+ branches
  + test-branch (15)

I then try to do a reintegrate merge between the trunk and test-branch: "cd trunk; svn merge --reintegrate svn+ssh://.../branches/test-branch". SVN complains that the trunk needs to be at revision 15. I do a "svn update" and the directory structure looks like this:

project
+ trunk (15)
+ branches
  + test-branch (15)

Cool! Ready to reintegrate. I try the "svn merge --reintegrate svn+ssh://.../branches/test-branch" again. Now SVN complains that I need to merge all of the trunk changes into the branch before reintegrating. The trunk is at 15 and but the test-branch has only merged through 14.

How do I resolve this? If I merge into the branch and then commit, the branch will be at 16. I tried using "svn switch" on the trunk, but I get the same errors.

The reason the repository is at 14 is because I keep see-sawing between the trunk and test-branch merges. One definition of insanity is repeating the same process and expecting a different outcome :-).

Thanks.

+3  A: 

It sounds like you have a checkout above branches and tags, that's now how you're supposed to work.

To fix this make sure you have a single working copy of just trunk:

svn co <server>/svn/repos/trunk

If you want to create a branch from that, you should make a server-side copy (otherwise it'll make a copy of your working copy to that branch, you don't want that):

svn copy <server>/svn/repos/trunk <server>/svn/repos/branches/test-branch

Now you can switch your working copy to do some work on the branch:

svn switch <server>/svn/repos/branches/test-branch

You can now either merge changes from the branch to trunk, or reintegrate the branch. After reintegrating, you should delete the branch (the command is meant to be executed once, at the end of the branch, see svnbook for more info)

To do this, first switch back to trunk:

svn switch <server>/svn/repos/trunk

And then either merge a revision:

svn merge -c <revnumber> ^/branches/test-branch

or reintegrate the branch:

svn merge --reintegrate ^/branches/test-branch
svn delete <repos>/svn/repos/branches/test-branch -m "Delete branch"
Sander Rijken