In software companies, a code is developed in parts by different software
developers. The code that is finally optimized and delivered to the client is
more or less an assimilation of the isolated code generated by these developers.
As these different packets pass through different levels, chances of inadvertent
errors creeping in become high. So it is necessary to keep track of the code and
ensure that unwanted mistakes can be reverted back without hassles. To ensure
this as well as improve the speed at which documents are processed, you need a
software utility that can keep track of all this and notify developers in case
the same line is edited by more than one developer. Subversion is one such Open
Source and free tool that is conceptually very similar to Concurrent Version
Control (CVS). It consists of a repository of data located at the server and a
copy for the required document kept at the user end, known as local copy.
Whenever someone wants to edit the content of the document, he edits the local
copy, keeping the original copy intact. After the changes have been done, the
copy stored on the repository is updated. A good thing about this software is
that unlike CVS, the tool commits the changes only if the entire commit process
is completed or else it doesn't. This helps in situations when a network failure
occurs while committing changes. In this article we show you how to implement,
configure and use this version control system.
Direct Hit! |
Applies To: Network and security managers USP: Monitoring machines with OSSEC Primary Link: www.ossec.net Google Keywords: HIDS, OSSEC |
Installation & configuration
For implementing subversion, one has to install Apache 2.0, Subversion 1.4.5
and Tortoise SVN on the system. You can get the Apache 2.0 installation file
from Apache website and the rest from the link: http://svnbook.red-bean.com/.
Apache, we all know is a Web server, Subversion is the tool that will take care
of the entire version control system and Tortoise SVN is a subversion client
that provides graphical interface to the user who will be using this version
control system. Installing these three tools is pretty simple; all of them come
with an easy to use installer for Windows.
After you have installed these, a bit of tweaking is needed to get things going.
Navigate to the Subversion folder through Windows Explorer, generally found
under 'C:\Program files\.' Copy the files '/httpd/mod_dav_svn.so' and
'mod_authz_svn.so' to Apache's module folder found under 'C:\Program
files\Apache group\apache2\.' Also copy '/bin/libdb43.dll' file to Apache Module
directory. Open up Apache configuration file 'httpd.conf,' which can be found
under Apache directory and look for the following lines:
In the 'Working copy' folder, you can check the status of documents that have been updated on the repository |
#LoadModule dav_fs_module modules/mod_dav_fs.so
#LoadModule dav_module modules/mod_dav.so
If these lines are marked as comments, then remove the '#' character. This is
done so that whenever Apache server starts, these modules are loaded along.
Further, add the following lines at the end of the 'LoadModule Section' in
Apache's configuration file:
LoadModule dav_svn_module modules/mod_dav_svn.so
LoadModule authz_svn_module modules/mod_authz_svn.so
Now configure Apache so that it can handle the Subversion client, ie
TortoiseSVN request and the URL that is should use for Subversion repository.
Open the Apache configuration file and add the following lines at the end of the
file:
DAV svn
SVNListParentPath on
SVNParentPath D:\SVN
AuthType Basic
AuthName "Subversion repositories"
AuthUserFile passwd
#AuthzSVNAccessFile svnaccessfile
#Require valid-user
For simplicity, we have ignored the line 'Require valid-user,' which is
basically used for user authentication whenever someone wants to access the
repository. The first line tells Apache that Subversion repository is available
through the following URL; 'http: //
repository is specified on the 4th line of the code provided above. So, if the
repository is in 'svn' directory, which is under D: drive, then the path will be
'D:\SVN'.
To update changes, made to the local copy of a document, on the repository, right click on 'working copy' folder and click on 'Update to revision' |
Working with Subversion
To get working with this version control tool one has to create at least one
repository. A repository is a place where electronic data is stored and
maintained for a specific purpose. For creating the repository, create a folder
in D: drive and name it as 'svn'. Right click on the newly created folder and
select TortoiseSVN > Create Repository here. It will ask 'select the type of
repository you want to create.' In our case we chose BDB. Once the repository is
created, one can see different files inside the 'svn' folder. These are
configuration and settings files, so please don't edit them or else it'll give
errors.
After the repository has been created, one needs to import data to the
repository. But before that, one should organize the repository so that data can
be maintained easily later on. Most of the organizations use three different
directories to maintain the development cycle. The first is the 'trunk'
directory that contains the final version of each code or document, second is
'branches' which contains the copies that are distributed among developers to
work on and the third is 'tags' which contains the tagged copies. For better
understanding of subversion we will create only one folder, named 'repo.'
Importing data to the repository is pretty simple. Create a new folder on the
desktop and name it 'test.' Copy the file which you want to add to the
repository to this newly created folder. For example, we copied six different
text files to this folder. After this, right click on the 'test' folder, go to
Tortoise SVN > Import. A dialog box opens up asking the URL of the repository
where you will be importing files. Provide the URL and click on 'Ok' to add up
the files. TortoiseSVN then imports the complete directory tree including all
files to the repository.
In Log Messages, you can view the time and date of changes made by different developers on a particular software code |
To obtain a working copy on your system you need to do a 'checkout' from the
repository, which means you need to get the working copies from the repository
to your system. For this create a folder and name it is as 'Working Copy.' Right
click on the newly created folder and go to TortoiseSVN > Checkout. A 'Checkout'
dialog will appear asking the URL of the repository, where you can also see the
path to 'Checkout Directory'. Click on 'Ok' to get working copies. In the next
window it will show the files and folders that are being copied to the 'Working
Copy' folder and the final status. Now the files that you want to work with are
in the 'Working Copy' folder.
After one has finished working on a particular file, the changes should be
made to the repository as well. Before committing or making the change to the
repository, one should check whether the copy he or she has is up-to-date or
not. For this, right click on the 'Working Copy' folder and go to TortoiseSVN >
Update. If the copy you have is up-to-date then there will be no conflict and
you can commit the changes. For this, right click on the same folder and go to
TortoiseSVN > Commit.
Use the TortoiseMerge tool to simultaneously view changes made to different versions of the code by different developers |
A conflict occurs when more than two people change the same line in a
document or a code. Now this tool doesn't know anything about the document or
the developer's code that has been modified, as it doesn't understand what is
right and what is wrong. To check yourself, open up the document which has
conflict and you'll notice the conflict area marked as:
<<<<<<< filename
your changes
=======
code merged from repository
>>>>>>> revision
So, wherever any conflict happens, this version control tool generates three
different file into the 'Working Copy' folder: one is your current working copy;
the second is the older version of your working copy, i.e. the copy before your
last update; and the third is the copy that has just been received from the
repository, ie after you've updated the current working copy.
To solve this conflict, open the 'Conflict Editor.' For this, right click on
the file that shows conflict and go to TortoiseSVN > Edit Conflict. Make the
necessary changes to the code, ie retain the lines that you feel are right and
delete the ones that are useless. After you've done the modifications, save the
file. For this, right click on the modified file and go to TortoiseSVN >
Resolved. Finally, save the changes to the repository.