Sunday, May 31, 2009

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.

No comments: