Subversion (svn)

From HPC users
Revision as of 14:56, 26 November 2012 by Albensoeder (talk | contribs) (Created page with "Subversion (svn) is a revision system to track changes of files, e.g. source code of a software. The chandes are stored on a server in a so called repository. For each change a c...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search

Subversion (svn) is a revision system to track changes of files, e.g. source code of a software. The chandes are stored on a server in a so called repository. For each change a comment should be written. Here some basic commands for using svn.

Environment

Choice od an editor

To set a default editor set the environment variable to the favorite editor, e.g.

  export EDITOR=/usr/bin/nedit

set general properties of new files

After a first checkout of a repository a folder ~/.subversion is created. In the file ~/.subversion/config you can set default properties for new files which are added to the repository. To this, add to ~/.subversion/config

 enable-auto-props = yes

The properties can bet set in this file by adding a section [auto-props] and a list of properties for defined suffixes, e.g.

 [auto-props]
  *.py = svn:eol-style=native; svn:keywords="Author Date HeadURL Id Rev URL"; svn:executable
  *.c = svn:eol-style=native; svn:keywords="Author Date HeadURL Id Rev URL"
  *.h = svn:eol-style=native; svn:keywords="Author Date HeadURL Id Rev URL"

for defining python files as executables and set automatically the svn keywords in *.c, *.h and *.py files, herr the variables $HeadURL:$, $Rev:$', $Author:$ and $Date:$.


Basic commands

Download the content of a repository

 svn checkout svn://ServerName/RepositoryName
   

Submit/checkin a change from a working directory to the repository

 svn ci [filenames] [directories]

submit afiles or directories (including subdirectories to the repository. The command opens an editor (default vi) for the changes you've made.

Update of the working dir for the newest version of files or directories

 svn update [filenames] [directories]

Informations about an repository

Some informationen about the reository you'll get with

 svn info  

Help

 svn [option] help

Content list of repository

 svn list [filenames] [directories]

List of changes

 svn log [filenames] [directories]

Add a file

   svn add [filenames] [directories]

Adds a file or a directory with subdirectories to the repository. Note that the new files have to be checked in because this command add the files only to your local working copy.

Move a file

   svn move <oldfilename> <new_filename>

Copy a file

   svn copy <oldfilename> <new_filename>

Add a directory

   svn mkdir <directoryname>

Status of a directory or files

   svn status [filenames] [directories]
 

Differences between working copy and archive

   svn diff [filenames] [directories]

Differences between 2 revisions can be shown by

   svn diff --revision m:n  [filenames] [directories]

Set svn properties/keyword substition for a file

  • Set svn keyword substition for a file
 svn propset svn:keywords " Author Date HeadURL Id Rev URL" filename
  • Set executable properties for a file
   svn propset svn:executable filename
  • Delete executable properties for a file
   svn propdel svn:executable filename


External links