Cool Solutions

Installing Subversion on Windows



By:

November 5, 2008 10:00 am

Reads: 10411

Comments:2

Score:0

Install Subversion and related tools on Windows

For those using version control in their projects

This document presents simple steps to install Subversion on a Windows server. This could be pretty useful during projects where several developers have to work on common sources (Java, XML, etc.).



Table of Contents

        Introduction

            Description

            Main features

            Why Subversion?

            System Requirements

        Definitions

            General definitions

            Operations

        Installation of the Subversion server

        Configuration of the Subversion repository

        Starting the server and creating a project

        Running the server as a service

        Installation of TortoiseSVN client

        Subversion Usage

            Project Creation

                Existing project in the repository

                Import of existing local project in the repository

            Retrieving project last version

            Committing local updates to the repository

            Retrieving older versions of a file

            Managing files

                Adding a new file

                Deleting a file

                Renaming a file

            Resolving conflicts

            Additional features

        Resources



Introduction

Description

Subversion (often called SVN) is a version control system using the same principles as Concurrent Versions System (the famous CVS), but with some nice enhancements, among these:

  • Copy of files while keeping full history of the changes
  • Rename of files while keeping full history of the changes
  • Commits are atomic
  • Native support of binary files
  • and much much more!



Main features

Here are the main features of such a system:

  • keep the history of the different versions of files in a project
  • allow developer to recover older versions of files
  • keep the history of all versions with their type, date, author, etc.
  • offer a flexible access to files locally of through the network
  • allow several remote developers to work on the same set of data



Such version control system should be used in any project where there is a lot of customization. As the tool track all changes made to files and directories, you can recover older versions of your data or examine the history of all changes done to a file. It’s not only a “Time Machine”, but also offers advanced features for developers such as tagging/branching/merging of source code.



Subversion can be installed as a server allowing different persons on different computers to access it. Everybody can work on the same set of data, updating and committing their changes as frequently as possible. If two persons modify the same file at the same time and commit their change, a conflit will appear and they will have to solve it before being able to commit everything.



Why Subversion?

There are many different version control system, but here are some points explaining why I think it’s an excellent choice:



  • Subversion is cross-plateform
  • Subversion is open-source
  • Subversion works in centralized mode
  • Subversion is easy to use
  • Subversion supports various protocols



System Requirements

There is no particular system requirement but you will need a Subversion client to interact with the system. Among those you will find:



  • the command-line client, not very user friendly but all commands are available
  • TortoiseSVN for Windows, we will cover the installation in this article
  • Subclipse, plugin for Eclipse
  • JSVN, Java based, cross-plateform
  • and many many more!



This article will also cover the installation of the Subversion server on Windows.



Definitions

For those already familiar with CVS, SVN, etc., you can directly go to the installation procedure!



General definitions

Repository
the repository is the central place where all data from the different projects are stored. It is accessible locally or remotely using a SVN URL. This repository contains the history of all versions of the files, the log of all changes plus dates and authors.
Project
inside a repository, you can manage one or more projects. Usually, each project corresponds to a different directory at the root of the repository.
Working copy
the working copy is a directory located locally on the desktop of the developer. It contains a copy of the project from the repository. The developer works on that copy and commit the changes to the repository.
Revisions
each time an update is committed to the repository, a revision is created. The revision number starts at 1 and increase by one at each commit. You can recover old versions of files using the revision number.



Operations

Import
this operation allows to import local files in the repository to create a new project. This is usually done once when you want to version control an existing project.
Checkout
this operation is the opposite to the import operation. It allows you to retrieve for the first time all the files of a project from the repository.
Update
this operation synchronize the working copy directory and the repository. Conflicts may appear during this operation.
Commit
this operation is the opposite of the update operation. It updates the repository from the working copy and create a new revision. A log file is needed at this time to do the commit.



Installation of the Subversion server

The first step is to download Subversion here: download. I’ve successfully tested the installation using the package Setup-Subversion-1.5.3.msi.



Simply follow the installatin steps, it is pretty easy. Once installed, there is only one post-configuration step to do: add the system environment variable SVN_EDITOR et set it to a simple text editor such as Notepad (C:\WINDOWS\notepad.exe) or GVim for me.



Configuration of the Subversion repository

To create a Subversion repository, you can use the following command. I created my repository in D:\svnrepo:



>svnadmin create "D:\svnrepo"
 



Once done, open the file D:\svnrepo\svnserve.conf to configure access rights. Uncomment the lines “anon-access = read”, “auth-access = write” and “password-db = passwd”, and save the file.



### This file controls the configuration of the svnserve daemon, if you
### use it to allow access to this repository.  (If you only allow
### access through http: and/or file: URLs, then this file is
### irrelevant.)

### Visit http://subversion.tigris.org/ for more information.

[general]
### These options control access to the repository for unauthenticated
### and authenticated users.  Valid values are "write", "read",
### and "none".  The sample settings below are the defaults.
anon-access = read
auth-access = write
### The password-db option controls the location of the password
### database file.  Unless you specify a path starting with a /,
### the file's location is relative to the directory containing
### this configuration file.
### If SASL is enabled (see below), this file will NOT be used.
### Uncomment the line below to use the default password file.
password-db = passwd
...
...
 



Then, you can edit your D:\svnrepo\conf\passwd file to specify users/passwords allowed to access the repository:



### This file is an example password file for svnserve.
### Its format is similar to that of svnserve.conf. As shown in the
### example below it contains one section labelled [users].
### The name and password for each user follow, one account per line.

[users]
# harry = harryssecret
# sally = sallyssecret
rkalfane = mysecret
 



Starting the server and creating a project

To start the server, open a command-line and execute the following command:



>svnserve --daemon --root "d:\svnrepo"
 



Warning: don’t close this command-line or the server will stop. The next chapter will explain how to install the Subversion server as a service on Windows.



To create a new project, open a new command-line and execute the following command:



>svn mkdir svn://localhost/myproject
 



This command will launch a text editor so you can enter a description. Enter a description, save and close the text editor.



If you Subversion login is not the same as your Windows login, hit “Enter” to choose a different login and enter the password defined in the “passwd” file:



Authentication realm: <svn://localhost:3690> SVN
Password for 'usera':
Username: rkalfane
Password for 'rkalfane': ******** (mysecret)

Committed revision 1.
 



From now on, you won’t need to enter your user/password again.



Running the server as a service

To install SVN as a service, extract the content from the attached zip file and copy it to the bin directory of Subversion.



First, close the command-line windows where you launched the Subversion server. You can now install the server as a service using the following command:



>svnservice -install --daemon --root "d:\svnrepo"
 



The service is now installed and you can change the startup option from manual to automatic in Services and start it.



Check that the service is running by listing your projects in the repository:



>svn ls svn://localhost
/myproject
 



Installation of TortoiseSVN client

TortoiseSVN is the Subversion client I use on Windows. It is fully integrated with Windows Explorer and you can use all the commands from there.



You can download TortoiseSVN from here: download. Follow the installatin steps, again it is very easy.



Once installed, you can create a new directory on your filesystem such as “D:\temp\myproject”. Then right click in the directory and choose “SVN Checkout…”. You will have to specify the SVN URL and credentials to use:

  • URL of repository: svn://localhost/myproject
  • Checkout directory: D:\temp\myproject

SVN_Clipboard02.png



Your project has now been checked out to a working copy. You can now create new files, commit to the repository, etc.!



Subversion Usage

This section covers very quickly the usage of Subversion through the command-line. The same commands are also available in TortoiseSVN if you prefer a more visual interface! Please refer to the official documentation for more details.



Project Creation

Existing project in the repository

As we have seen, if the project exist in the repository, you can simply do a checkout to retrieve the content:



>svn co svn://localhost/myproject .
A  file1.txt
A  file2.txt
A  file3.txt
Checked out revision 10.
 



Import of existing local project in the repository

If you want to create a new project in the repository from an existing local directory, you can use the command “svn import”. Please check the official documentation for more information.



Using TortoiseSVN, I’ve been able to easily import content in the repository.



Retrieving project last version

To retrieve the last verison of the files, use the following command:



>svn update
U file2.txt
Updated to revision 10.
 



Committing local updates to the repository

To commit your local changes to the repository, you can use the following command:



>svn commit
Sending     file3.txt
Transmitting file data .
Committed revision 11
 



This command will first open a text editor so you can enter comments. You can also directly specify your comments in the command-line:



>svn commit -m "Added more lines."
Sending     file3.txt
Transmitting file data .
Committed revision 11
 



Retrieving older versions of a file

To recover the last verision on a file locally updated:



>svn revert file3.txt
Reverted 'file3.txt'
 



To retrieve an older version:



>svn update -r 9 file3.txt
U  file3.txt
Updated to revision 9.
 



Managing files

Adding a new file

To add a new file in the repository (effective only after a commit):



>svn add file4.txt
A  file4.txt

>svn commit -m "New file added."
Adding file4.txt
Transmitting data .
Commited revision 12.
 



Deleting a file

To delete a file in the repository (effective only after a commit):



>svn delete file4.txt
D  file4.txt

>svn commit -m "File deleted."
Deleting file4.txt
Committed revision 13.
 



Renaming a file

To rename a file, use the following command (effective only after a commit):



>svn move file3.txt file5.txt
A  file5.txt
D  file3.txt

>svn commit -m "File moved."
Deleting file3.txt
Adding file5.txt
Committed revision 41.
 



Resolving conflicts

During a commit, conflicts can appear if someone else committed a change just before. In that case, you will need to do a “svn update” and resolve the conflicts in your local file. Once done, you will be able to do a commit.



Additional features

There are a lot more features for advanced users such as tagging releases, branching to create a parallel development process (like a research branch) and merging this into the main development tree. Please check the official documentation for more details and examples.



Resources



VN:F [1.9.22_1171]
Rating: 0.0/5 (0 votes cast)

Tags:
Categories: Uncategorized

Disclaimer: This content is not supported by Novell. It was contributed by a community member and is published "as is." It seems to have worked for at least one person, and might work for you. But please be sure to test it thoroughly before using it in a production environment.

2 Comments

  1. By:anonymous

    “To install SVN as a service, extract the content from the attached zip file and copy it to the bin directory of Subversion. ” Where is the “attahced zip file”?

    VA:F [1.9.22_1171]
    Rating: 0.0/5 (0 votes cast)
    • By:rkalfane

      Hello,

      You’re right, the attachment was not here anymore… I re-added it, now it should appear in the attachments list.

      Have fun!

      Cheers,

      Réza

      VN:F [1.9.22_1171]
      Rating: 0.0/5 (0 votes cast)

Comment

RSS