Page 151 -
P. 151
Share the Repository
A Subversion repository can be accessed by programmers using any of the access methods
listed in Table 7-4. The simplest way to do this is to use a shared folder and the file:///
URL schema. However, this is not secure and may be problematic to share on an intranet
or over the Internet.
Running a server is very straightforward using the svnserve program. Many people think
that the word “server” is synonymous with “administrative headache.” In fact, setting up
and running a Subversion server is simple, and can be done on any machine where a
repository is installed. The following command will run a read-only server:
$ svnserve -d -r /usr/local/svn/repos/
It works equally well on a Windows platform:
C:\>svnserve -d -r c:\svn\repository\
If this is running on a machine called mybox.example.com, the repository can be accessed
using the URL svn://mybox.example.com. (Note: At the time of this writing, svnserve does not
work with Windows 95/98/ME.)
By default, the server is read-only, which means that it only allows users to retrieve files,
not to commit changes. However, it does not take much work to turn on password
authentication. First a password file must be created in the conf folder in the Subversion
repository. In this example, the file passwords.txt contains the following lines:
[users]
andrew = mypassword
jenny = anotherpw
Then the following lines must be added to the end of svnserve.conf in the same folder:
[general]
anon-access = read
auth-access = write
password-db = passwords.txt
Now when the svnserve command listed above is executed, it will run a server that sup-
ports authentication. The username and password can be passed to svn on the command-
line with the --username and --password flags. When the repository is checked out, the
working copy remembers the authentication information, so the username and password
only need to be supplied when files are checked out.
$ svn checkout svn://servername/trunk --username andrew --password mypassword
A trunk/hello-world.c
A trunk/hello-world.h
Checked out revision 1.
Note that in this example, since no destination folder name is given, it checks out the
working copy into a folder named trunk, which corresponds to the path given in the URL.
DESIGN AND PROGRAMMING 143