For some time now I have wanted to play around with SubVersion. I have a college professor friend of mine who raved about it when it first came out some years ago. Finally, Scott Rosenbaum of the BIRT PMC convinced me to take a look at it a little more in depth.
The following instructions are centered around an Ubuntu 6.06 platform, so modify as you will for your platform of choice. First thing to do is to install Subversion. Using the Apt, it is a piece of cake. I drop to a root console and run “apt-get -f install subversion”, as indicated below:
root@digiassn-laptop:/usr/sbin# apt-get -f install subversion
Reading package lists... Done
Building dependency tree... Done
The following extra packages will be installed:
The following NEW packages will be installed:
0 upgraded, 2 newly installed, 0 to remove and 0 not upgraded.
Need to get 716kB of archives.
After unpacking 4342kB of additional disk space will be used.
Do you want to continue [Y/n]?
Get:1 http://us.archive.ubuntu.com dapper/main libsvn0 1.3.1-3ubuntu1 [513kB]
Get:2 http://us.archive.ubuntu.com dapper/main subversion 1.3.1-3ubuntu1 [203kB]Fetched 716kB in 2s (269kB/s)
Selecting previously deselected package libsvn0.
(Reading database ... 112788 files and directories currently installed.)
Unpacking libsvn0 (from .../libsvn0_1.3.1-3ubuntu1_i386.deb) ...
Selecting previously deselected package subversion.
Unpacking subversion (from .../subversion_1.3.1-3ubuntu1_i386.deb) ...
Setting up libsvn0 (1.3.1-3ubuntu1) ...
Setting up subversion (1.3.1-3ubuntu1) ...
One thing to note is I believe Apache 2 may be a pre-requisite or optional package. Since I already have Apache 2 and Tomcat installed for use with BIRT, these were not shown in the above transcript. Cool, now that it is setup, I noticed that there are not executables for it... strange. So I read the Subversion quick-start guide to get an idea of what I am doing. Aha, so there are command line tools and they are prefixed as svn... so we have an “Svn” to interact with Subversion, and an svnadmin to administer Subversion.
Here, I want to create a repository containing all my BIRT reports for a project I am working on. The first thing I do is create that repository using svnadmin. I want to call this repository “BirtReports” and store them under my home directory at /home/digiassn. Using my general account, I run the commands like so:
digiassn@digiassn-laptop:/etc/default$ svnadmin create /home/digiassn/BirtReports
digiassn@digiassn-laptop:/etc/default$ cd /
digiassn@digiassn-laptop:/$ cd home/digiassn/BirtReports/
digiassn@digiassn-laptop:~/BirtReports$ ls -alF
drwxr-xr-x 7 digiassn digiassn 4096 2006-09-23 18:21 ./
drwxr-xr-x 56 digiassn digiassn 4096 2006-09-23 18:21 ../
drwxr-xr-x 2 digiassn digiassn 4096 2006-09-23 18:21 conf/
drwxr-xr-x 2 digiassn digiassn 4096 2006-09-23 18:21 dav/
drwxr-sr-x 5 digiassn digiassn 4096 2006-09-23 18:21 db/
-r--r--r-- 1 digiassn digiassn 2 2006-09-23 18:21 format
drwxr-xr-x 2 digiassn digiassn 4096 2006-09-23 18:21 hooks/
drwxr-xr-x 2 digiassn digiassn 4096 2006-09-23 18:21 locks/
-rw-r--r-- 1 digiassn digiassn 229 2006-09-23 18:21 README.txt
OK, so I have a tool that creates a bunch of arbitrary directories. Well, not necessarily. It actually uses its own database to store your versioned files, so when I import them into Subversion, i wont get to see them. So, I want to check in my BIRT reports, which are stored at /home/digiassn/eclipse/workspace/OldReports. To check these files into Subversion, I can run the following command:
digiassn@digiassn-laptop:~/BirtReports$ svn import /home/digiassn/eclipse/workspace/OldReports file:///home/digiassn/BirtReports -m "BirtProject Initial Import"
Adding (bin) /home/digiassn/eclipse/workspace/OldReports/sguil_logo2.png
Committed revision 1.
Sweet, now I've stored my old reports into Subversion. So lets say I want to check these files out now. I can run the command below:
digiassn@digiassn-laptop:/$ cd /tmp
digiassn@digiassn-laptop:/tmp$ svn checkout file:///home/digiassn/BirtReports/
Checked out revision 1.
digiassn@digiassn-laptop:/tmp$ cd BirtReports/
DemoForBook EventsSummaryByIP.rptconfig GetStatusInfo.rptconfig IpEventDetail.rptconfig
eventsByStatus.rptconfig EventSummary.rptdesign GetStatus.rptconfig sguilLibrary.rptlibrary
eventsByStatus.rptdesign GetIPSummary.rptconfig GetStatus.rptdesign sguil_logo2.png
What was easy enough. So, back to the problem that triggered this. I wanted to checkout the files that Scott had on his super secret server so I can view a project he was working on. This was put online using a web server for viewing, so below is the transcript of how I pulled the project in question.
digiassn@digiassn-laptop:/tmp$ cd /tmp
digiassn@digiassn-laptop:/tmp$ mkdir gwt
digiassn@digiassn-laptop:/tmp$ cd gwt
digiassn@digiassn-laptop:/tmp/gwt$ svn checkout http://scotts_super_secret_server/gwt
...remaining files removed for brevity.
Checked out revision 28.
Pretty neat. I have seen CVS systems that can do the same thing, however. By looking in the documentation, there are tons of options for how to run Subversion. You can run a daemon to allow multiple repositories, add user authentication, and integrate authentication with SSH, plus a whole slew of other features.