Question

I have a trunk (A) and two branches (B and C). When I merge A with C its OK, after I merge A with B, the previous C its overwriten and my trunk don't have the C changes.

What I want is A + B + C into trunk after merges.

Edited for more explanation:

  1. In trunk I have 3 files: "FILE 1", "FILE 2" and "FILE 3";
  2. I create a branch from trunk as "Branch 1";
  3. I switch to "Branch 1", I fix bugs into "FILE 1" file and commit;
  4. In the same time, another person create a branch from trunk as "Branch 2";
  5. This person fix another bugs into "FILE 2" and "FILE 3" files and commit;
  6. The "Branch 2" is approved for publish, then I merge "Branch 2" to "trunk" (its ok);
  7. In next day the "Branch 1" is approved, then I merge "Branch 1" to "trunk", and the "trunk" lose the changes from "Branch 2".
Was it helpful?

Solution

  1. Make a working copy of trunk
  2. svn merge -r W:X svn://branchA workingCopy
  3. svn merge -r Y:Z svn://branchB workingCopy

I think this will give you what you want, which is the trunk plus any changes made by either branch. You will have to deal with conflicts, however.

OTHER TIPS

Assuming you're using Subversion 1.5 or greater, I think you want to "reintegrate" your branches back to the trunk, see http://blog.red-bean.com/sussman/?p=92

Your terminology is not clear. When you say you "merge A with B" does that mean you merge A into B or B into A? Can you explain exactly what you did to create the branches, and how you attempted to do the merging? Also, for merging it's important which SVN version you're using.

I suggest you carefully read the chapter on branching and merging in the SVN book.

Basically, when you have a feature branch (which is what you seem to have), you repeatedly merge the branch into it. SVN then logs which revisions you merged and won't merge them again. When you're done with your branch, you reintegrate it into the trunk and dismiss it.

All this is done on your disk, one branch at a time, resolving potential conflicts after each branch, and checking in each step. (If for some reason you need to apply the changes to the trunk in one checkin, you can merge your branches into a fresh branch off the trunk and then merge that branch into the trunk when you're done.)

You want to apply the merges to your workspace, not the repository. Alternatively you can use cvs which deals with branches in a far superior way than svn does.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top