It was brought to my attention that some of you budding php hackers out there may not be aware of SVN, what it is, or how to use it. So here comes the 5 minute tour. This is not a complete howto, or a complete set of documentation, but is designed to introduce you to source code repositories in general, and svn specifically, what they do, and how developers would typically use them.
SVN (ir Subversion) is an open sourced source code repository tool. It's designed to allow multiple developers to work on the same set of files essentially simultaneously, and to keep track of the changes in the code over time, for tracking, testing, and reversion purposes.. Similar (but not as good) products are RCS, SCCS, CVS (and lots of commercial ones).
There are a number of SVN clients available for download, or many linux distributions come with them automatically installed. For windows, the favorite so far is "Tortoise svn", and infact there's a document about using that svn client with the cmsms forge here:
http://dev.cmsmadesimple.org/docman/view.php/48/12/tortoisesvn.htmFor further instructions, please refer to the subversion manual(s), and help documentation.
Starting coding with svnChecking Out:To get started coding with svn you must first "checkout" some code. You will be given a url that specifies the location of the repository, infact if you check out the "SCM" tab of any project page in the forge
dev.cmsmadesimple.org, you will see the SVN url and the instructions for accessing it. On unix, via the command line, this command is usually:
svn checkout <url>
At this point you're ready to start doing whatever you need to do.
Checking Status:From time to time, as others can commit and modify files you will need to check what has been done. This is accomplished with the
svn status
command. It will tell you which files have been added, removed, locally modified, or modified by others, but will not make any changes to your files.
Merging:Once you know what will be done, you can
update your local working copy with the files that have been added/deleted, or modified by others. This is done with the
svn update
command. This will automatically merge the changes you have made with the changes made by others, into your working directory. Note, this does not commit anything to the repository.
Adding filesIf you create a new file that needs to accompany the other files in the source tree, you need to use the
svn add <filename>
command. This marks the file for addition, but does not commit it to the repository.
Removing filesFor removing files, you use the
svn remove <filename>
command. This will remove the file from the local filesystem and mark it for removal from the repository (don't worry about removing files from the repository, they can always be brought back later). This command does not commit anything to thre repository.
Getting a patchSometimes you don't have write access to the repository, or you want to see what has all been changed. the
svn diff
command can be used to create a summary of all of the changes in the working directory. You can send the output from this command to a file, and this is called a "patch file", as it can be used by other users to update their code.
Committing filesAfter you've completed your modifications, (and done the appropriate testing, of course), if you have access, you may commit your code. This is done with the
svn commit
command. You will be asked to describe all of your changes, and then all of the files you have modified, added, or deleted will be committed to the repository. You are then ready to begin the development process again.
Note: You may have to do an
svn update
before committing your changes, as the repository will not allow you to commit changes if your local working copy is not up to date.
ConclusionThere you have it, that's the 5 minute tour of svn, and source code maintenance in general.