I have written about CVS and GIT in the past and the joys of working on various projects mean that I end up using pretty much any system that I get a chance to lay my hands on which make me more aware of the options available. So this time it was SVN, I spent a while this evening reading through various tutorials to get the hang of it and its amazingly straightforward to use it. Documenting the commands here for future reference. This can be useful who wants to get up and running with SVN quickly.
1: Creating a local repository
busybox:tmp rpandit$ svnadmin create --fs-type fsfs /Users/rpandit/tmp/project-svn
Make sure you provide it the full path, I spent a while looking around because all i had done was just create it by using ./ . So after this command, you can have a look around in the new folder project-svn. You will see a bunch of files but they wont make much sense to you.
To have a look inside the directory such that it make sense, you need to use SVN commands. The SVN repo is like a virtual directory in which you can create new files/ directories etc as long as you do it via the SVN commands.
busybox:tmp:tmp rpandit$ svn mkdir file:///Users/rpandit/tmp/project-svn/bla -m "Silly Directory" Committed revision 1. busybox:tmp:tmp rpandit$ svn ls file:///Users/rpandit/tmp/project-svn/ bla/ busybox:tmp:tmp rpandit$ svn rm file:///Users/rpandit/tmp/project-svn/bla -m "Removed silly directory" Committed revision 2.
So as you saw access the repo is pretty much similar to accessing a actual virtual directory via SVN. The thing that you would expect from SVN is that that it not only just allows you to create files and directories but it also maintains the history of the files that you changed or modified.
busybox:tmp rpandit$ svn log file:///Users/rpandit/tmp/project-svn ------------------------------------------------------------------------ r2 | rpandit | 2009-01-08 21:08:29 +0000 (Thu, 08 Jan 2009) | 1 line Removed silly directory ------------------------------------------------------------------------ r1 | rpandit | 2009-01-08 21:07:36 +0000 (Thu, 08 Jan 2009) | 1 line Silly Directory ------------------------------------------------------------------------ busybox:tmp rpandit$
So now, its time to put this repo to some real use. Lets add an existing project to this repository.
Adding an existing project to the repo
busybox:tmp rpandit$ svn import ~/cfarm/python/ file:///Users/rpandit/tmp/project-svn/trunk -m 'Initial Import' Adding /Users/rpandit/cfarm/python/django Adding /Users/rpandit/cfarm/python/django/mysite Adding /Users/rpandit/cfarm/python/django/mysite/manage.py Adding (bin) /Users/rpandit/cfarm/python/django/mysite/urls.pyc Adding (bin) /Users/rpandit/cfarm/python/django/mysite/foomatic -- some output removed --- Committed revision 3.
The parameters are pretty obvious especially for someone who has used CVS in the past. -m is used to add a comment to the action and it shows up in the log files as shown in above when creating and removing folders.
Now that we the repo populate, its time to checkout the code at another location to start hacking away on it.
Checking out code
busybox:tmp rpandit$ mkdir project-dir busybox:tmp rpandit$ svn checkout file:///Users/rpandit/tmp/project-svn/trunk A trunk/django A trunk/django/mysite A trunk/django/mysite/manage.py A trunk/django/mysite/urls.pyc A trunk/django/mysite/foomatic A trunk/django/mysite/__init__.py A trunk/django/mysite/settings.py A trunk/django/mysite/__init__.pyc A trunk/django/mysite/polls A trunk/django/mysite/polls/views.py -- output removed for readability --- Checked out revision 3.
With that we have a version controlled copy of the code, ready to be used. Shall write more about adding/deleting/branching etc in the second part
