Subversion: Version Control

moodusroundoSoftware and s/w Development

Aug 15, 2012 (4 years and 10 months ago)

364 views

Version Control with
Subversion
and the

TortoiseSVN Client


Overview


Version control

is the management of source code, documents, graphics and related files in a large
software project. Version
-
control software provides a
database

that is used to keep track of the
revisions made to a program by all the programmers and developers involved in it (from PC Magazine
online encyclopedia). The database of information to manage the different revisions is often called a
repository. Access

to this repository is generally from many clients and is managed by server
-
side
software.


Subversion (aka SVN) is a type of server
-
side version control software which integrates with the apache

web server
.
Subversion is a type of central repository wher
e there is one primary copy of repository and
individual revisions of this m
aster copy at various clients. Clients share revisions of their code by

first
synchronizing their local copy with the master, then making local edits, then
committing their change
s
to the
central
repository
. There are several SVN clients available for Windows O/S machines. For
example, there are plug
-
ins for IDEs Eclipse, Netbeans and Visual Studio.

One of the most common SVN
clients for Windows machines is tortoisesvn (or simpl
y tortoise). Tortoise integrates nicely with
Windows Explorer to provide additional right
-
click context menus for most of the client
-
side actions,
including updating, committing, browsing the repository for changes, and comparing revision
differences.


Th
e rest of this document gives instructions for setting up a subversion repository on a linux server and
access that repository via tortoise.




Subversion


Resources

Online instructions for this process may be found at:


1) https://help.ubuntu.com/commu
nity/Subversion


Instructions for creating and setting the permissions for the repository may be found at:


2) http://svnbook.red
-
bean.com/en/1.5/svn.serverconfig.httpd.html


Setup


In resource
number
2

above
, and
in the notes
below
(
for our specifi
c site
)
, you’ll find instructions for
setting up the apache2 web server with mod_dav and editing the .passwd and .authz files for access.
Our site uses the access control described in Example 6.2.


Specific workflow (commands):


1.
Change directory to where repositories are hosted on your site:
cd /home/svn



Go to the svn repository root (not strictly required, but it is good




practice to have all repositories managed from one location
). On our server, joseph,


repositories are rooted at /home/svn
.



2.
Create new repository:
svnadmin create
newRepository



Create the repository in /home/svn



3.
Correct ownership of repository:
chown
-
R www
-
data:subversion
newRepository



The owner of the repository
needs to be www
-
data (apache) and the group



is set to subverison. This gives apache the permissions to proxy for



the actual user of the repository.



4.
Correct repository access permissions:
chmod
-
R g+rws
newRepository



svncreate does

not set the group permissions correctly, so we need to fix




this, recursively.



5.
Move to the apache setup directory for configuring:
cd /etc/apache2/



Now we need to move to the apache configuration directory to update the



.passwd and

.authz files.





6.
Create a subversion account, if necessary:
htpasswd dav_svn.passwd
newUserName



Often when we create a new repository, we will want to create an "owner"



of that repository. This owner is not a linux account, but an



authentication account with subversion, i.e., an account known only to



dav_svn.passwd and dav_svn.authz.



7.
Edit

dav_svn.authz

to control general authentication. This step is done
once

at initial setup.
It does


not need to be done for each new

repository.



Just as we create a new account for authentication in the .passwd file,



we also need to set this account's access restrictions in the .authz



file. Access is controlled in two places. General control
,
which should be


done once when subversion is first configured for your site
,

is provided



in the file /etc/apache2/mods
-
available/dav_svn.conf file
. It is discussed


next. See paragraph 8 on fine control below for per repository setup


instructions
. The relevant
general control
settings are:



# dav_svn.conf
-

Example Subversion/Apache configuration


<Location /svn>



# Uncomment this to enable the repository


DAV svn



# Use SVNParentPath if you have multiple re
positories under


# under a single directory (/home/svn/repo1, /home/svn/repo2, ...).


SVNParentPath /home/svn


SVNListParentPath On



# To enable authorization via mod_authz_svn


AuthzSVNAccessFile /etc/apache2/dav_
svn.authz



# Require apache to authenticate the user


Require valid
-
user



AuthType Basic


AuthName "Source Repository"


AuthUserFile /etc/apache2/dav_svn.passwd



</Location>






8.
Fine control is
provided in the file /etc/apache2/dav_svn.authz. Typical



settings for this file are:



# the repository is the SVNParentPath followed by the name specified,


# e.g., /home/svn/
newRepository


#


# The path, i.e., /, after the
name indicates the root of this repository


#


# This is followed by an access account, in this case
newUserName,

and


# it'
s permissions on the repository. If several users need to access the


# repository, then just append addit
ional names as show below.


[
newRepository
:/]


newUserName

= rw


anotherUserName

= rw


9. Example command sequence:

login as: shomperk

shomperk@john.cedarville.edu's password:

john:~> ssh joseph

shomperk@joseph's password:

joseph:~> su

P
assword:

root@joseph:/home/shomperk# cd /home/svn

root@joseph:/home/svn# svnadmin create demo

root@joseph:/home/svn# chown
-
R www
-
data:subversion demo

root@joseph:/home/svn# chmod
-
R g+rws demo

root@joseph:/home/svn# cd /etc/apache2/

root@joseph:/etc
/apache2# htpasswd dav_svn.passwd demoUser

New password:

Re
-
type new password:

Adding password for user demoUser

root@joseph:/etc/apache2# vi dav_svn.authz

root@joseph:/etc/apache2#



TortoiseSVN: A subversion client


Resources

Instructions for the tortoi
sesvn client and a link to download it may be found at
:

1)

http://tortoisesvn.net/


Setup

1. Setup the subversion repository as indicated in the instructions above.


2.
Install tortoisesvn.

a.

Click on Install tab

b.

Choose

either 32
-

or 64
-
bit installer and save

c.

Double
-
click on installer.


3. Checkout repository with tortoisesvn: right
-
click

in a Windows Explorer window

and choose “SVN
Checkout …”