2011-04-18

Subversion - Branching and merging to release, stable or something else

Previously, we talk about the basic stuff of Subversion. This is still basic stuff :p


Is about managing source codes by branching. Branching is a way to have 2 or more sets of source code with each has it's own development, but eventually, merging them into the main trunk.

Example, in most development, we normally have "development" & "release" version. As word means, the "development" version is meant for development & testing. But the "release" version, would be the ultimate version that roll out for production use. For this example, "release" will be the trunk & "development" will be the branch.

A view of it :

web_blog(repository)
   |
   +release
   |  |
   |  +front_end
   |  |
   |  +engine
   | 
   | 
   +development
      |
      +front_end
      |
      +engine



To create this hierarchy :
  1. cd /home/user/svn_repositories
  2. svnadmin create web_blog
  3. svn mkdir file:///home/user/svn_repositories/web_blog/release
  4. svn import /home/user/web_blog_initial_source_code \
    file:///home/user/svn_repositories/web_blog/release
  5. svn copy file:///home/user/svn_repositories/web_blog/release \
    file:///home/user/svn_repositories/web_blog/development
The last command actually copy the "release" directory as "development" directory within subversion repository.


Usually, the cycle of branching & merging of codes looks like this :
  1. To work on "development" branch, do a usual checkout from the development branch, e.g.
    svn checkout file:///home/user/svn_repositories/web_blog/development
  2. Then work on the code in "development" branch working copy
  3. Commit as usual, e.g.
    svn commit -m "The codes are ready for production"
  4. Test the codes in devel branch until it is stable and ready for release
  5. When the code is ready to merge with release trunk, checkout a copy from "release" trunk, and cd into it. MAKE SURE the current directory is in the root of "release" working copy!
  6. Merging the "release" code with "development" code, e.g.
    svn merge file:///home/user/svn_repositories/web_blog/development
  7. To check out what are the file changes :
    svn status
  8. Finally, commit the merge, e.g.
    svn commit -m "Merging the development codes"
Usually, repeat step 2 for further development cycle.

Hasta la vista !!!

ref : The Subversion Book, legally free online

No comments: