Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Subversion Branch/Trunk Best Practice - keeping Branch Up-to-Date?

Tags:

svn

My development team has worked with subversion for quite some time. The way that manage the trunk and branches is as follows:

  • We (almost) always release from the trunk

  • Each release gets its own branch.

  • When a release is ready for QA, we merge the branch back into the trunk and create a new branch for the next release.

  • Developers work off of either the trunk or the branch, but there are no developer-specific branches.

Lately, we have had some nightmare merging sessions, in part due to some major changes to the application. These don't always go smoothly and issues sometimes pop-up during QA where subversion did not merge quite right.

One solution might be to merge trunk changes into the release branch on a regular basis, say weekly, to ensure that the most up-to-date trunk changes are in the branch. Conflicts can then be fixed in closer to real-time.

What is your experience with this issue? Is there a standard best practice? Also, do you have a good way of keeping track of which revisions have been merged into the branch (decent comments in subversion could probably handle that).

like image 579
jonstjohn Avatar asked Feb 20 '09 15:02

jonstjohn


2 Answers

Firstly, I don't think there's a one-size fits all solution when it comes to managing code branches and releases. But to touch on a few of your points from my perspective:

  • Yes, I would merge changes from trunk into the release branch more often. Smaller chunks are always going to be more manageable than one large integration. And of course this means you're working against the latest most stable code.

  • Proactively teach people how to merge well. The developer who made the change should be doing (or be closely involved with) the merge. Understand what it is you are taking and what it should look like when it is finished. I too often see people run a integration without really knowing what they are doing and what they are expecting as the result.

  • Perhaps you want to have an integration branch that isn't trunk. This can be tested daily and any issues caught here before they go and break trunk and scare everybody.

like image 67
Andy Hume Avatar answered Sep 22 '22 08:09

Andy Hume


So assuming I've got your model right here: You develop major changes to the project in a branch (off of trunk) which can get quite old.

You continue to do other development on trunk which always holds the 'live' software, so these changes are minor updates and bug fixes. You're getting problems when you merge the monumental development branch back into trunk.

You can only effectively manage 2 concurrent product versions with that model, which may be enough for now, but might bite you in other ways anyway and will get worse if you ever need to manage 3 or 4 versions. Can I suggest inverting the way you work?

Have a Version branch for each release. This should be branched from trunk (at any revision). The only way you modify the version branch is to merge in revisions from trunk.

This means you can work primarily on trunk instead of in a large development branch. You also apply your bug fixes directly to trunk - so you've got no major integration issues being stored up for the next release. To release bug fixes to the previous versions, just merge the required trunk revisions into the appropriate Version branch.

This way you can keep everything you want to release in branch, but only actually ever release what you're happy with, because that's all you merge in to the version branch.

You can still take development branches if you need, but you can keep them targetted and small, perhaps individual features rather than large projects.

This will allow you to manage multiple versions in a sane way and keep a good track of what's in each release using svn's merge-info.

like image 24
Jim T Avatar answered Sep 21 '22 08:09

Jim T