An introduction to version control using Subversion

 
Published on 2005-10-02 by John Collins. Socials: YouTube - X - Spotify - Amazon Music - Apple Podcast

Introduction to version control

Normally while working on a file containing source code you will save your changes over the previous version of the file. All previous versions of the file are therefore lost, as each save is replacing the file entirely.

Generally this situation is not a problem, but what if the changes you have made are not working out: how can you revert to a previous version you had that was stable but you've already overwritten it?

Many developers are disciplined enough to backup their work on a periodic basis, but this is only useful if the backup period is a short space apart, e.g. several times a day for an active project. Of course these backups then become an overhead without an automated tool.

Version control systems such as CVS (Current Version System), [1] SI (Source Integrity), [2] and Subversion [3] are designed to handle these situations by enabling single or groups of developers to save their work to a shared repository that stores each revision of a file separately, allowing for the safe storage of all historic data.

In this article we will take a first look at Subversion version control system, as it offers a number of advantages over other version control systems which we will highlight here.

Overview of Subversion

Subversion is a free open source version control system supported by CollabNet. [4] Subversion manages files and directories over time, which are stored in a central repository managed by the Subversion server. The repository is much like a normal file server that is accessible over a network, except that it remembers every change made to your files and directories. [5]

Subversion also knows who changed each file and what changes they made, right down to the line level. Team collaboration is made possible by this functionality, combined with network access to the repository for all team members. One of the main reasons for systems like Subversion being developed is to enable teams of developers to cooperate effectively, while not stepping on each other's toes.

Subversion benefits

We have already discussed some of the benefits of Subversion and version control in general already; however Subversion offers a number of specific benefits over rival systems: [3, 5]

Directory versioning - CVS only tracks the history of individual files, but Subversion tracks revisions to entire directory trees over time, meaning files and directories are versioned.

Atomic commits - a collection of updates either goes into the directory or it does not, meaning that when a user commits a number of files in one go, they do not need to worry about which files were committed or not in the event of a error, for example a network connection going down. Either all files make it to the repository or none of them, therefore repository integrity is retained.

Versioned metadata - each file has a set of properties associated with it, in the form of key-value pairs. This metadata is versioned along with file contents, while users can add their own arbitrary key-value pairs if they wish.

Choice of network layers - Subversion can run under the Apache HTTP server as a module extension; while a more lightweight, custom standalone Subversion server process is also provided.

Costs are proportional to change size, not repository size - generally the time required to carry out a Subversion transaction are proportional to the changes resulting from that transaction, not the size of the project contained within the repository. This is particularly important for remote users with low bandwidth.

Choice of database or plain-file repositories - Subversion can use an embedded database backend using BerkeleyDB, or else it can use a normal flat-file backend which uses a custom format.

Efficient handling of binary files - Subversion handles binary files equally as well as text files, because it uses a binary differing algorithm to transmit and store successive revisions.

Another benefit that Subversion has is in the range of client tools that are available to it, which enable the user to view the contents of the repository in many different ways.

Subversion tools

Subversion comes with a console client tool as standard, however there are a number of more advanced graphical clients available for you to use for free. To begin with, if you use the Eclipse IDE [6] then you can always try the Subeclipse plug-in for Eclipse, [7] which enables you to access the contents of a local or remote Subversion repository without even leaving your IDE!

TortoiseSVN[8] is a Windows Explorer extension for Windows users that allows you to create and access Subversion repositories via a right-click context menu in Explorer, allowing for quick access to all Subversion commands for working with files.

WebSVN[9] is a web client for viewing the contents of Subversion repositories through a web browser, which is written in PHP and therefore can be hosted under any server that supports that language, such as IIS or Apache HTTP. While essentially only offering read access, this tool is nonetheless useful for presenting code online to a partner or to the public for an open source project.

Conclusion

Version control is a powerful tool for professional software development, which greatly facilitates project collaboration between team members via the use of network-enabled file repositories. Subversion is not limited to team usage however, as it is perfectly viable to install the Subversion server and clients on a single computer for one user.

Subversion is an example of a version control system that is free to use and is open source (the code for Subversion is publicly available). The fact that it is free means that small projects can avail of it apart from large enterprise projects, while its open source nature will continue to enable third party developers to produce varied client tools for Subversion.

As Subversion can handle binary files as well as text files, it is not limited to being used as a code repository for programmers: anywhere that requires groups of users to manage computerized information that changes often can benefit from version control.

For a next step into learning more about Subversion, I would recommend working through the online quick start guide, which will get you up and running with the application in a short space of time. After that there is the excellent online book Version Control with Subversion, a link for which is contained below in the references section.

References

[1] R. Price, D, (2005), CVS (Current Version System), http://www.nongnu.org/cvs/, Date Accessed: September 2005.

[2] MKS, Inc, (2005), MKS SI, http://www.mks.com/products/sie, Date Accessed: September 2005.

[3] CollabNet, Inc, (2005), Subversion, http://subversion.tigris.org/, Date Accessed: September 2005.

[4] CollabNet, Inc, (2005), CollabNet Home Page, http://www.collab.net/, Date Accessed: September 2005.

[5] Collins-Sussman Ben et al, (2005), Version Control with Subversion, http://svnbook.red-bean.com/nightly/en/index.html, Date Accessed: September 2005.

[6] Eclipse Project Team, (2005), Eclipse, http://www.eclipse.org/, Date Accessed: September 2005.

[7] Subeclipse Project Team, (2005), Subeclipse, http://subclipse.tigris.org/, Date Accessed: September 2005.

[8] TortoiseSVN Project Team, (2005), TortoiseSVN, http://tortoisesvn.tigris.org/, Date Accessed: September 2005.

[9] WebSVN Project Team, (2005), WebSVN, http://websvn.tigris.org/, Date Accessed: September 2005.


Updated 2021 : note that the above post is out-of-date, given this post was originally published in 2005, but is left here for archival purposes. As most of the links in the references section are now dead, I have unlinked them.