If you always synchronise a feature branch before you merge it back. Why do you really have to use the --reintegrate
option?
The Subversion book says:
When merging your branch back to the trunk, however, the underlying mathematics is quite different. Your feature branch is now a mishmosh of both duplicated trunk changes and private branch changes, so there's no simple contiguous range of revisions to copy over. By specifying the --reintegrate option, you're asking Subversion to carefully replicate only those changes unique to your branch. (And in fact, it does this by comparing the latest trunk tree with the latest branch tree: the resulting difference is exactly your branch changes!)
So the --reintegrate
option only merges the changes that are unique to the feature branch. But if you always synchronise before merge (which is a recommended practice, in order to deal with any conflicts on the feature branch), then the only changes between the branches are the changes that are unique to the feature branch, right? And if Subversion tries to merge code that is already on the target branch, it will just do nothing, right?
In a blog post, Mark Phippard writes:
If we include those synched revisions, then we merge back changes that already exist in trunk. This yields unnecessary and confusing conflicts.
Is there an example of when dropping reintegrate gives me unnecessary conflicts?
Let me explain when
--reintegrate
is absolutely necessary.Consider the following use case.
readme.txt
, with one line "line1"<readme.txt
and commit it to trunkp1/branches/br1
branch. Update to HEAD.line1
andline2
inreadme.txt
p1/branches/br1
branchp1/branches/br1 to trunk.
line1
,line2
andline2
inreadme.txt
. So, you have "line2" two times which is incorrect. SVN does not show any conflicts. So, it is very dangerous because merge performed with no errors and you are under impression that everything is fine.The solution here is that the step 9 merge should be done using the
--reintegrate
option. The reintegrate option tells SVN to comparebr1
with trunk and apply onlybr1
changes to trunk. In this particular case we have not done any changes inbr1
. The result in trunk should be two lines "line1" and "line2".Another useful remark. Branch
p1/branches/br1
should not be used for development after step 9 anymore. If you want to continue development in branches, create a new branch, for example,p1/branches/br2
. Another merge from trunk top1/branches/br1
causes lots of conflicts.