Sunday, May 31, 2009

Subversion - Checking out a Project

Overview
When it is time to get work done, code will need to be checked out. The main steps to checkout code that was imported as described in a previous post is as follows:
  • Create a workspace folder for your project
  • Change directory into that folder
  • Checkout code from the trunk (or tag or even branch) into the current directory.
Procedure
The following steps will checkout the sqlbuilder project that is part of the perl repo into my local filesystem's sqlbuilder folder.

Create new folder called sqlbuilder. My code is targeted to be on my local file system in a base directory of ~/work/perl/sqlbuilder

cd ~/work/perl/
mkdir sqlbuilder
cd sqlbuilder

svn checkout https://www.inhouse.stoken.net/repos/perl/sqlbuilder/trunk/ ./

Now your code is in a subversion managed folder.

Tagging Current Trunk
Tagging is a common practice in which you create a snapshot of your code as it stood in time or within a version. In this example, the sqlbuilder code needs to be tagged. The tagged version will be stored in the repo within a 20090528 folder.

svn -m 'tagging first release' copy https://www.inhouse.stoken.net/repos/perl/sqlbuilder/trunk/ https://www.inhouse.stoken.net/repos/perl/sqlbuilder/tags/20090528

Use a browser to view trunk and tag using the above URLs.

Final Thoughts
The process of checking out a tagged version is the same as for a trunk version, just ensure that the URL path is correct and it will work.

I personally tag frequently in Subversion since Subversion does it pretty efficiently. Your thoughts may vary on this.

This concludes the series on basic Subversion usage. When I have time, I will post something on Subversion + Netbeans. Netbeans handles Subversion very well but there are few small details that may help. I will post them soon.

Subversion - Importing a new Project

Overview
Once a repo has been created, it is time to import your code. This has only a few main steps.
  • Create a base directory within the repo with the project name
  • Build the standard subversion project tree (tags, branches, trunk)
  • Import code into trunk
Procedure
In this example, I have created a simple helper project called sqlbuider.

As described above, the first step is to create the base directory within the repo.
svn mkdir -m 'adding new project area' https://www.inhouse.stoken.net/repos/perl/sqlbuilder

Next, the standard subversion directory tree needs to be created.
svn mkdir -m 'adding new project area' https://www.inhouse.stoken.net/repos/perl/sqlbuilder/branches
svn mkdir -m 'adding new project area' https://www.inhouse.stoken.net/repos/perl/sqlbuilder/tags
svn mkdir -m 'adding new project area' https://www.inhouse.stoken.net/repos/perl/sqlbuilder/trunk


If you are building your repo as you are reading along, you should be able to point your browser to it and see an empty folder for .../tags .../trunk .../branches

We are ready for the next step, Import the project. On the local system, change directory to local project folder (sqlbuilder in my case) and import. My local source happens to be in ~/work/perl/sqlbuilder. Subversion doesn't care about the location. Just that you are sitting in the project folder. The following will import the project

cd ~/work/perl/sqlbuilder
svn -m 'inital import' import ./ https://www.inhouse.stoken.net/repos/perl/sqlbuilder/trunk/

The command says, "using the message of 'initial import', import everything in ./ to https://..../trunk/

If you refresh your broswer in the trunk folder, you will see code.

Normally, I will take my local directory (sqlbuilder in my case) and rename it to something like sqlbuilder_pre_svn or sqlbuilder_old.

This process can be followed for multiple projects within the same repo. Just create the directory structure and then import your code into it.

When you are ready to work on the project, you will want to create a new sqlbuilder folder and checkout the https://..../trunk/ code into it. That will be described in my next post.

Final Thoughts
Why not import the folder sqlbuilder? Why import just the contents of the folder into trunk? The main reason is that it simplifies situations where you may have one or many versions of the same project checked out. Now you can checkout a trunk or tag version into whatever directory you want. It makes things easier to deal with. The only thing to remember is to check out after you create a local workspace folder before checking out into it.

The next post will describe howto check out and tag code.

Subversion - Adding a new Repo

Overview
Based on my previous post, you should now have a working and configured Subversion environment. Most of the work was done in Apache.

Now a repo is needed to store all related projects. Subversion is pretty flexible here. You can create a repo per project, on single repo for everything, or do what I do. Create a repo per language you work in. For example:
  • /opt/intranet/svn/python/
  • /opt/intranet/svn/ruby/
  • /opt/intranet/svn/java/
  • /opt/intranet/svn/php/
The amount of repos is up to you.

Procedure
For this example, I am adding a new repo for my perl code projects. All my repos are stored in /opt/intranet/svn/

to create a new repo:

• cd /opt/intranet/svn
• svnadmin create perl
• chown -R apache:apache perl/

Within each repo, one or many projects. The following shows how to prepare and import files into a new project.

Final Thoughts
With this repo created, new projects can be added.

Saturday, May 30, 2009

Subversion - Setting up Apache and Users

Overview
Subversion is a fantastic source control system. Not only is it pretty easy to setup and use but it also integrates with a vast list of IDEs.

This post describes how to setup the base environment for Subversion. This consists of:
  • Apache Configuration
  • Apache Web Server User
Other posts will cover adding repos.

My environment:
  • Internal access only
  • linux/Unix environment
  • Apache + Subversion
Configuring Apache With Subversion
When you install Subversion, there will be a default subversion.conf file setup (most likely) in /etc/httpd/conf.d/ for Apache

Within the environment I use, the following file system structure is used:
  • /opt/intranet/svn - Main area for subversion repos. Local file system.
  • /repos - Apache reference to Parent Path
  • /opt/intranet/svn/users.passwd - Location of subversion user/password file for any/all repos.
What to modify in your /etc/httpd/conf.d/subversion.conf to get it to work like the one described below.

# START OF CONFIG
<Location /repos>
DAV svn
SVNParentPath /opt/intranet/svn

# Limit write permission to list of valid users.
<LimitExcept GET PROPFIND OPTIONS REPORT>
# Require SSL connection for password protection.

SSLRequireSSL
AuthType Basic
AuthName "StoKen Software Subversion"
AuthUserFile /opt/intranet/svn/users.passwd
Require valid-user
</LimitExcept>
</Location>

# END OF CONFIG

Adding a Subversion User
# htpasswd -c /opt/intranet/svn/users.passwd thawk
New password: mypassword
Re-type new password: mypassword
Adding password for user thawk

Final Thoughts
With this step complete, subversion is ready but will not do anything interesting until you add some repos. But that is another post...

POLL: What Persistance Engine Do you Use? (Results)

  • 50% Java Persistence API
  • 37% Hibernate (Java)
  • 25% NHibernate (.NET)
  • 0% LINQ (.NET) 0 (0%)
  • 12% ActiveRecord (Ruby)
  • 12% Other
Poll closed 04/02/2009

POLL: What JAVA Do you use? (Results)

This was not much of a surprise. SUN Java is the way to go. I just hope Oracle continues the to support JAVA like SUN did.
  • 90% SUN Java (linux/Windows)
  • 5% OpenJDK
  • 0% SUN Java (OSX)
  • 5% IcedTea (linux)
Poll Close 04/24/2009