Thursday, July 17, 2008

Subversion: Server: Setting up Svnserve

Subversion (SVN) is a version control system that is gaining wide popularity. I've been using TortoiseSVN as the client, which is easy to use and setup. However, I find that setting up the Subversion server (svnserve based) is not that straight-forward (although not really that difficult as well).

As such, based on my own experience, I've compiled a step-by-step guide to setup the svnserve based Subversion server, that could be useful for future use.

Note: This topic is more like a walk-through than a complete guidelines. And is basically based on the great documentations found on the TortoiseSVN website and various sources. You can refer the site for more explanation if needed.

This topic is separated into 3 sections:
  1. Server: Setting Up Svnserve
  2. Server: Setting Up Svnserve With SSH
  3. Client: Installation and Guidelines
Server: Setting Up Svnserve

Part 1: Installation

Note
: The following guide assumes the server's
- svnserve is installed in c:\svnserve\
- root folder for all repositories is in d:\svn_repos

  1. In Windows, login as Administrator.
  2. Install SvnServe (get the latest version from here).
    • If manual install:
      • Manually create a folder c:\svnserve\
      • Unzip and copy all the files/folders into the folder.
  3. Run the SvnServe:
    • If install as a service (automatically started when Windows starts): sc create svnserve binpath= "c:\svnserve\bin\svnserve.exe --service --root d:\svn_repos\" displayname= "Subversion" depend= tcpip start=auto obj= "NT AUTHORITY\LocalService"
    • If manual run, create and run a batch file (e.g. svnserver_service.bat):c:\svnserve\bin\svnserve.exe --daemon --root d:\svn_repos\
  4. Install TortoiseSVN (get the latest version from here).
    • Optionally, after installed, right click > Settings > General
    • Tick Use "_svn" instead of ".svn" directories
    • Tick Set fildates to the "last commit times"
  5. Create a root folder for all repositories in d:\svn_repos\.
  6. Create a repository trunk folder for the relavant project inside the root folder. (e.g. d:\svn_repos\Repo_Project1\Trunk)
  7. Right click on the folder and select TortoiseSVN -> Create Repository here.
    • Choose Native Filesystem (FSFS)
    • Do NOT choose Berkeley DB, especially use on a network share.
    • Do NOT modify the contents of the repository folder yourself.
  8. Authentication (modify and save with a Notepad):
    • Modify the 'svnserve.conf' file in the repository 'conf' folder (e.g. d:\svn_repos\Repo_Project1\Trunk\conf).
    • Paste the following after the last line:
      anon-access = none
      auth-access = write
      password-db = passwd
      authz-db = authz
    • Modify the 'passwd' file in the same folder to set user name and password.
      • Put your user-password pair after the last line. E.g.:
        harry = harrypassword
        user1 = user1password
    • Modify the 'authz' file in the same folder to set the path-based access control:
      • Put your user-authorize pair after the last line (r = read, w= write). E.g.:
        [/]
        harry = rw
        user1 = r
        * =
  9. Test (make sure the svnserve service is running): Anywhere in Windows Explorer, right click > TortoiseSVN > Repo-Browser to view a repository (e.g. svn://localhost/Repo_Project1/Trunk). Type the username and password when prompted.
  10. Optional: To create a backup copy of the repository:
    • In DOS prompt, type: svnadmin hotcopy path/to/repository path/to/backup --clean-logs
  11. Optional: Setup SvnServe using SSH. Refer the Setting up Svnserve with SSH.
Reference source: http://tortoisesvn.net/docs/release/TortoiseSVN_en/tsvn-serversetup-svnserve.html

Part 2: Repository Layout
  1. The repository basic folder structure can be created by:
    • Creating an empty folder with the folder structure inside, then TortoiseSVN > Import, or
    • Using TortoiseSVN repository browser
  2. It is recommended to create separate repositories for 'each' project. This allows independent development and to keep track on the repository's revision number.
  3. The recommended directory structure:
    • trunk : To hold the "main line" of development
    • branches : Contain branch copies
    • tags : Contain tags copies
    • For details, refer here.
Reference source: http://tortoisesvn.net/docs/release/TortoiseSVN_en/tsvn-dug-import.html

Reference: File Version Used:
Subversion (svn): 1.4.5
TortoiseSVN: 1.4.8.12137 (win32)


Additional Resources:
Subversion: Post-Commit Email Notification



If you find this post helpful, would you buy me a coffee?


No comments:

Post a Comment