Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Consequences of not using --reintegrate with svn merge back to trunk

Tags:

svn

I'm new to subversion. Over the last month I had done some changes and merged them to trunk. Everything seemed fine - my changes got propagated as expected. But today I was re-reading about merging and saw this, saying the following when merging your changes back to trunk:

Now, use svn merge with the --reintegrate option to replicate your branch changes back into the trunk.

and a few paragraphs later:

Notice our use of the --reintegrate option this time around. The option is critical for reintegrating changes from a branch back into its original line of development—don't forget it!

I guess I hadn't read things carefully enough the first time around.

So, it seems I made a mistake with my previous merges back to trunk because I hadn't used the --reintegrate option. What are the consequences of this? Is there something I need to fix?

In case it's useful, my work flow had looked like this:

  1. Copy from trunk to create a personal branch.
  2. Check out the personal branch.
  3. Changes and commits.
  4. Get a working copy of trunk.
  5. Merge my branch to the working copy of trunk (again, without --reintegrate).
  6. Commit the merge.
  7. Delete my branch.
like image 547
firebush Avatar asked Jul 27 '12 16:07

firebush


People also ask

Do I need to commit after merge svn?

It never should have been committed. You can use svn merge to “undo” the change in your working copy, and then commit the local modification to the repository. All you need to do is to specify a reverse difference.

Does svn merge delete the branch?

If you merge a branch into trunk using "svn merge --reintegrate", you are recommended to delete the branch. If you want to do further development in that branch, you should "re-branch", effectively create a new branch with the same name, but rooted at the same revision as you merged the branch into trunk.

What is a sync merge in svn?

The complete merge is used for the 'sync' and 'reintegrate' merges in the 'feature branch' pattern described below. It finds all the changes on the source branch that have not already been merged to the target branch, and merges them into the working copy.


1 Answers

Your workflow is fine if your branch is very short-lived.

If it has a longer life, you'll want to regularly merge changes from the trunk into your branch, to avoid being disconnected from the main branch of activity.

In the end, your feature branch will contain every change from the trunk since you created the branch, + the new feature you developed in the branch. At this time, you need to use the reintegrate option, because it would be wrong to apply the changes of your branch to the trunk: it would reapply changes that are already in the trunk, since they originate from it.

This is well covered in the section of the SVN book about feature branches.

like image 120
JB Nizet Avatar answered Sep 24 '22 23:09

JB Nizet