В начало → Unix Toolbox → 13. SVN |
Subversion (SVN)9 is a version control system designed to be the successor of CVS (Concurrent
Versions System). The concept is similar to CVS, but many shortcomings where improved. See also the SVN book10.
The initiation of the repository is fairly simple (here for example /home/svn/ must exist):
# svnadmin create --fs-type fsfs /home/svn/project1
9.http://subversion.tigris.org/
10.http://svnbook.red-bean.com/en/1.4/
Now the access to the repository is made possible with:
• file:// Direct file system access with the svn client with. This requires local
permissions on the file system.
• svn:// or svn+ssh:// Remote access with the svnserve server (also over SSH). This
requires local permissions on the file system.
• http:// Remote access with webdav using apache. No local users are necessary for this
method.
Using the local file system, it is now possible to import and then check out an existing project.
Unlike with CVS it is not necessary to cd into the project directory, simply give the full path:
# svn import /project1/ file:///home/svn/project1/trunk -m 'Initial import'
# svn checkout file:///home/svn/project1
The new directory "trunk" is only a convention, this is not required.
Remote access with ssh
No special setup is required to access the repository via ssh, simply replace file:// with
svn+ssh/hostname. For example:
# svn checkout svn+ssh://hostname/home/svn/project1
As with the local file access, every user needs an ssh access to the server (with a local account) and also read/write access. This method might be suitable for a small group. All users could belong to a subversion group which owns the repository, for example:
# groupadd subversion
# groupmod -A user1 subversion
# chown -R root:subversion /home/svn
# chmod -R 770 /home/svn
Remote access with http (apache)
Remote access over http (https) is the only good solution for a larger user group. This method
uses the apache authentication, not the local accounts. This is a typical but small apache
configuration:
LoadModule dav_module modules/mod_dav.so
LoadModule dav_svn_module modules/mod_dav_svn.so
LoadModule authz_svn_module modules/mod_authz_svn.so # Only for access control
<Location /svn>
DAV svn
# any "/svn/foo" URL will map to a repository /home/svn/foo
SVNParentPath /home/svn
AuthType Basic
AuthName "Subversion repository"
AuthzSVNAccessFile /etc/apache2/svn.acl
AuthUserFile /etc/apache2/svn-passwd
Require valid-user
</Location>
The apache server needs full access to the repository:
# chown -R www:www /home/svn
Create a user with htpasswd2:
# htpasswd -c /etc/svn-passwd user1 # -c creates the file
Access control svn.acl example
# Default it read access. "* =" would be default no access
[/]
* = r
project1-developers = joe, jack, jane
# Give write access to the developers
[project1:]
@project1-developers = rw
See also the Subversion Quick Reference Card11. Tortoise SVN12 is a nice Windows interface.
Import
A new project, that is a directory with some files, is imported into the repository with the import command. Import is also used to add a directory with its content to an existing project.
# svn help import # Get help for any command
# Add a new directory (with content) into the src dir on project1
# svn import /project1/newdir http://host.url/svn/project1/trunk/src -m 'add newdir'
Typical SVN commands
# svn co http://host.url/svn/project1/trunk # Checkout the most recent version
# Tags and branches are created by copying
# svn mkdir http://host.url/svn/project1/tags/ # Create the tags directory
# svn copy -m "Tag rc1 rel." http://host.url/svn/project1/trunk \
http://host.url/svn/project1/tags/1.0rc1
# svn status [--verbose] # Check files status into working dir
# svn add src/file.h src/file.cpp # Add two files
# svn commit -m 'Added new class file' # Commit the changes with a message
# svn ls http://host.url/svn/project1/tags/ # List all tags
# svn move foo.c bar.c # Move (rename) files
# svn delete some_old_file # Delete files
В начало → Unix Toolbox → 13. SVN |