[ad_1]
I used to work in an organization where I had no choice but to use PVCS for version control for all projects. I still remembered how long it took to commit all changes or to check out a project from PVCS. CVS was then introduced to my team and I could see some improvement however it still had some weaknesses. For example, two people are committing changes at the same time and a change conflict occurrs. In this case, some files will have been updated, while others been refused, which leaves the repository in an unstable state. CVS was however used in my team for a while until Subversion was introduced. Subversion is probably one of the best open source version control systems since it was designed to overcome the shortfalls of CVS.
CVS keeps track of individual file versions. In CVS, when you commit a set of changes, each modified file is updated separately. Subversion, by contrast, keeps track of revisions. A revision is a representation of the repository structure and contents at a given point in time. Updating the Subversion repository is a bit like updating a relational database using transactions. Either all of your changes are updated in the repository, or none are if there is a conflict. If you hate CVS, consider Subversion.
I will describe a step by step instruction to set up a Subversion system on a local machine.
1. Install Subversion server
- Install Subversion on Ubuntu:
Open a Terminal and execute the following command:
$ sudo apt-get install subversion libapache2-svn
Or using the Synaptic Package Manager:
Go to System -> Administration -> Synaptic Package Manager
Type subversion in Quick search and select subversion checkbox.
Click the Apply button on the toolbar and accept all the default.
- Install Subversion on Windows:
Get Windows binaries from Subversion website
Select CollabNet and download CollabNet Subversion Server and Client v1.6.6 (for Windows)
You need to create an account with CollabNet before you can download the installer file
2. Setting up a Subversion Repository:
There are 2 different storage systems for Subversion repository: Berkeley DB database and flat filesystem known as FSFS. To create a Subversion repository, you use svnadmin create command. By default, this will set up an FSFS repository at the specified location.
- $ svnadmin create /home/vietma/svn_repository/dev_repos (Linux)
- C:>svnadmin create D:svn_repositorydev_repos (Windows)
You can use –fs-type option to specify a Berkeley DB:
$ svnadmin create –fs-type bdb /home/vietma/svn_repository/dev_repos
3. Create a new Java project
You create a new Java project in your usual way. In this example, I use Maven 2
You can download Maven 2 (apache-maven-2.2.1-bin.zip) from Apache website and extract the file in a directory of your choice on Windows OS. If you use Ubuntu, you can use the Synaptic Package Manager to install maven2 similar to subversion as described in step 1 above.
Change to a temporary folder where you can temporarily create the project.
- $ cd /home/vietma/tmp (Linux)
- $ mvn archetype:create -DgroupId=com.example.myproject -DartifactId=myproject (Linux)
- D:tmp>mvn archetype:create -DgroupId=com.example.myproject -DartifactId=myproject (Windows)
4. Initial import of the created project directory into Subversion:
- $ svn import myproject file:///home/vietma/svn_repository/dev_repos/myproject/trunk -m “Initial import of myproject” (Linux)
- D:tmp>svn import myproject file:///d:/svn_repository/dev_repos/myproject/trunk -m “Initial import of myproject” (Windows)
5. Delete the temporary project myproject from /home/vietma/tmp or D:tmp
6. Check out the clean project from Subversion.
You can use TortoiseSVN to check out the source code but I prefer to use the command line
- $ cd /home/vietma/projects (Linux)
- $ svn checkout file:///home/vietma/svn_repository/dev_repos/myproject/trunk myproject (Linux)
- D:projects>svn checkout file:///d:/svn_repository/dev_repos/myproject/trunk myproject (Windows)