Home Hosting Domains IT Services Support Contact Us
MyAccount PortalClient AreaAnnouncementsKnowledgebaseSupport TicketsDownloads

Knowledgebase
You are here: MyAccount Portal > Knowledgebase > Control Panel > WHM (WebHost Manager) > Using Subversion/SVN on cPanel Servers

Using Subversion/SVN on cPanel Servers

Subversion is a free/open-source version control system. This article will explain you about how to use subversion in linux servers mainly cpanel servers. Subversion uses copy-modify-merge model for its working.

Access Methods :

Subversion repositories can be accessed using different methods.

Syntax             Access Method
————————————
1. file:///    direct repository access (on local machine)
2. http://            access via WebDAV protocol to Subversion-aware Apache server
3. https://    same as http://, but with SSL encryption.
4. svn://            access via custom protocol to an svnserve server
5. svn+ssh://    same as svn://, but through an SSH tunnel.
————————————

1. If you are accesssing the subversion repository from the local machine, use the following syntax to access the file.

$ svn list file:///path/to/repos.

For eg: If you have ssh access to the server, login to the shell and repository contents can be listed as,

$svn list file:///home/testuser/testrepo

The command ‘list’ will display the repository contents.

2. We can use http URLs to access svn repository.

$svn list http://domainname/path/to/repository

If you have any space in the URLs used, give the URLs in quotes,

$svn list “http://domainname/path with space /to/repository”

This will take the URL as a single argument to svn program.

Note : As we are not using a Subversion-aware Apache server, it is not possible to access repository from our server directly using http(or https).

3. You can access the svn repository from our server using svn+ssh method, like

$svn list svn+ssh://username@domainname/home/username/public_html/testrepo/

Creating a new subverion repository in your home directory on our server:

$svnadmin create /path/to/repository

You can have your own working copy of a project. Your working copy is your own private work area. Subversion will never add other people’s changes, nor make your own changes available to others, until you explicitly do so. After making changes to the working copy, you can publish the changes to the repository. You can also merge the changes made by other people to your working directory.

You can create a private copy of an existing project using ‘checkout’ command.

$svn checkout /path/to/project

Usually we start working on a project by using a working copy.

To publish changes, use the ‘commit’ command.

$svn commit -m “changes made in file”

After -m, we are mentioning a note of the changes made to the file.

If you want to update others changes to your working copy, use the ‘update’ command.

$svn update

You can add new files to the subversion repository using the import command.

$svn import file:///path/to/repos -m “Initial import”

For eg, to import files in your local machine to a repository created by you on our server,

$svn import -m ‘Initial Import’ svn+ssh://username@domainname/home/username/testrepo

You will get error “svn: ‘.’ is not a working copy” if the path mentioned for the repository is not correct.

Recommended repository layout :

Subversion’s flexibility allows you to create your repository in any way, but the recommended way is to create a trunk directory to hold the “main line” of development, a branches directory to contain branch copies, and a tags directory to contain tag copies, like

$svn list file:///path/to/repos
/trunk
/branches
/tags

A small description of svn commands :

* Update your working copy
$svn update

* Make changes
$svn add 

Add file, directory, or symbolic link to the existing repository.

$svn delete

Delete file, directory, or symbolic link from the repository.
$svn copy

Create a new file file2 as a duplicate of file1 and automatically schedule file2 for addition.

$svn move

This command is exactly the same as running svn copy file1 file2; svn delete file1.

* Examine your changes
$svn status
$svn diff

* Possibly undo some changes
$svn revert

* Resolve Conflicts (Merge Others’ Changes)
$svn update
$svn resolved

* Commit your changes
$svn commit

Creating users to access the subversion repository using authentication(Using Access Method 4):
————————————————————————-

We can give access to some authenticated users to the repository using the
svnserve daemon. Suppose that you have created a test repository /home/username/testrepo.
Add the following lines in /home/username/testrepo/conf/svnserve.conf.

======================
[general]
anon-access = read
auth-access = write
realm = Test Repository
password-db = passwd
======================

By this anonymous users will have read access and only authenticated users will have write access to the repository. The realm is a name that you define. The authenticated user’s details are mentioned in the file ‘passwd’ in the same directory as that of the configuration file(/home/username/testrepo/conf/passwd).

passwd file :
======================
Username = testpass
======================

Now users can use these login details to write to the repository from shell. For this, svnserve daemon should be running on the server. If it is not running serverwide, you can start svnserve daemon as follows.

#svnserve -d -r /home/username/testrepo/

Using the -r option effectively modifies the location that the program treats as the root of the file system space it can access.

Now you can access the repository as follows.
==================================
# svn import -m ‘Initial Import’ test svn://domainname/testrepo/
Authentication realm: Test Repository
Password for ‘root’:
Authentication realm: Test Repository
Username: Username
Password for ‘Username’:
Adding test/test.html

Committed revision 1.
==================================

At first when it prompt for root password, just enter without giving anything. Then you can give username and password. Svn will cache the login from a particular IP and will not prompt for password every time that user access the repository. The passwords are cached in the directory /home/username/.subversion/auth. It is not insecure as the ‘auth/’ caching area is permission-protected so that only the user(owner) can read data from it, not the world at large. If that’s still not safe for you, you can disable credential caching by uncommenting the line ’store-auth-creds = no’ in the file /home/username/.subversion/config.

Note :
Currently we are not running svnserve daemon all the time on the server. If we are permitting users to run the svnserve daemon to a particular repository, it will make a conflict if another user try to run this daemon under their repository.

To ensure that the svnserve gets started whenever the server is booted, we must add a @reboot line to the root crontab as follows.

———————————
@reboot svnserve -d -r /home/
———————————

Now any user’s repository under /home can be accessed using svnserve daemon by authentication.

Reference :
http://svnbook.red-bean.com/en/1.4/svn.intro.whatis.html



Was this answer helpful?

Add to Favourites
Print this Article

Also Read


Network Status Client Area Knowledgebase Datacentre  
 
Terms of ServicePrivacy PolicyCustomer Security