This time, we'll see how to install and use Subversion. You will have to download VisualSVN Server (http://www.visualsvn.com/server/) and TortoiseSVN (http://tortoisesvn.tigris.org/). You can also download AnkhSVN (http://ankhsvn.open.collab.net/) if you want Visual Studio integration (for Visual Studio 2008, take version 1.0.3 or later).
VisualSVN Server, TortoiseSVN and AnkhSVN installation are straightforward. When VisualSVN Server is installed on our server, and TortoiseSVN on our client(s), we can begin.
During VisualSVN Server installation, you just have to remember the path labeled "Repositories location" for backup purposes.
Server side
First, you need to create a place where source code will be stored : a repository. Every modification of the code in the repository (commit) will increment its version number. Repositories are created in the repositories path specified during VisualSVN Server installation (c:\repositories by default). This is the only directory you need to backup. If you restore this directory on another server, install VisualSVN Server, everything (repositories, source code, users and groups) is back to normal!
Now you can launch "VisualSVN Server Manager", and "Create a repository". You can name your repository after your project's name. Do not forget to leave "Create default structure" checked : it will create 3 directories, at your repository's root :
- trunk : development version of your source code
- tags : specific (released) revisions of source code
- branches : development duplications of trunk, for adding new features that don't belong to the trunk at this point of time.
You can have a look at this post from Bill Simser who explains very well those concepts.
Now we have a repository, let's add some access control. You can create your developpers by clicking on "Create new user", and create your groups with "Create new group". You can associate users into groups. Finally, to define access rules, right click on your repository in the treeview, and choose "Security".
Before going client side, remember your repository's url, like http://server:8080/svn/RepositoryName.
Client side
Now that we have a repository, we need to create a local copy of it. Every modification made on the local copy is made on the repository, after you "commit" it. Every modification on the repository is made on local copy by "updating" it.
You can create a folder on your development machine (like d:\ContinuousIntegration), right click on it and choose "SVN Checkout". Now enter your repository's url, appended by "trunk" : http://server:8080/svn/RepositoryName/trunk. Remember : trunk is your development branch.
Your local copy is ready. If you add files and folders inside, you just have to right-click, choose "Commit" and it's done (after a dialog), it's on the repository, with version tracking!
You can simplify some things, like never commit bin, obj, *.suo and *.user. You just have to right-click, TortoiseSVN -> Settings. Inside General, Subversion, fill "bin obj *.suo *.user" inside "Global ignore patterns". There is no use storing compilation products inside the repository : everything you need to make it is already there !
How to properly commit
1. Bob (our developper) updates his local copy, to get the latest version of the code
2. Bob modifies the code
2.1 If code doesn't compile, back to 2.
2.2 If code compiles, go to 3.
3. Bob updates his local copy, to get modification that can have been made on the repository since 1.
3.1 If code doesn't compile, back to 2.
3.2 If code compiles, go to 4.
4. Bob commits his modifications.
Point 3 is very important : it ensures that Bob's modifications don't conflict with code in the repository. Which leads us to the most important point : the code in the repository must compile. Everytime. If someone updates his local copy with code that doesn't compile, he will be losing valuable time : who commited the code, why doesn't it compile, how to correct...