SVN

From DevelopSpace
Jump to navigation Jump to search

DevelopSpace.net hosts Subversion repositories to help projects share and collaboratively edit files. Subversion (or SVN) is a version control system which tracks all revisions of the files it manages. While created primarily for assisting software development teams, Subversion is useful whenever a group or individual has a set of files they want to update over time without losing revisions. Subversion enables multiple users to access the same repository and make updates in a safe fashion, unlike a simple file storage system where one person's updates can over-write another's.

Existing Repositories

All DevelopSpace.net SVN repositories have http://svn.developspace.net/svn/ as the root URL. The existing repositories are:

  1. sandbox - a place to try out svn and learn how to use it - generic username: guest, password: sandbox
  2. minmars - SVN repository for Minimalist Human Mars Mission Project

Repository and User Account Setup

For projects looking to setup a repository and users looking to gain read-write access to a repository, please email info@developspace.net. Setting up users and repositories is currently a manual process, so may take a day or two. When requesting a repository be setup for your project, please indicate whether you would like anyone who requests a user account for it to have access, or if you would like to approve all read-write access requests for your repository. Note, all DevelopSpace.net SVN repositories are publicly readable, meaning no account is needed to view and download files from a repository -- users accounts are only need to add and modify files in the repository.

Basic Usage

This section details basic usage of SVN of relevance to DevelopSpace.net projects and members. For further information on SVN, we recommend the Subversion documentation or the documentation associated with your SVN client.

SVN clients

Anyone can browse and download files from the latest revision of a repository by simply entering the URL into their web-browser (e.g., http://svn.developspace.net/svn/sandbox/). In order to add or modify files in a repository, an SVN client is required (in addition to a user account with write access to that repository). A listing of common clients follows:

  • svn command line - Command line interface, installed by default in many Linux distributions, also available for other platforms (e.g., Windows)
  • TortoiseSVN - A Windows-only client which integrates into the Windows Explorer interface. Once installed, functionality is available via right-clicking files and folders.
  • scplugin - A Mac Subversion client
  • Subclipse - A Subversion plug-in for the cross-platform Eclipse IDE (an open source, Java-based, software development environment)

Common Commands

From a user perspective, Subversion works by the user first creating a local copy of the repository (or subset thereof) on the user's computer, the user modifying or adding files to the local copy, and then the user submitting their changes back to the repository.

Some common commands for doing this follow:

  • checkout - sets-up a local copy of the repository on your computer
  • update – downloads any updates in the repository to the local copy on your computer
  • commit - sends any updates you have made to the repository.
  • diff and merge - allows you to see differences between revisions for certain file types (text files in all versions, other files with certain clients) and, again depending on file type, take modifications from two revisions/files and merge them into a single file

Use Scenarios

Copy-Modify-Merge

By default, Subversion allows multiple users to edit the same file at the same time, each user working with their own local copy. When users go to upload their changes, if the underlying file has been updated by another user in the mean time, Subversion provides an opportunity for the user to merge the changes together. This can work well with text files, such as software source code, by allowing multiple people to work on a file concurrently while still keeping the resulting file consistent with each user's change.

For more information on this version control approach, see this page of the Subversion documentation.

Lock-Modify-Unlock

While Copy-Modify-Merge works well with human readable files such as plain text, the model can break down when the file being modified cannot be readily merged, such as when the file contents are not human readable (for example, an Excel file). To assist with such cases, Subversion provides a lock utility. If you lock a file (using the "lock" command), no other user can make a change to that file in the repository until you have released the lock (either through the "unlock" command or via the commit process, which by default will release locks) or somebody breaks or steals the lock (which they have to do intentionally).

For more information on locking in SVN, see:

There are a number of file types for which using locks is highly encouraged. In general, users should be reminded of the importance of checking for and creating locks on non-text files, although one way to help enforce this is to set the "svn:needs-lock" property on files in a repository for which a lock is required. The property can be set in the local copy via your SVN client, and then will be updated in the repository at your next commit. Files with this property set will be read-only in a user's local copy unless they have locked the file, making it less likely (although not impossible), that the user will accidentally edit the file without first obtaining a lock.

You can have your SVN client automatically add this property (svn:needs-lock) to files you add to the repository by modifying your SVN client configuration file. The config file is in the following locations:

  • Linux or Mac: "~/.subversion/config"
  • Windows: "C:\Documents and Settings\[USER_NAME]\Application Data\Subversion\config"


Replace or merge the [miscellany] and [auto-props] sections in the svn config file with the following:

[miscellany]
enable-auto-props = yes

[auto-props]
### The format of the entries is:
###   file-name-pattern = propname[=value][;propname[=value]...]
### The file-name-pattern can contain wildcards (such as '*' and
### '?').  All entries which match will be applied to the file.
### Note that auto-props functionality must be enabled, which
### is typically done by setting the 'enable-auto-props' option.
# Initial list, added: 2008-05-11
*.bmp = svn:mime-type=image/bmp;svn:needs-lock=*
*.gif = svn:mime-type=image/gif;svn:needs-lock=*
*.ico = svn:mime-type=image/x-icon;svn:needs-lock=*
*.jpeg = svn:mime-type=image/jpeg;svn:needs-lock=*
*.jpg = svn:mime-type=image/jpeg;svn:needs-lock=*
*.png = svn:mime-type=image/png;svn:needs-lock=*
*.tif = svn:mime-type=image/tiff;svn:needs-lock=*
*.tiff = svn:mime-type=image/tiff;svn:needs-lock=*
*.doc = svn:mime-type=application/msword;svn:needs-lock=*
*.jar = svn:mime-type=application/octet-stream;svn:needs-lock=*
*.odc = svn:mime-type=application/vnd.oasis.opendocument.chart;svn:needs-lock=*
*.odf = svn:mime-type=application/vnd.oasis.opendocument.formula;svn:needs-lock=*
*.odg = svn:mime-type=application/vnd.oasis.opendocument.graphics;svn:needs-lock=*
*.odi = svn:mime-type=application/vnd.oasis.opendocument.image;svn:needs-lock=*
*.odp = svn:mime-type=application/vnd.oasis.opendocument.presentation;svn:needs-lock=*
*.ods = svn:mime-type=application/vnd.oasis.opendocument.spreadsheet;svn:needs-lock=*
*.odt = svn:mime-type=application/vnd.oasis.opendocument.text;svn:needs-lock=*
*.pdf = svn:mime-type=application/pdf;svn:needs-lock=*
*.ppt = svn:mime-type=application/vnd.ms-powerpoint;svn:needs-lock=*
*.ser = svn:mime-type=application/octet-stream;svn:needs-lock=*
*.swf = svn:mime-type=application/x-shockwave-flash;svn:needs-lock=*
*.vsd = svn:mime-type=application/x-visio;svn:needs-lock=*
*.xls = svn:mime-type=application/vnd.ms-excel;svn:needs-lock=*
*.zip = svn:mime-type=application/zip;svn:needs-lock=*

Note: You can add other files types that should use a lock to your config file by following a similar form to that above (the mime-type isn't needed, "*.xxx = svn:needs-lock=*" is sufficient to make .xxx files need to be locked). To assist other DevelopSpace.net users, you can add additional binary file types to the list above, although please include a comment of "# Added: YYYY-MM-DD" before the new items so that users can update their config files more easily.