Archive for the ‘Subversion’ category

Setting Up a Sandbox Server with SVN

October 11th, 2010

svn mkdir http://manoj.com/repos/sandbox/manoj -m “created sandbox directory manoj”

SVN is one of those things that you love once you know what and how it works. SVN is a version control system used by almost all major open source projects and is an absolute dream to work with. If you have ever worked with a team of developers you probably have had the experience of having your code accidentally written over or deleted.

With SVN you have version control where you can revert changes, kinda like Wikipedia. It also keeps track of which files were actually modified and gives you an option to describe to other developers what changes were made. No more unfortunate mishaps.

What is great about SVN is that the code can be checked out to any server at any time with the latest code. I use SVN to make a “sandbox” server. A server that I can play around in without worrying about deleting code or messing something up. When I am happy with my changes I can type one command and the two servers are synced with the newest changes. If for some reason it doesn’t work out I can revert back to the old way in one easy command.

Getting Setup (using the command line svn)

The Open Source Flex SDK Sandbox is currently using Subversion 1.4 (version 1.5+ is out). You should make sure you are familiar with standard SVN usage (check out that book above).

1.Install the subversion command line client

2.Create a sandbox directory in the flex/sdk/sandbox repository:
svn mkdir http://manoj.com/svn/opensource/flex/sdk/sandbox/[ your sandbox name ] -m “created sandbox directory [ your sandbox name ]”

3.Copy the flex/sdk/trunk to your sandbox (create your own branch):
svn copy http://manoj.com/svn/opensource/flex/sdk/trunk http://manoj.com/svn/opensource/flex/sdk/sandbox/[ your sandbox name ] -m “copy the trunk to my sandbox dir”

4.Checkout the sdk to your local filesystem:

svn checkout http://manoj.com/svn/opensource/flex/sdk/sandbox/[ your sandbox name ] 5.Commit changes to your sandbox at your leisure
svn commit [ path to local copy ]

6.Get up-to-date sdk/trunk changes:
svn update
Reminder: The Subversion server is still on version 1.4 therefore merge tracking is not yet implemented. Make sure you are familiar with merging best practices
Run the merge command:
svn merge http://manoj.com/svn/opensource/flex/sdk/trunk http://manoj.com/svn/opensource/flex/sdk/sandbox/[ your sandbox name ]
This command does not commit changes to your repository
(This merge command will default to the HEAD revision of the trunk. Revisions can be specified, see the Subversion 1.4 merge documentation for more information.)

7.Check the differences between your branch and the new merging changes:
svn diff

8.Build and Test to make sure everything works
This is kind of a pain because it all goes into the terminal and it’s hard to read. I like git a lot better.

9.View the status of your working copy (make sure you have a clean working copy so you can commit):
svn status [ path to your local copy ]

10.Resolve any conflicts:
-svn diff

11.Commit the changes to your sandbox:
svn commit [ path to local copy ] -m ‘Merged latest trunk changes to [ your sandbox name ]‘

12.…A few days pass and you want to merge again, check what you need to merge:
svn mergeinfo http://manoj.com/svn/opensource/flex/sdk/trunk –show-revs eligible
or to see what might happen if you merge:
svn merge http://manoj.com/svn/opensource/flex/sdk/trunk –dry-run

Setting Up Subversion

April 11th, 2010

Introduction:-

# yum install subversion

Ok, that was pretty easy. I now have subversion installed on my system; both from a client and user’s perspective. Next I need to create a subversion 
repository location on my disk (/svn can be replaced with any location on your server).

# svnadmin create /svn

In /svn/conf/passwd add the following (it is in plaintext, but I am sure there is an encrypted solution):

[users]
achristopher = some secret, yet plaintext password

In the /svn/conf/svnserve.conf, you should set the following:

[general]
anon-access = read
auth-access = write

password-db = passwd

realm = Test Repo

There, our subversion repository has been set up. Now all we have to do is start the subversion daemon.

# svnserve -r /svn -d

We can test the subversion repo:

# mkdir /tmp/test

# svnserve -r /svn -d

# svn import /tmp/test svn://localhost/svn/test -m “Initial creation.”
Authentication realm: <svn://localhost:3690> Test Repo
Password for ‘root’:
Authentication realm: <svn://localhost:3690> Test Repo
Username: ravi
Password for ‘manoj’:

Committed revision 1.

[root@manojserver conf]# svnlook tree /svn
/
 svn/
  test/
We have just added a directory to our subversion repository. Now lets checkout this project, and get to work:

[root@manojserver conf]# rm -Rf /tmp/test
[root@manojserver conf]# svn checkout svn://localhost/svn/test
Checked out revision 1.
=======================================
Running Subversion From xinetd

Now that we have Subversion installed on our server, we really need some way to have it always available. We could run subversion in daemon mode but we would 
have to write init.d scripts which can get rather complex (especially if you are writing one properly, and not just hacking one together).

Instead, we will add subversion to xinetd. The benefit of this is that subversion is only running when we need access to the repository rather than running 
all the time. By default, subversion is not set up in xinetd, so the following is how I set it up:

First make sure that xinetd is installed.

# yum install xinetd

Next we want to add the following to our /etc/xinetd.d/svnserve

# default: off
# description: svnserve is the server part of Subversion.
service svn
{
  disable = no
  port = 3690
  socket_type = stream
  protocol = tcp
  wait = no
  user = root
  server = /usr/bin/svnserve
  server_args = -i -r /svn
}

Finally, lets restart xinetd:

/etc/init.d/xinetd restart

Now xinetd will start the subversion repository server every time a subversion request is made.

Thanks
Manoj Chauhan