As you have seen, all version control systems provide a means to keep track of the changes made to a collection of files over time; and since software development is usually a collaborative effort, they also provide facilities to merge the efforts of multiple developers. Branching and tagging features of many VCSs allow the paths of development on a project to be
The benefits of using a version control system are many, and its use is critical for any project of larger than trivial
Now that you have a firm grasp of the general features and benefits of version control, you can
Chapter 2. An Introduction to Subversion
In 1986, Dick Grune introduced the Concurrent Versioning System (CVS) as the first version control system to support development of multiple files concurrently by multiple developers, using the merging paradigm to combine those developers' work together when they committed to the repository. From there, CVS went on to become immensely popular,
2.1. Why Subversion?
Subversion may be successful, but does that mean it's right for your project? If you're currently using CVS, the answer is almost
2.1.1. A Software Engineering Tool
Software development is a craft, on par with the finest woodworking or most
Subversion is hosted (as an
Already, Subversion is a flexible tool, capable of supporting many aspects of organized software engineering. Much of this book, in fact, is dedicated to showing how Subversion can fit into a variety of different development processes.
2.1.2. Open Source Solutions
I grew up in a small town
When I first learned about open source software, I quickly realized that it
Subversion is licensed under an open source license similar to those used for the Apache Web server and the BSD operating systems. In short, the license states that you are free to do whatever you want with it, as long as you give credit to CollabNet, which currently holds the copyright for Subversion. Unlike the GNU Public License, used for Subversion's predecessor CVS, Subversion does not require you to distribute code for any changes you makealthough contributing changes back to the Subversion project helps ensure that they
So, in addition to it being free of charge, exactly what direct benefit do you as the end
By being open, Subversion
The open nature of Subversion also makes it very integrable. The core of Subversion is, in fact, a set of libraries with a well-documented, open application programming interface (API). This API allows developers to write custom
2.1.3. Major Features of SVN
What, exactly, can Subversion do? What features make it stand out against other version control systems? What features foster
The basic interface to Subversion is very similar to CVS. The primary method of interfacing with Subversion is through the command line (although there are some very good GUI front ends available), and by design, SVN has very similar command-line operations to CVS. Commands have not been needlessly
Like many common version control systems, Subversion uses a client-server paradigm, where a central repository sits on a server and clients check out local working copies where they can modify things as much as they like. When a modification is complete, changes between the repository and the working copy are merged, and the modified version is committed back to the repository.
Subversion allows for great flexibility in layout of repositories, by keeping revision histories for both files and directories across moves, copies, and renames. This may not seem like a big deal if you're not familiar with other version control systems, but copy, move, and rename functionality is a feature sorely lacking in many popular version control systems. Most notably, CVS is notoriously
Subversion uses transactions whenever it modifies the database. When a commit starts, Subversion marks the current state of the database, then makes its modifications. That way, if a crash (or bang or boom) interrupts the commit, there is no risk that the database will be corrupted. When it is resumed, the database will automatically be restored to its state before the commit
This is another feature sorely lacking in many older VCSs, such as CVS or Visual SourceSafe. If a network glitch or software crash causes a commit in either of those systems to fail, the repository can be left in a corrupted, unstable state, which may require the repository to be restored from backup.
Branches and Tags
Most version control systems allow for the revision trees of individual files and directories to be branched and tagged. Subversion, on the other hand, does not explicitly support this. In fact, SVN has no built-in concept of either branches or tags. Instead, it provides
. When a developer uses the
command, Subversion does not make a copy of data contained in those files. Instead, it just marks the location of the new file and links it back to the history of the original file, up to the point where the copy is made. From that point on, if changes are applied to the copy, a new
Using this paradigm, a branch can be created by simply copying the directory (or file) to be branched. Usually, this is done into a directory named branches , so that it is always clear to users that they are dealing with a branch of part of the repository's main trunk. There is no enforcement of this in Subversion, though, and in Chapter 9, "Organizing Your Repository," I talk about a variety of different approaches that you can take when deciding where to place branches, to best fit a project's style of development.
Similarly, tags are also created by making a copy, usually in a tags directory. Like branches, this makes for a wide latitude of flexibility when dealing with how tags are used. The downside is that there is no built-in enforcement to make sure that tags stay tags, and don't inadvertently become branches when someone makes a change to them. It is possible, though, to enforce tag policies using either Subversion's support for hook scripts, or (if you are using Apache as your server) permissions on the tags directory to disallow changes to files in the tags directory after they have been created.
Versioning binary files is a more difficult task than versioning text files. With a text file, the file data itself has meaning to a human being, which makes it easy to merge files or examine their differences. With a binary file, though, you need an external program to interpret the file and present it in a manner that has meaning for a human. This makes it difficult for a version control system to automatically perform merges or present diffs, because it has no context for performing merges properly and no way to present the result of a diff in a meaningful manner. Instead,
Subversion still doesn't have any direct support for automatically merging binary files (which would be nearly
Release 1.1 of Subversion adds the capability to version symbolic links from UNIX systemslike GNU Arch and unlike CVS. If a user is working on a UNIX-like system, he can add symbolic links to the repository, just as he would any other file, and the repository will retain the link information for any other UNIX user who checks out a working copy of the repository. (Windows users will not get symbolic links, because Windows does not support UNIX-style symbolic links.)
Subversion and CVS both use a paradigm of making modifications and then merging them with the modifications others have made, instead of the file locking paradigm used by many other VCSs like Visual SourceSafe. Resolving conflicts in merges when using CVS can be a bit messy, though. When CVS fails to automatically merge changes between the working copy and the server, it replaces the conflicted file in the working copy with a version of the file containing diffs of the two different versions. If the conflict was large, the resulting diff can waste hours while the developer
Subversion has a flexible repository backend that allows different types of repository storage systems to be plugged in,
Subversion provides two servers for communicating with the repository via different protocols. The first server (known as
) uses an SVN-specific network protocol that requires a dedicated server and open port, which allows a Subversion server to be set up quickly and easily.
also supports Inetd access, or tunneled-SSH style access. The other server is a module for the Apache Web server, and is based on the Web-based Distributed Authoring and Versioning (WebDAV) protocol, with a few extensions for version control-specific operations. By using this standard protocol,
One of Subversion's powerful, unique features is its support for file and directory metadata in the form of properties that allow the user to store arbitrary keyword:value data pairs that can be associated with a particular file or directory. This makes it easy to store whatever file metadata makes sense in your development process. Additionally, Subversion defines several special properties that it can use internally to provide some extra functionality, like keyword expansion or end-of-line interpretation.
Subversion supports a broad array of hook scripts that are run in response to a variety of SVN actions, such as before or after a commit or property change. These scripts are given access to relevant information about the action that is taking place, as well as the capability to examine the repository. Hook scripts can be a powerful tool for automating
Subversion features a very complete API, which developers can use to easily and elegantly create new client interfaces, to create new Subversion servers, or to integrate Subversion into other development tools. In fact, the standard Subversion client tools, as well as the SVN servers, use these same APIs to communicate with each other, the Subversion repository, and a local working copy. Additionally, the interfaces are available with language bindings for a number of different programming languages (such as C, C++, Java, Perl, and Python), which allows interfacing programs to be written in whatever language best