tisdag 11 oktober 2005

Setting up Subversion

This is meant as a no-nonsense guide to setting up Subversion, the excellent open-source version control system. It is aimed at software developers who are familiar with version control in general, and want to quickly try Subversion without having to sift through all of the documentation pages. It is assumed that you will run the Subversion server on a Unix-like system, and that you will access the repository using TortoiseSVN, a very nice shell extension and user interface for Windows. For those with more time to spare, I recommend reading parts of the free on-line book Version control with Subversion. So let’s dig into this task and you should be up and running within minutes!
  • First of all, make sure that Subversion is installed. In a prompt, type:
    svn
    You sholid get something like this as a response:
    Type 'svn help' for usage.
    If the command is not recognized, you’ll have to install the packages for your distribution. If you run a reasonably recent release of Fedora Core, you should be able to just type:
    yum install subversion
  • Next, you’ll have to make sure that Subversion is automatically launched on boot. How to accomplish this task depends on your operating system and distribution. If you run Fedora Core, a quick and dirty way is to locate the file /etc/rc.d/rc.local (create it if it does not exist) and add the following:
    svnserve -d
    If you want to run the server as a user other than root, which you may consider for security reasons, please consult the documentation for your operating system. Server security is beyond the scope of this document.
  • Now you’ll have to decide which user should own the repository. If you want, you can create a dedicated user. Log in as that user and type the following (substitute johndoe for the user, johnsfiles for the name of the repository that you want to create, and /home/johndoe for the intended parent directory):
    cd /home/johndoe
    svnadmin create johnsfiles
    mkdir files
    mkdir files/branches
    mkdir files/tags
    mkdir files/trunk
    svn import files file:///home/johndoe/johnsfiles -m “Imported the root directories.”
    mv johnsfiles/conf/svnserve.conf johnsfiles/conf/svnserve.conf.original
  • Create the file johnsfiles/conf/svnserve.conf and add the following:
    [general]:
    password-db = users.conf
    realm = John Doe’s File Repository
    anon-access = none
    auth-access = write
  • Then create the file johnsfiles/conf/users.conf and add (substitute 12345 for the desired password):
    [users]
    johndoe = 12345
  • If you use a router and want people from outside of your local network to have access to the repository, you’ll have to configure the router to forward port 3690 (TCP and UDP) to the same port on your host.
  • Now we’ll switch to Windows. Make sure TortoiseSVN is installed. It requires a reboot following installation, after which additional menu items are visible when right-clicking on folders and files.
  • Create a new folder using Explorer, with the name of your choice.
  • Open the new folder, and then right-click inside it. Select SVN Checkout....
  • In the dialog that now opens, enter the following address under URL of repository: (exchange 192.168.1.2 for the IP address or name of your Unix host):
    svn://192.168.1.2/home/johndoe/johnsfiles
  • Click OK. The three special folders branches, tags and trunk should now be created. For the purpose of each, refer to the Subversion documentation. The short version is that trunk is where you should normally be working.
That’s it! You can now create the files and folders of your choice in trunk and import them to the repository using the menu items provided by TortoiseSVN. Be sure to explore other menu items as well. If you are familiar with other version control systems, the purpose of many of them is probably fairly obvious to you.
I hope this helped