Log In | Users | Register
All about IT at IAC
spacer
Edit | Attach | New | Raw | Delete | History | Diff | Print | Pdf | | Tools
You are here: IT » ServiceSvn

How to use Subversion

Get a repository

The Subversion repositories are stored and accessible on https://svn.iac.ethz.ch. You can ask for a user repository which will be only accessible by you. Or you can ask for a project repository which can be accessible by other users too. If your repository should be accessible without authentication (anonymous read access) ask for a public repository. Send a mail to urs.beyerle@env.ethz.ch to ask for a new repository.

For a project and public repository the following information is needed:

  • (Folder) name of the repository.
  • Usernames of the users that have access to the repository. You may want to distinguish between read and write access.
  • For external users (not ETH members), please provide their name, email address and a possible username.

It's possible to enable email notification for repositories. If enabled, the users will get an email in case something was changed in the repository (file added, file modified, etc).

Location of repositories

  • Repositories can be found under https://svn.iac.ethz.ch/repos/
  • The repositories are located in following folders
    • users: Repositories related to a IAC user (only the owner will have access to his repository)
      • https://svn.iac.ethz.ch/repos/users/username - this is the standard repository for a user
    • projects: Repositories related to a project (several users may have access to these repositories)
      • https://svn.iac.ethz.ch/repos/projects/projectname - each project has its own repository
    • pub: Public repositories which can be read by everybody (anonymous user)
      • https://svn.iac.ethz.ch/repos/pub/projectname - each project has its own repository

Browse the repositories

You can browse the repositories with a normal web browser. Two different views are available:

Subversion clients

  • Linux: svn command line tool.
  • Windows: TortoiseSVN download at tigris.org
  • Mac: SvnX

Access the repositories with WebDAV

With WebDAV you can access the repository like a normal file system. If you remove, add or modify a file, a new revision of your repository is automatically created.

  • Linux: Use konqueror and point it to webdavs://iacsvn.ethz.ch/repos/path_to_your_repo
  • Windows: Use Internet Explorer

Email notification

  • It's possible to setup email notification for a repository. In case you would like to enable email notification contact iac-it@env.ethz.ch

Working with Repositories using svn command

  • To checkout (co) your repository into a folder (my_repo), type
    svn co https://svn.iac.ethz.ch/repos/users/beyerleu my_repo 
    
    Now you have a so called working copy of your personal repository in the folder my_repo

  • You can also checkout only one folder of your repository, for example
    svn co https://svn.iac.ethz.ch/repos/users/beyerleu/matlab matlab
    

  • You may want to check out your project repository into a local folder having the same name as the repository
    svn co https://svn.iac.ethz.ch/repos/projects/projectname projectname
    

  • The above commands will checkout the latest revision. In case you want to checkout an older revision, use the option --revision. To checkout revision 14 type
    svn co --revision 14 https://svn.iac.ethz.ch/repos/projects/projectname projectname-r14
    

  • Now change to your working copy folder
    cd my_repo 
    # or
    cd projectname
    

  • To show information about your checked out repository
    svn info
    

  • To add a file to your working copy
    touch testfile 
    svn add testfile 
    

  • View the status of your working copy
    svn status
    svn st
    

  • It's highly recommended to use instead of the Linux file commands (rm, mv, cp) the svn commands to delete, rename ore copy files!

  • Delete a file
    svn delete testfile 
    

  • Copy a file
    svn cp file copy_of_the_file
    

  • Rename a file
    svn mv oldfile newfile
    

  • Commit / check-in (ci) your changes to the repository on the server
    svn ci -m "testfile created"  
    
    If you don't define a comment with the option -m, your default editor will be open to let you write a comment. You can define your default editor by setting the $EDITOR environment variable.

  • Everything you do a check-in the revision number of your repository is increasing by one.

  • View changes between your working copy and the repository on the server
    svn diff
    svn diff <file>
    
    Comparing current folder content with content of an older revision (-r 100) or from 2010-01-15
    svn diff -r 100
    svn diff -r {2010-01-15}
    

  • Update your local copy against the repository on the server
    svn update
    svn up
    

  • You may want to see first what will be updated (use svn status with -u option)
    svn st -u
    

  • Restore <file> to version stored in the repo (un-do local edits in your working copy)
    svn revert <file>
    

  • Restore <file> to an older revision, for example revision 100:
    svn up -r 100 <file>
    

  • Go back to an older revision, for example revision 80:
    svn up -r 80
    
    or to the status of a specific date, for example 2010-01-15
    svn -r {2010-01-15} up
    

  • In order to start from scratch, you can check out also an older revision of your repository
    svn co -r {2009-10-01} https://beyerleu@svn.iac.ethz.ch/repos/users/beyerleu my_repo.2009-10-01
    

  • Make a file executable that was not executable before. Note, there is no "svn chmod" commando, use instead
    svn propset svn:executable ON <file>
    

  • List the Logs
    svn log
    
    Only list logs for a specific file
    svn log <file>
    

  • Get help
    svn help
    svn help <subcommands>
    svn help cp
    

For more info about common tasks see http://svnbook.red-bean.com/en/1.4/svn.tour.cycle.html

Important note about security

Per default the Linux svn client is caching your password. This can be quite useful, since you don't have to type in your password every time you check out or commit a change. However, the password is stored in cleartext. Per default the folder storing the password ~/.subversion/auth is only readable by you. You should definitely not change this.

Nevertheless, I would recommend to disable the password caching of the svn command completely by uncomment the following line in your ~/.subversion/config file.

store-passwords = no

Afterwards, remove all stored svn passwords with

rm ~/.subversion/auth/svn.simple/*

spacer

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 regarding Wiki? Send feedback
Syndicate this site RSS ATOM