macdevcenter.com
oreilly.comSafari Books Online.Conferences.

advertisement

AddThis Social Bookmark Button

Making the Jump to Subversion

by Adam Swift
08/10/2004

If you haven't checked out Subversion, you should. It's a free, open source, powerful revision control system that was built to be a better CVS. It was created with clear design goals and built on top of robust, time-tested technologies. If you've been waiting for a better CVS and are ready to roll up your sleeves, skip directly to the Installing Subversion section of this article.

However, instead, you may be saying, "But c'mon, I'm a busy programmer, this sounds like extra work to me. Besides, CVS only punishes me on Tuesdays and Thursdays, and my team is already comfortable with it and its shortcomings."

After using CVS for years, I realized that it was influencing my software development decision-making just to avoid CVS's shortcomings! (For example: renaming or moving files and removing/renaming directories.) Though I consider this to be one of CVS's greatest crimes, it is only one of many good reasons to make the switch to Subversion.

In short, you should consider jumping to Subversion because:

  1. It's more of a skip than a jump.
  2. It's FREE.
  3. It not only fixes the main issues with CVS that will burn you, but it presents one of the best approaches to revision control available at any price. You can spend a good deal of money and still fall short of the ease-of-use and functional strengths of Subversion.

Also, thanks to the hard work of the Subversion open source community, installation is quick, easy, and uses the standard Mac OS X package installation tools. Alternatively, you can use Fink to install Subversion or download the source and build it by hand. Subversion is also available as downloadable, pre-built packages for a variety of platforms (Mac OS X, Linux, FreeBSD, Win32, etc.). See the official Subversion web site for a current listing.

Installing Subversion

Subversion can run stand-alone or on a network as a repository server with multiple clients. The preferred client/server configuration uses Apache and WebDAV for network communication. I strongly recommend using this style of networked repository server access. It provides the best combination of features, flexibility, and security. If for some reason this type of client/server configuration won't work in your environment, there are other supported configurations available.

You will need to designate one computer as the Subversion server. Subversion clients will connect to this server to access and manage source code and project resources. Secure access to the server can be configured via HTTPS or HTTP through SSH port tunneling. Put simply: HTTPS makes it easy to provide public, read-only access to the repository, and SSH tunneling has the advantage that only users with SSH access through the firewall can connect to the repository.

Because setting up HTTPS can be somewhat involved, this article will focus on HTTP access through SSH port tunneling. The same instructions used to configure HTTP access can be applied to an HTTPS-based connection. For more information about configuring HTTPS see the references listed at the end of this article.

Client-side Installation

Most users will only need to install the Subversion client-side tools. Download the statically linked package from Martin Ott's site or D. J. Hagberg's web page. Download the latest version of the Subversion client (currently Subversion-1.0.6.pkg.zip). Alternatively, see the server-side installation notes below for instructions on how to install the individual packages (the client installation only requires these packages: APR, APR-util, BerkeleyDB, Expat, Subversion).

After downloading, mount the disk image (or open the zip file) and use Apple's Installer application to install the Subversion client package. (Martin Ott's package will install into /opt/subversion with links from /usr/local/bin/; D. J. Hagberg's will install directly into /usr/local/bin/). For convenience, add the path to your executable search path. For the bash login shell, add the following lines to your ~/.bash_profile file:


PATH="/usr/local/bin:/usr/local/subversion/bin:$PATH" 
export PATH

To verify your installation, enter 'svn' into a terminal window. The command should respond with the message, "Type 'svn help' for usage.".

Server-side Installation

To set up a network accessible repository, you'll need to install a few packages on the computer you choose to use as the repository server. Once the packages are installed, then the actual repository must be created and configured for access from client users over the network.

Download and install these individual packages. The packages are available for download as disk images from Fred Sanchez's public iDisk at idisk.mac.com/wsanchez/Public/Software/packages/. Use the Finder to Connect to Server and enter the URL as the server address.


BerkeleyDB
Expat
Libxml2
Neon
SWIG
APR
APR-util
Apache2
Subversion

Mount the disk images and install all of the packages. If you are remotely connected to the server, you can use hdiutil to mount each disk image and use Installer to install the package from each volume mounted by the disk images.


% hdiutil attach <disk_image_file>
% installer -pkg <package_file> -target <target_volume>
In this example note that the installer command and all arguments must be entered on the same line; the \ is used to indicate line continuation:

% hdiutil attach ~/Desktop/Subversion_1.0.5.dmg
% installer -pkg /Volumes/Subversion_1.0.5/Subversion_1.0.5.pkg \
-target /

Each package will be installed into /usr/local/<package_name>.

Now you have all of the necessary packages installed on the server. The only remaining steps are to create the repository and set up client access.

Because you are using Apache to provide access to the repository, you'll need to create HTTP/Apache user accounts to determine repository access restrictions and ownership of file revisions in the repository. These are accounts used within the repository and are completely independent of the Unix/login accounts configured on the server. These accounts are set up as HTTP/Apache users.

Outside of the repository, you need an account that owns the repository database and supporting files. Apache2 will need to have read/write access to files owned by this account.

In reality, this is easy to deal with. Make the Mac OS X standard web server account, www, the owner of repository files and also the account that the Apache2 process runs as. Then create an HTTP/Apache authentication file using htpasswd to set up the users for the repository.

Enough talk, time for action! Create the repository on the server using the following command (perform the following commands as root or authenticated via sudo):


svnadmin create <path to repository>
chown -R www <path to repository>

Configure Apache2 to access the repository by editing /usr/local/apache/conf/httpd.conf. Add the command to load the WebDAV/Subversion module at the end of the LoadModule commands (around line 262) as follows:


LoadModule dav_svn_module modules/mod_dav_svn.so

Set the Apache-Unix process account to be www by replacing the existing line that sets the default account as "User nobody" with the following:


# User nobody
User www

To avoid conflict with the standard OS X Apache configuration, set a different port to listen for http requests. Replace the existing line configuring "Listen <port>" with the following (for the rest of this article we'll assume use of port 8800):


# Listen 80
Listen 8008

Add the following text to the end of the configuration file to let Apache2 know the path to the repository and the HTTP/Apache user accounts file. Replace the text "<path to repository>" with the path you used above.


<Location /svn>
  DAV svn
  SVNPath <path to repository>
  AuthType Basic
  AuthName "Subversion Repository"
  AuthUserFile /usr/local/apache/etc/svn-auth-file
  Require valid-user
</Location>

Now, configure HTTP/Apache accounts. I put the authentication file in /usr/local/apache/etc/svn-auth-file. To CREATE this file enter the following command (you will be prompted for a password):


htpasswd -c /usr/local/apache/etc/svn-auth-file <username>

Note, to add users to an existing file, skip the -c option:


htpasswd /usr/local/apache/etc/svn-auth-file <username>

Now start up Apache2 by issuing the command:

	
/usr/local/apache/bin/apachectl start

You're now done with the setup and installation! To verify that the server installation was successful enter the URL specified for the location of the repository (as configured in the httpd.conf file) into Safari. You should be prompted for a username/password combination and upon successful authentication see a revision number and the contents of the top directory of your repository (it should be empty).

Pages: 1, 2, 3

Next Pagearrow