Friday, July 13, 2007

Use CVS in less than 5 minutes

Using CVS for your personal projects/little utilities.

Applies to Cygwin, *nix environments. For windows, use the extremely cute tool called TortoiseCVS or better TortoiseSVN.
If you want to use the power of CVS for your simple project, solely for the purpose of keeping track of the changes you make within a span of a few days within the development cycle, you can use a local repository of CVS. (Remember, you probably don't get file backup facilities etc with this).

Set your CVSROOT environment variable to the directory which you want to use as repository. For example "work/cvsroot in your home directory.
$ mkdir ~/work/cvsroot
$ export CVSROOT=~/work/cvsroot

Then you ininitalize the cvs repository by saying
$ cvs init

Now you import the first version of the code into the repository, by "adding module" technique. Suppose your root module directory is rootModule.
$ cd rootModule
$ cvs import -m "yor comment in quotes" rootModule ROOTMODULE_DIST ROOTMODULE_0_0_1

Now you have a repository with a module added to it. To work on it you need to "checkout" the content into a work area, say ~/devp.

$ cs ~/devp
$ cvs co rootModule
Now you have the entire module checked out into your ~/devp.
Make the necessary modifications to all the files. Once you are satisfied, review the references, cvs diff command.
$ cvs diff
It lists all the changes made on the console in diff format. You can view this in [g]vim which is the galaxy's best text editor. Once you are sure everything is alright, it's time to "checkin" the files back into the repository, (while retaining the ability to go back to your earlier versions, which is what CVS is all about).
$ cvs commit
It will let you know the files which have changed and ask for conformation. Once you are done, you may tag the new version with an appropriate name so you can use that version later if you need to. I found the following command helpful, but use your imagination here.
$ cvs tag -R -b <APPROPRIATE_TAGNAME>

And continue the above steps peacefully, knowing that you can make mistakes and correct them later or track them to where they happened. History is important, and not just for politicians!!!! Heck, it doesn't teach them anything anyway, but it does a lot of good for us software labourers.

No comments: