Log In | Users | Register
Edit | Attach | New | Raw | Diff | Print | | Tools
You are here: Data » DocTools » ToolsCtrl » CtrlSvn » SvnMch

SVN: misc

SVN is a tool to manage versions of source code or any other documents/files. Two features are of main interest for us: Firstly the ability to easily retrieve the newest or any older version of the source code, and secondly to ease the collaboration between several developers and the user doing the common istallations, in our case osm. The source code is stored in a common directory, called "repository". Users of SVN only access the repository through svn commands.

Note that SVN is not officially used in MO yet and these pages are meant solely as a sandbox for any future official documentation!

Good practice

  • Always base your branches on a single trunk or vendor version. Do not merge new trunk or vendor versions into your branch. Instead, create a new branch based on the new version and merge your branch changes into it. Like that, you always have a full delta of your changes with respect to an trunk or vendor version.

  • Put the base version of your branch in your branch name. Since branches should be based on a single trunk or vendor version, this version number should appear in the name of the branch to make things clear. For example, if you are making changes with respect to trunk tag cosmo_4.7.6 you should name your branch cosmo_4.7.6_hdiff.

  • Always try to merge the smallest delta to avoid conflicts. For example, if you want to merge a new vendor version onto the trunk, it is usually easier to create a temporary copy of the vendor version, apply the differences of the trunk with respect to the last vendor version to the temporary copy and, once all conflicts have been resolved and the new version has been tested, move the new version onto the trunk.

Other documentation

How to create your own personal SVN repository and import a project

  1. Create a repository using svnadmin create /users/olifu/src/SVN.
  2. Set the environment variable to point to your repository setenv MYSVNROOT file:///users/olifu/src/SVN (you could put this in your .cshrc).
  3. Create a directory for your project svn mkdir $MYSVNROOT/project and enter a comment describing the project.
  4. Import your project into the trunk using svn import project_1.0 $MYSVNROOT/project/trunk where project_1.0 is a local directory containing your project.
  5. If everything went well, remove your local copy of the project using rm -r project_1.0
  6. Create a directory which contains the tags of the releases of your project using svn mkdir $MYSVNROOT/project/trunk_tags and give a comment describing the action.
  7. Create a tag for the version of the project you have just checked in using svn copy $MYSVNROOT/project/trunk $MYSVNROOT/project/trunk_tags/project_1.0 and give a comment describing this release.
  8. Checkout a working copy of the trunk from the repository using svn co $MYSVNROOT/project/trunk project_wc
  9. Make some changes/improvements to your project and test them extensively. You can use svn status inside the project directory to check which files have changed in some manner.
  10. Once you are satisfied with your changes and have tested them, you can commit the changes using svn commit inside the project directory.
  11. If you want to create a new release, you can use svn copy $MYSVNROOT/project/trunk $MYSVNROOT/project/trunk_tags/project_1.1.

How to manage official distribution of COSMO code from ECMWF repository

The official release of the COSMO code resides in a vendor branch of the SVN repository under $SVNROOT/lm/vendor and the official releases are saved as tags in $SVNROOT/lm/vendor_tags for each official release.

Importing the official release for the first time

  1. First unpack a release of the official code (say lm_f90V3_22.tar.gz) at a temporary location using tar xvfz lm_f90V3_22.tar.gz
  2. Import the code into the SVN using svn import lm_f90V3_22 $SVNROOT/lm/vendor
  3. Remove your local copy using rm -rf lm_f90V3_22
  4. Checkout a working copy from the SVN repository using svn co $SVNROOT/lm/vendor lm_wc
  5. cd lm_wc/src
  6. Set keyword properties for all source files using svn propset svn:keywords "Revision Date" *
  7. cd ..
  8. Commit all changes using svn commit
  9. Remove your working copy using rm -rf ../lm_wc
  10. Make a tag for this official release using svn copy $SVNROOT/lm/vendor $SVNROOT/lm/vendor_tags/lm_3.22 and comment it with "official 3.22 release"

Updating the official release when a new version is released

Instead of following the step-by-step instructions below, you may also use the following ready made script which does everything automatically.

  1. Checkout a working copy from the SVN repository using svn co $SVNROOT/lm/vendor lm_wc
  2. cd lm_wc
  3. Remove all files (but not directories) using \rm -f * */*
  4. cd ..
  5. Now de-tar new release (say lm_f90V3_28.tar.gz) using tar xvfz lm_f90V3_28.tar.gz
  6. cd lm_f90V3_28
  7. Copy files into checked-out version tar cvf - * | ( cd ../lm_wc; tar xvf - )
  8. cd ..
  9. \rm -rf lm_f90V3_28
  10. cd lm_wc
  11. List status of files using svn status
  12. Add all files not under version control (marked by ?) using =svn add =_filename_
  13. Remove all files that have been removed in new version (marked by !) using =svn delete =_filename_
  14. Check that status of all files is modified (M), deleted (D) or added (A) using svn status
  15. If everything is ok, commit the changes using svn commit
  16. Remove your working copy \rm -rf lm_wc
  17. Make a tag for this official release using =svn copy $SVNROOT/lm/vendor $SVNROOT/lm/vendor_tags/lm_3.28

FAQ

  • Say I checked out a working copy and accidently removed some of the .svn stuff. Now when I issue an svn status I get a status of ? and when I try to commit I get an Commit failed and Unable to lock. What to do?

Answer: If you don't necessarily want to keep the modifications you did after you checked out, simply remove ( rm -rf) the concerned directory you are working on and update it from the parent directory using svn update. This will create the .svn directory again. If you want to keep your modifications, first copy the concerned directory in another location. Then remove the directory and update it from the parent directory (as above). Finally copy the content of the copied directory in the updated directory again and check the status. (See svnbook page 17).

  • Say I created a branch from COSMO version 4.7.1. Now I've made some changes in the branch. Since I still would like to develop further, but the trunk is already at version 4.7.6 I decide to merge in the changes from the trunk into my branch. I develop further and now the results look really cool. Now in order to send my changes to DWD I need to apply my changes to the official COSMO version 4.11. But I have no clean diff which reflect my changes since the changes of my developments are mixed with the update from 4.7.1 to 4.76. How to solve this problem?

-- OliverFuhrer - 2009-11-11 spacer

This site is managed by the Center for Climate Systems Modeling (C2SM).
This site is powered by FoswikiCopyright © by the contributing authors. All material on this collaboration platform is the property of the contributing authors. Ideas, requests, problems? Send feedback!