SVN merge issue

I have a directory running subversion. I created a branch from it just for merge testing. I took the file, changed the line X in the tube as "abc" and changed the same line X as "def" in my branch.

Then from the working branch directory I did:

svn merge branchURL trunkURL . 

He updated the file with the contents as "abc" on this line number, that is, he did not give me a conflict with the same line number as svn update , if I did this in the same working directory and someone committed "def" in the repository.

So svn merge just replaces the contents during merging and does not lead to conflicts?

And if so, then the reason for branching proj dir from the main body would be useless when it would be impossible to merge in such a way as to save both changes in the trunk and branch.

+6
svn
source share
3 answers

Do you understand that

 svn merge branchUrl trunkUrl branchWorkingCopy 

In fact, huh?

Here's the translation:

Find out the set of changes necessary to ensure that the contents of branchUrl are identical to the contents of trunkUrl. Now make these changes on the WorkingCopy branch.

You will not have conflicts merging in this way. However, when registering with your WorkingCopy branch, you will make your branch identical to your trunk, which is almost certainly not what you want.

If you want to copy selected changes from an external line to a branch, you need to tell Subversion which changes you want to copy and use a different form of the merge command:

 svn merge -r100:103 trunkUrl branchWorkingCopy 

This means: Define the set of changes needed to get from r100 to r103 on the trunk. Make these changes in the working copy (branches). Note that this “change set” will not include the changes made by r100, as they are captured by the set of changes needed to transition from r99 to r100. Subversion's change ranges are half open.

Also, consider this excellent guide if you have not already done so.

+6
source share

so that svn merge just replaces the content in the merge and not cause conflicts?

Well no. I can’t indicate what you did wrong, but merging flags conflicts with the update.

0
source share

Something may be missing for me, but when I used svn merge, I always had to get the revision numbers correctly if I wanted it to work correctly.

So, if you changed (or last merged) in revision 100, then the trunk is currently at level 200, and you want to merge the changes from the trunk into your branch, and then in the branch working directory:

 svn merge -r 100:200 trunkURL 

Then I think that you will see a conflict that you resolve and verify. You do a similar thing in the trunk working directory to merge with your branch back into the trunk.

svn merge without -r distinguishes between the two locations you specify and applies this diff to the working directory. Therefore, I assume that it happened that the conflict does not exist because your working directory matches the branch header. Thus, the difference between the head of the branch and the head of the torso can be applied to your working directory without any problems. This is not what you want to do: all he does is change your working directory to match the trunk. Try to make another change on the branch, register and repeat the process. If the merge cancels this change (because it is not on the trunk), then I am right about this form of svn merge, but, as I said, I did not use it.

[Edit: prior to svn version 1.5 ...]

Working directories and branches are not the same thing in SVN, and this is annoying as you have to consider the differences. SVN needs more information to perform branch merging than to update or check, because afaik does not automatically take into account where the branch occurred, since it always takes into account where the working directory was checked. I’m sure there is a reason for this, I just don’t know exactly what it is: it’s possible because the SVN copy is more than just branches.

[Edit ... but according to Joshua McKinnon on this answer, with 1.5 svn it supports the correct merges of branches that do what you want automatically. Specify the URL from which you are merging, and run the command in the working directory of what you are merging with. Therefore, in this case, try

 svn merge trunkURL 

and you should see the conflict. You may need to return the working directory first.]

0
source share

All Articles