Personal tools
You are here: Home / Documentation / Extending Biskit / SVN Howto

SVN Howto

How to use Subversion

Changing, adding, removing files

  • creating a complete local copy of the project into the current directory

    > svn co svn://my.host.com/path/to/repos/project/trunk
    

    The address depends on the SVN server setup. A http:// address served by apache is perhaps the most common setup. See also <http://svnbook.red-bean.com/nightly/en/svn.serverconfig.svnserve.html#svn.serverconfig.svnserve.invoking>

  • commit changes to the server

    1. update local copy to include all changes on the server and check for clashes

      > svn update
      

      (checks all files in current dir and sub directories, ignores empty directories)

    2. commit new version to server

      > svn ci
      
  • add new file to the project

    > svn add file-name
    > svn ci
    
  • remove file

    > svn rm file-name
    > svn ci
    

    In contrast to CVS, the file is also removed from your local folder.

Inspect changes

  • display all locally modified files:

    svn status
    
  • display local and remote modifications:

    svn status -u
    

    Note:

    status -u will also report any file that doesn't exist in the repository, including things like *pyc and *py~. To ignore the latter two file types, edit ~/.subversion/config and add / uncomment the following line:

    [miscellany]
    global-ignores = *.o *.lo *.la #*# .*.rej *.rej .*~ *~ .#* .DS_Store *.pyc
    
  • compare a working copy with the checked in version:

    svn diff yourfile.py
    

Track statistics inside files

  • Add the following lines as comments to your source code:

    $Author$      ... inserts last author
    $Date$        ... inserts last date
    $Revision$    ... inserts last revision, or alternatively...
    $Id$          ... inserts 1-line summary of file name, date, revision, author
    

    Unlike in CVS, you explicitely have to activate keyword replacement for a file:

    svn propset svn:keywords "Date Author Revision Id" myfile.py
    

    But the latter can be automatted in the svn configuration. Add or uncomment the following lines in the appropriate section of ~/.subversion/config:

    [miscellany]
    enable-auto-props = yes
    
    [auto-props]
    *.py = svn:keywords="Date Author Revision Id"
    *.txt = svn:keywords="Date Author Revision Id"
    
  • See also: <http://svnbook.red-bean.com/nightly/en/svn.advanced.props.html#svn.advanced.props.special.keywords>

Troubleshooting:
If you are sitting on a non-English system, subversion may insert special characters into the $Date: $ string of Biskit python files and you will get something like "SyntaxError: Non-ASCII character in ...". Define an environment variable LC_ALL=C to circumvent this problem.

Handle binary files

In contrast to CVS, SVN does not require special handling of binary files.

Passwordless SVN

Depends on the svnserve setup. See also: <http://svnbook.red-bean.com/nightly/en/svn.forcvs.auth.html>

Branches

  • creating a new branch:

    svn copy https://graik@svn.code.sf.net/p/biskit/code/trunk \
             https://graik@svn.code.sf.net/p/biskit/code/branches/devel
    

    This creates a new branch 'devel'. Your local working copy remains untouched and you are still working with the trunk.

  • switch current working copy to branch 'devel':

    cd biskit/
    svn switch  https://graik@svn.code.sf.net/p/biskit/code/branches/devel
    

    Note:

    • local modifications (changes that are not yet checked into any branch) remain untouched and can now be checked into the new branch
    • recent commits to the old branch (from which you are switching) will be reverted, e.g. a file that has been added to the old branch after the creation of 'devel' will be deleted.

    You can repeatedly switch to a branch, make and commit changes, switch back to the trunk (at which point your changes will be reversed), make and commit changes to the trunk, and switch over again.

  • create a new working copy from a branch:

    svn co https://graik@svn.code.sf.net/p/biskit/code/branches/devel
    
  • copy changes from one branch to another

    Let's assume we want to 'merge' the changes in branch devel back into the trunk:

    cd biskit
    svn switch  https://graik@svn.code.sf.net/p/biskit/code/trunk
    svn merge https://graik@svn.code.sf.net/p/biskit/code/trunk \
              https://graik@svn.code.sf.net/p/biskit/code/branches/devel
    

    This will apply all changes from the devel branch as local modifications into your current working copy (which should be a clean checkout of trunk to avoid confusion).

    Note: The first branch is the destination branch and should correspond to your local copy.

    Once you have reviewed the changes, you can commit them into the trunk branch:

    svn ci -m 'ported all changes from devel rev xx into trunk'
    

    It is recommended to mention 'ported' and the revision numbers in the log message because svn itself doesn't keep track of what has been copied when.

  • copy recent changes in trunk into a branch:

    That's a bit more tricky because the simple merge of trunk into branch would actually revert all those valuable work that you have done in that branch. Here is how it works. Let's assume you have created a branch devel2 at revision 700. At revision 710 somebody has fixed a bug in the trunk and later (revision 715) there were some other improvements to the trunk. You want to continue working with your devel2 branch but, at the same time, want to merge the trunk changes into your branch. This is how it works:

    cd biskit_devel2/   ## checkout of your branch
    svn merge -r 700:720  https://graik@svn.code.sf.net/p/biskit/code/trunk .
    

    This merges the changes done between r 700 and 720 into your current working copy. Review, and commit. If you have to resolve conflicts, don't forget to delete the *.merge* and *.working files. Otherwise you will get a "still in conflict" error.

Tagging

  • tag the current version of biskit:

    svn copy https://graik@svn.code.sf.net/p/biskit/code/trunk \
             https://graik@svn.code.sf.net/p/biskit/code/tags/release-0.1 \
             -m "Tagging the 0.1 release of biskit"
    

Revert changes

  • retrieve a previous version of a file:

    svn update -r 123 yourfile.py
    

    Note, this will merge version 123 into your working copy of yourfile.py. SVN will not allow you to commit modifications to this file though.

  • revert changes that are already checked in:

    Let's say you want to undo changes to yourfile.py that were checked in as revision 123 and revert it to the state of revision 100. This is done by a "reverse merge":

    svn merge -r 123:100 https://graik@svn.code.sf.net/p/biskit/code/trunk
    

    This will create a new working copy of yourfile which lacks the changes from rev. 100. You then still need to check in this new modified version:

    svn ci yourfile.py -m 'reverted changes from revision 123'