49

Per this old question, using SVN 1.5, reintegrating a branch multiple times is problematic, and should be avoided.

There has been some rumbling to the effect that, "This is a known issue, and should be fixed in SVN 1.6." Was that the case? Is it fixed? Can I reintegrate multiple times?

Community
  • 1
  • 1
Andres Jaan Tack
  • 22,566
  • 11
  • 59
  • 78
  • Let's be more specific. For the purposes of this question, I don't care whether I _should_ be reintegrating. That's a different question. For now, I want to know _how_ to reintegrate multiple times. – Andres Jaan Tack Jul 23 '10 at 08:20
  • Yes, it was fixed in Subversion 1.8. – bahrep Jan 15 '16 at 09:56

3 Answers3

57

To merge a branch topic into the trunk repeatedly: Do the following on every merge.

  1. svn merge --reintegrate <topic> <trunk>, as you would normally. (=> rM)
  2. svn merge --record-only -c M ^/<trunk> <topic>. Note the record-only option.

Step 2 essentially tells the topic branch to consider the merge commit (revision M, from step 1) part of its history. This merge-revision is the one that usually causes problems during reintegration; svn tries to undo rM when integrating topic a second time.

So, repeated reintegration works, just not automatically. :)

I eventually found this solution through an enlightening commit message to the svn source and the matching test (search for "def multiple_reintegrates"). This is a "clever trick" discovered and used by svn-devs with the current releases. It's even been added to more recent documentation. The result is still not as good as a DVCS's merging properties, but it's at least functional.

The only broad downside (as per an open issue as of June 2, 2010) is that apparently the svn log -g output is messy. I guess this is the risk.

Andres Jaan Tack
  • 22,566
  • 11
  • 59
  • 78
  • 3
    They eventually added this to the docs: http://svnbook.red-bean.com/nightly/en/svn.branchmerge.advanced.html#svn.branchmerge.advanced.reintegratetwice – JW. Jul 22 '10 at 21:51
  • 1
    Holy crap. That explanation would have been so much easier to parse. I've added it to the answer. A+ – Andres Jaan Tack Jul 22 '10 at 21:56
  • Can this handle merging from trunk into the branch (as well as vice versa)? I.e., --record-only the trunk->branch merge as well? – JeeBee Apr 24 '13 at 08:30
2

Yes, you can. The problem you ask about was solved in Subversion 1.8.

Beginning with SVN 1.8, --reintegrate option is deprecated and reintegrate merges are now performed automatically (or automagically :) ). See Subversion 1.8 Release Notes and read updated SVNBook 1.8 | Reintegrating a branch chapter:

If you choose not to delete your branch after reintegrating it to the trunk you may continue to perform sync merges from the trunk and then reintegrate the branch again. If you do this, only the changes made on your branch after the first reintegrate are merged to the trunk.

...

Only Subversion 1.8 supports this reuse of a feature branch. Earlier versions require some special handling before a feature branch can be reintegrated more than once. See the earlier version of this chapter for more information: http://svnbook.red-bean.com/en/1.7/svn.branchmerge.basicmerging.html#svn.branchemerge.basicmerging.reintegrate

IMPORTANT: You should upgrade your Subversion client and server if you still use Subversion 1.7 or older. The current and best version of SVN is 1.9 as of year 2016. There is no real reason to be using very old Subversion releases such as 1.5, 1.6 or even 1.7. There were numerous improvements on client and server side since version 1.6!

bahrep
  • 29,961
  • 12
  • 103
  • 150
1

While 1.6 did indeed fix issues with merge tracking, I don't think you can re-use an integrated branch.

But this is not an issue. Since the branch got fully integrated into the trunk, just delete it and create a new branch (with the same name) in its place.

sbi
  • 219,715
  • 46
  • 258
  • 445
  • @Andres: How do you propose I find references that a certain thing (the ability to repeatedly reintegrate) does _not_ exist? The SVN book 1.5 says reintegration renders a branch useless (at the end of http://svnbook.red-bean.com/en/1.5/svn-book.html#svn.branchemerge.basicmerging.stayinsync). Free free to browse the release infos for SVN 1.6 (http://subversion.apache.org/docs/release-notes/1.6.html and http://svn.apache.org/repos/asf/subversion/tags/1.6.12/CHANGES) for anything rendering this information stale. – sbi Jul 22 '10 at 18:53
  • 2
    "I don't think you can..." isn't very credible. An example, an updated reference, something that isn't a book on v1.5... – Andres Jaan Tack Jul 22 '10 at 20:21
  • @Andres: So all this just to avoid an `svn delete`, followed by an `svn copy`. What does it buy you? I have no idea why you're so worked up about it. – sbi Jul 22 '10 at 22:45
  • 1
    Delete+copy doesn't work for a maintenance branch. Suppose I have a mainline (trunk) and a 1.0 branch. I don't want _most_ of the things in the trunk, but I certainly want to forward-propogate v1.0 bugfixes. This calls for repeated reintegration of one of the branches. – Andres Jaan Tack Jul 22 '10 at 23:23
  • 1
    @Andres - I think you are confusing simple merging and reintegration. In a release branch (1.0) forward propagating bug fixes to trunk is fine, this does not require reintegrating the branch - It is simply a merge of certain revisions. – Joshua McKinnon Jul 23 '10 at 00:40
  • 1
    This post is the svn merge bible for me and may shed some light: http://blogs.open.collab.net/svn/2008/07/subversion-merg.html While 1.6 did some cleanup on cases that mergeinfos are created, I don't think it alters how --reintegrate merges work. You typically only reintegrate feature branches. The rest are plain old merges, tracked fine by both 1.5 and 1.6. – Joshua McKinnon Jul 23 '10 at 00:44
  • 1
    @Andres: What you describe is not reintegrating, it's cherry-picking bugfixes. – sbi Jul 23 '10 at 06:57
  • @sbi Not if the changes go both ways. Like I say, I don't want _most_ of the trunk. That's not to say I don't want _any._ – Andres Jaan Tack Jul 23 '10 at 08:10
  • @sbi Actually, you're right, you can do what I'm describing with cherry-picking. However, that was not the question. :) – Andres Jaan Tack Jul 23 '10 at 08:16
  • @Andres: And the question is fully answered with "you don't need to be able to continue using a reintegrated (feature) branch, just create a new one". (And, BTW, while certainly _unnecessary_, I don't see why this should not be _possible_ to do with a release branch.) – sbi Jul 23 '10 at 08:59
  • @Joshua McKinnon: Your SVN merge bible is now a 404. – Peter Mortensen Dec 03 '16 at 09:46
  • @PeterMortensen link rot :( http://blogs.collab.net/subversion/subversion-merg seems to be the new URL - however, I should note - as reintegration is now automatic in SVN 1.8+ so the post may be growing a bit out of date. (See: http://subversion.apache.org/docs/release-notes/1.8.html#auto-reintegrate) – Joshua McKinnon Dec 03 '16 at 19:16