Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to setup SVN repo for emergency fixes?

Being a developer for a number of years this is something I should know but don't.

I am working on a released product on a small team. I am the main developer committing most of the code but there are a couple other developers that commit from time to time. Currently, we have a staging server running Hudson CI that builds after every commit. Production is updated manually by a simple svn up command when the trunk is stable and tested.

This has generally worked fine except we do have situations requiring emergency/urgent changes to production when code is not finalized in the trunk.

How can I setup the repo to accommodate this situation? I thought this response was a good reply but it is still a little over my head.

I am thinking, when updating production, create a branch at that revision. However, if I need to make urgent production fixes, how do I access that branch and how can I update production by pulling from that branch and not trunk? How do I make sure that any urgent fixes for the production branch are also committed to the trunk?

ie. this is the situation I want to have a better solution for because it has occurred a few times

  • Rev 1000 is updated on production
  • Rev 1001-1005 are new feature requests/bug fixes that will be included in the next version
  • Rev 1006 is an urgent fix that needs to be pushed to production
  • Rev 1007-1009 are more feature updates
  • Rev 1010 should be the next revision updated to production

Update:

After reading through the branching section of the SVN Book, I am thinking about the following setup.

  1. Create branch when ready to push to prod

    svn copy /trunk /branches/production_01 -m 'Production release'

  2. On production, do a switch to the production branch

    svn switch /branches/production_01

  3. If an urgent fix is needed, developer needs to make changes in branch:

    svn checkout /branches/production_01
    // make changes
    svn merge /trunk # make sure changes get merged into trunk as well
    svn commit -m 'Urgent fix

  4. On production, update to the latest branch

    svn update

Does this process sound like it would work for our setup?

like image 263
Matt McCormick Avatar asked Feb 05 '11 01:02

Matt McCormick


1 Answers

Creating a new branch every time in order to get ready to release to production is necessary in large teams where people still want to check in new features for future releases while you are trying to stabilize for this release. Unless you are supporting more than one production release at a time, that's not really necessary on a small team.

In your situation I would keep one permanent production branch. Whenever you do a normal release, get it stabilized in trunk, merge trunk into production, and test and push from there.

For a hotfix, create a new branch from production1, make your changes in there, then merge it both into production and trunk. As with your normal release, you test and push from production.


1 Always branch from the oldest branch you intend to merge back into. It makes the merge much cleaner.

like image 161
Karl Bielefeldt Avatar answered Oct 07 '22 19:10

Karl Bielefeldt