views:

278

answers:

3

When SVN with merge tracking works, it's really nice, I love it. But it keeps getting twisted up. We are using TortoiseSVN. We continuously get the following message:

Error: Reintegrate can only be used if revisions 1234 through 2345 were previously merged from /Trunk to the reintegrate source, but this is not the case

For reference, this is the method we are using:

  1. Create a Branch
  2. Develop in the branch
  3. Occasionally Merge a range of revisions from the Trunk to the Branch
  4. When branch is stable, Reintegrate a branch from the branch to the trunk
  5. Delete the branch

I Merge a range of revisions from the trunk to the branch (leaving the range blank, so it should be all revisions) just prior to the reintegrate operation, so the branch should be properly synced with the trunk.

Right now, the Trunk has multiple SVN merge tracking properties associated with it. Should it? Or should a Reintegrate not add any merge tracking info?

Is there something wrong with our process? This is making SVN unusable - 1 out of every 3 reintegrates forces me to dive in and hack at the merge tracking info.

+1  A: 

Bunny hopping might be the solution.

Basically, instead of continuously merging trunk changes into a single branch (branches/foo, let's call it), when you want to pull those changes from trunk:

  1. Copy trunk to a new branch (branches/foo2).
  2. Merge in the changes from the old branch (merge branches/foo into branches/foo2).
  3. Delete the old branch (delete branches/foo).
Kevin L.
I'll look into that, but it seems pretty distasteful. If it's this difficult to manage branches, the value of SVN seems to be pretty low.
RandomUsername
Which is why I use git at home, and soon (when the Windows integration is a little bit better) at work. :-P
Kevin L.
+2  A: 

Your problem is that you're trying to use Reintegrate merge on a branch that has been 'corrupted' by having a 'half merge' already done on it. My advice is to ignore reintegrate and stick to plain on revision merging if this is your workflow.

However, the big reason you get errors is because SVN is performing some checks for you. In this case, if the merge has extra mergeinfo from individual files in there, then svn will throw a wobbly and prevent you from merging - mainly because this case can product errors that you might not notice. This is called a subtree merge in svn reintegrate terminology (read the Reintegrate to the Rescue section, particularly the controversial reintegrate check at the end).

You can stop recording mergeinfo when you perform your intermediary merges, or just leave the branch alone until its ready - then the merge will pick up changes made to trunk. I think you can also byass this check by only ever merging the entire trunk to branch, not individual files thus keeping mergeinfo safe for the final reintegrate at the end.

EDIT:

@randomusername: I think (never looked too closely) at moving is that it falls into the 'partial merge' trap. One cool feature of SVN is that you can do a sparse checkout - only get a partial copy of a tree. When you merge a partial tree in, SVN cannot say that the entire thing was merged as it obviously wasn't, so it records the mergeinfo slightly differently. This doesn't help with reintegrate as the reintegrate has to merge everything back to the trunk, and now it finds that some bits were modified without being merged, so it complains. A move appears kind of the same thing - a piece of the branched tree now appears differently in the mergeinfo than it expects. I would not bother with reintegrate, and stick with the normal revision range merge. Its a nice idea, but it trying to be too many things to too many users in too many different circumstances.

The full story for mergeinfo is here.

gbjbaanb
Thanks for the response. I have a better understanding of the subtree merge now, but I was at a loss as to why we were seeing it - we only merged at the top level, never at a sub-directory or file level. We were, however, performing some renames, which I believe to be the culprit. The page you linked to points this out, but leaves open their reasons for doing this odd behavior. I feel much better about SVN now that the oddness is at least determinable (renaming seems buggy) and fixable (remove merge info from renamed files).
RandomUsername
A: 

This problem sometimes happens when a parial merge has been done from trunk to branch in the past. A partial merge is when you perform a merge on the whole tree but only commit part of it. This will give you files in your tree that have mergeinfo data that is out of sync with the rest of the tree.

The --reintegrate error message above should list the files that svn is having a problem with (at least it does in svn 1.6).

You can either:

  1. Merge the problem files manually from trunk to branch, using the range from the error message. Note: you must subtract 1 from the start of the range, so the command you'd run would be: cd svn merge -r1233:2345 svn commit or

  2. If you're certain that the contents of the files in your branch are correct and you just want to mark the files as merged, you could use the --record-only flag to svn merge: cd svn merge --record-only -r1233:2345 svn commit

(I think you can use --record-only on the entire tree, but I haven't tried it and you'd have to be absolutely sure that there are no real merges that need to come from trunk)

Gruff