Wednesday, February 9, 2011

How do I use the new SVN merge-tracking?

In my existing (Pre-SVN 1.5) merge strategy, we create a copy of the Trunk (called BasePoint) at the moment of branch-creation for referencing later during the merge.

When we need to merge a branch back into the trunk, we perform 2 operations.

  1. Merge from BasePoint to LatestTrunk (Trunk has likely moved on since the original branch) into Working copy of Branch and then commit.

    At this point we typically check that the merge into the branch has not damaged anything

  2. Merge from LatestTrunk to LatestBranch back into Working copy of trunk and then commit.

Documentation suggests that I use the new reintegrate merge on the Trunk and Merge from the Branch.

Do I need to merge from the trunk into the dev branch first or is this included in the new reintegrate option?

To put it another way, does the new merge --reintegrate functionality represent 'each of my previous merges' or 'the whole operation' ?

(FWIW I am using TortoiseSVN 1.5.1)

  • I believe reintegrate does not actually do the two operations, but instead is used to merge back into trunk from an updated branch. You will still need to do the first set of merge/commit operations to update the branch first.

    Here is a link to the Subversion Book. It is possible to get this book in dead tree format.

    From the link, it sounds like using --reintegrate handles some weird cases, probably like merge usually does compared to just using straight patches (read the section "Why Not Use Patches Instead?").

  • The short answer is, You still have to do both steps.

    The SVN book explains the process for merging as:

    1. svn merge http://trunk/path while in a branch working copy
    2. svn merge --reintegrate http://branch/path while in a trunk working copy

    Notice the lack of revision numbers. This probably doesn't feel like a huge win. The new coolness is the ability to re-run the merge as you are coding in your branch, allowing you to keep the branch up to date with changes in trunk (without recording revision numbers by hand!). SVN keeps track of what needs to be merged in from trunk and what changes are unique to the branch. When you are done with the branch, --reintegrate uses that data to automatically merge only the branch changes back to trunk.

    From Nate Green
  • A good blog post about merging problems in svn (and what reintegrate does) is here.

    From teki

0 comments:

Post a Comment