Thursday, June 21, 2007

Quick and dirty way to change your mind: Mid-term conversion of your project to be versioned

This tutorial teaches you how to convert a simple ongoing project to be versioned. It uses Subversion (SVN) concurrent version system.

  • svn
  • a simple project in a directory (folder)

Let's say you have a quick idea about a certain research topic, and you start writing code to test your ideas. A week later, you realize that you have a full-blown project on hand. You have about five things going on, and takes hours to create a multi-gigabyte artifact files - you don't dare move these around, but you still want to version some of the core modules that you have created for your analysis. You understand the virtues of versioning your source codes and documentations - it'll save you hours if you ever run into problems and have to back track what you have done with your code. Here is a way to convert your project to be versioned, using SVN as your version control system.


Create the repository directory:
mkdir ~/svn-repos
Then populate the directory with svn files
svnadmin create ~/svn-repos
Go to your project directory, with all the files used for the project (this assumes it is all in one giant mess of a directory).
cd ~/Desktop/snowball.project/

say you have these files in the snowball.project directory:
  • documentation.txt
The last two files are what you want (let's assume the first two are 1 petabyte each!)
So, you create a temporary directory:
mkdir temp
cp documentation.txt temp/
cp temp/
Then you import the content of that directory:
cd temp/
svn import . file:///Users/steve/svn-repos/snowball/trunk/
Then you can check out the files, in a separate directory:
mkdir temp2
cd temp2
svn checkout file:///Users/steve/svn-repos/snowball/trunk/
cd trunk
you should see .svn when you:
ls -a
along with the critical files.

Move .svn directory snowball.project:
mv -rf .svn ~/Desktop/snowball.project/


This converts snowball.project into SVN compatible directory. Command such as svn update and svn commit should now work when you are in the original directory. You may erase temp and temp2 directory now.

No comments: