Building a Development Environment Part 1: Managing your sourcecode with Subversion

November 4, 2006

This first installment in a series of posts about building a development environment is about repository lay-out and getting the code out of your source control system.

I originaly was planning on writing a series of articles about how we implemented continuous integration (CI). However, while experimenting and searching the internet for information, I quickly came to the conclusion that this whole CI thing was just to narrow in scope. There is a lot of information and a lot of blogs discussing CI, but most of them are people starting to write a simple application and them being the only one working on it. So, no projects made of multiple subprojects, no projects shared by other projects, no developer interaction, etc…

But in a real company you do have several developers, you do enable reuse and thus use a project in multiple other projects, you do have organisational standards (how projects must be setup, where code must be commited in the source code repository, etc…) that must be applied, etc… Some of this interacts with CI and this is way I made the scope of the series bigger:

How Do I Build An Environment To Develop Software?

Disclaimer

This post is by no means “The Way” of building a development environment. In fact, you will notice that at times I deviate from some of the practices advocated by the referred articles at the end of my articles. It’s our interpretation of the process and how we implement it. If you have any remarks or suggestions for improvement, please post a comment.

Tooling used

  • Subversion (version 1.3.1): This is the source control application and is run on the source control server for central code management and the client part is on the developer box for retrieving the code to wrk on the application.
  • TortoiseSvn (version 1.3.5.6804): This is an optional but very handy tool for windows shell integration of the Subversion client.

Installing the software

Installing the software is a no brainer. Just download the installation packages and execute them. The Subversion installation will add the path to the binary folder to your path environment variable. So you can execute commands directly in any folder.

Organizing the source control server

A universal thruth: “Everything must be seen in it’s proper context”. Weather it’s a real life event, a program method call or software proces. So here’s our context:

We are a shop with a few developers working mostly on a few products but which are closely related. So we have some code that is used in all our products, and some code that is just for a single product. However, this being “code for a single product” is relative: it might be that this code eventually wil end up in some other product. So, we treat all our products as being a collection of modules that could be reused.

The products evolve mostly by customer driven changes which can be implemented in a rather short timeframe. However, there are also sometimes major adaptations which take a long time to implement. What this all comes down to is that we don’t want an integration failure of a long term project jeopardize the integration of a short term project or vice versa. So for each project we create a codeline on the source control server which is completely seperate from eachother and from the main codeline.

Also, we would eventualy like to implement CI. And in this CI we will monitor of course our main code line and the project codelines. However, we do not want to monitor any release folders because the code placed in there is allready integrated: that code comes from the main code line or project code lines.

Thus the layout of our code lines is like this:

repolayoutv4.gif
So, why exactly is it like this?

We have four basefolders in the root of our repository:

  1. Main: this is what the Subversion documentation calls “Trunk”
  2. Projects: this is a folder where we branch our sources for long term development, experiments, etc…
  3. Release: this is where we put our released sources. Subversion typically names this folder “Tags”
  4. Extern: this is where we put libraries from external sources

Main
The Main folder has three subfolders: Core, Product and Unittest.

The Core folder contains the modules we develop. A module is a group of sourcecode files which produce one single target file of type exe or dll.
The Product folder contains subfolders with the name of the Products we develop. It contains Visual Studio solution files which represent components out of which the product exists and the buildscripts for the product.
And the Unittest folder contains the same Module folders as the Core folder but extended with Unittest to indicate thaht they are test modules.

Projects
The Project folder has subfolders for each project we are currently working on. These project folders have the same structure as the Main folder: they also have subfolders Core, Product and Unittest.

This is logical:
If the project is adding a new feature to an existing product, then this folder contains the modules that make this product.
If the project is about making a new product, then again it contains the existing modules that are used by this new product and some new modules which are not yet in the Main codeline.

Release
This folder contains, as subfolders, all existing modules. As subfolders of these module folders, we have the release folders. They are named after the release label and contain the sources for that release.

Extern
This folder contains, as subfolders, all external modules. As subfolders of these module folders, we have the release folders. They are named after the complete version number of the external component. If you would for example use Nant as an external library, then your subfolder might be named “0.85-rc4″

Let’s get praticle

So, after this explanation of our code management strategy, let’s get our hands dirty and implement it.

Organising our experimentation environment
In practice, we can have a seperate Build Server, Source Code Management Server, and of course seperate Developer Workstations.

Me, I only have one portable computer. So, to be able to simulate all these computers, I simply used a few folders:

simulation.gif

The devenv folder is simply a folder on my computer that I have made to experiment with developing a DEVelopment ENVironment
The buildsrvr subfolder mimics our BUILDSeRVeR and the scmsrvr folder mimics our Source Code Management SeRVeR.

Configuring Subversion
We do not only have to organise our sourcecode, but also the access rights of our code repository. But for this we first need a repository.
Execute the following on the commandline:
(You can of course use your own folder and drive letter)

svnadmin create D:\Serge\Devenv\simulation\scmsrvr\data

Now that we have a repsoitory, we will have to access it. We use svnserve to make our repository available. I’ve made a simple batch file with following line in it:

svnserve –daemon –root D:\Serge\Devenv\simulation\scmsrvr\data

Now we can set the access rights to it.
In the folder D:\Serge\Devenv\simulation\scmsrvr\data\conf we have three files which provide this functionality:

  • svnserve.conf: this files contains some default security settings (like anonymous access) and where to find the users and their passwords
  • authz: contains the users
  • passwd: contains the passwords

The svnserve.conf file looks like this

### This file controls the configuration of the svnserve daemon, if you

### use it to allow access to this repository.  (If you only allow

### access through http: and/or file: URLs, then this file is

### irrelevant.)

 

### Visit http://subversion.tigris.org/ for more information.

 

[general]

### These options control access to the repository for unauthenticated

### and authenticated users.  Valid values are “write”, “read”,

### and “none”.  The sample settings below are the defaults.

anon-access = read

auth-access = write

### The password-db option controls the location of the password

### database file.  Unless you specify a path starting with a /,

### the file’s location is relative to the conf directory.

### Uncomment the line below to use the default password file.

password-db = passwd

### The authz-db option controls the location of the authorization

### rules for path-based access control.  Unless you specify a path

### starting with a /, the file’s location is relative to the conf

### directory.  If you don’t specify an authz-db, no path-based access

### control is done.

### Uncomment the line below to use the default authorization file.

authz-db = authz

### This option specifies the authentication realm of the repository.

### If two repositories have the same authentication realm, they should

### have the same password database, and vice versa.  The default realm

### is repository’s uuid.

realm = CodeRepository

The authz file looks like this

[groups]

 

[/]

autobuild = rw

serge = rw

* = r

 

Read access to anyone
Allthough in the svnserve.conf file we added the line “anon-access = read”, in the authz file you still have to add the line “* = r” (see last line of the file). In the file created by svnadmin when creating the repository this line siimply says “* =” which translates to everybody having no access to the root.

We will eventualy setup CI in this series and will use Cruisecontrol.NET. Cruisecontrol.NET uses the log command of subversion to decide if something changed in the repository, and thus if an integration must be build. Unfortunatly, this subversion command fails with a message “Item is not readable” if you didn’t provide read access to the root for anyone in the authz file. It even fails if you logged on to subversion with an account having read/write access rights.

It took me a wilhile to find this because one would think that providing read access to anonymous users and read/write access to others would be enough. However, it apparently is not sufficient. It somehow looks like logging the repsoitory history uses an anonymous account. I do not know if this is me or if it is a bug in subversion.

The passwd file looks like this

[users]

autobuild = autobuildpwd

serge = sergepwd

If we now start the batch file created above, our repository is available and we can create the folder structure described above in our repository using TortoiseSVN or by executing following commands in a commandline window:

svn mkdir -m “Main folder” svn://localhost/Main

svn mkdir -m “Core folder” svn://localhost/Main/Core

svn mkdir -m “Product folder” svn://localhost/Main/Product

svn mkdir -m “Unittest folder” svn://localhost/Main/Unittest

svn mkdir -m “Projects folder” svn://localhost/Projects

svn mkdir -m “Release folder” svn://localhost/Release

svn mkdir -m “Release folder” svn://localhost/Extern

Conclusion

Well, that’s it for this entry. In the next part we will setup CruiseControl.NET to monitor any changes in our repository. See you then…

Resources

[1] Subversion.
[2] Version Control with Subversion
[3] Subversion Version Control: Using the Subversion Version Control System in Development Projects. There is a downloadable version available by following the Downloads link on the books page.
[4] TortoiseSVN
[5] Streamed Lines: Branching Patterns for Parallel Software Development
[6] The Joel on Software Discussion Group – Source Control and VS.NET
[7] Blogtastic – How to setup a .NET Development Tree Wrapup
[8] Better Builds with Maven

Updates

4 November 2006: original version
27 November 2006: added some references
10 januari 2007:

  • restructured the Core folder: it now is made of several subfolders which contain modules, and modules can have only one buildresult, either an executable or dynamic library.
  • Added commands to execute on commandline to build the repository.
  • Added support for external libraries
About these ads

4 Responses to “Building a Development Environment Part 1: Managing your sourcecode with Subversion”


  1. [...] Building a Development Environment Part 1: Managing your sourcecode with Subversion [...]


  2. [...] answer is pretty simple.  First of all, there are many articles that already describe very well how to install, configure and properly use CruiseControl.NET as a build integration [...]

  3. Guest Says:

    Thanks!!! :)

  4. Marky Says:

    Hi,

    I installed svn on my linux box as the document above, I am able to checkout, commit and redo but I am not able to see the log using svn log from cli nor show log from TSVN.Kindly post an answer.

    Thank you


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

%d bloggers like this: