Shared knowledge leads to accumulated knowledge

Printer Friendly Page

Subversion - what is it?



Subversion is a version control system. All of our projects are available in a zip file as they always have been, but minor upgrades are now kept in our subversion system. If there is a subversion link near the download link, this means there could be updates to the project.

Over time all of the projects will be brought in under source version control. The source of these projects can be inspected using a browser when you point it to the correct URL. By default we are using the following URL schema: http://svn.vdf-guidance.com/<projectname> For example: http://svn.vdf-guidance.com/TheHammer/trunk/

Normally you want to see the "trunk" as that is where all the changes happen. This is the main current line of the project. The reason we are using Subversion is because it is free and easy to use under any OS using the appropriate client.

The most commonly used windows client for this is TortoiseSVN from http://tortoisesvn.tigris.org/ Just download and install that (defaults are OK) and reboot if you are asked to do so.

For an idea how that works read on below.
Some of our projects however also have been added to our projects server and have a web interface to the subversion tree.
For example if we stay with the Hammer example from above look at the following page:
Hammer Repository Projects Server

Apply Common Sense


If this is the first time that you are going to use the TortoiseSVN client and you have made changes to the source code of the project that you want to contribute to, then be sure and make a backup of your work first. For example, make a zip file and move it to another location on disk - If you point the Tortoise client to the directory where your changes exist, it could overwrite your code.

Now in order to get you started we are going to download the latest version of the project "The Hammer" and walk you thru the process, so that you have seen the most common operations. Not only will this help you in explaining how it works, it also gets you a new Hammer version that works under Visual DataFlex 14 and is capable to work with ANY released dataflex version.

Note:
The text for this document has been made using a number of computers. As a result, you'll see screenshots from the varying PCs, this also highlights one of the stronger points of using a version control system. Any PC will do as long as you have access to the subversion server.

View the project



You can view the source code in your browser, but most likely you'll want to see more. In order to view the project you select a folder (or create one) in windows explorer. Right click, Select the subversion submenu, choose repo browser and enter the URL from the project. For example:

http://svn.vdf-guidance.com/TheHammer/trunk/

Tortoise now pops up a dialog which looks like another explorer window and you can now see that there's a folder under trunk called Hammer. This is the normal workspace as you are used to see when downloaded.

Checkout a project



Let's say you want to get yourself the latest version of The Hammer as opposed to the published project. In subversion lingo that means you are going to "check out" a project. In order to do so, go in windows explorer to the location where you want to download the new project and create a new folder called "Hammer". Right click "Hammer" and choose "SVN Checkout". A dialog will pop up and you should now enter the URL from above in the "URL of repository" field.

http://svn.vdf-guidance.com/TheHammer/trunk/Hammer

The "Checkout directory" is already prefilled with the name of the folder you selected. Click OK and the entire Hammer part of the source code will be downloaded into your destination folder.

*
After the project is downloaded, you'll probably notice that files under subversion control have a little "OK" check overlay added to the icon of the file. This way you can see changes from within windows explorer as an edit makes the "OK check" change into a red exclamation mark.

If the main folder has a README.txt file with tips on how-to setup or compile the project, then make sure to read it. All projects at vdf-guidance stored at the subversion server are setup in a way that they do not trigger changes when you for example save some data in the database OR if you open the project in the studio. Most of those files are regenerated (like the metadata from the Studio). Other files (like the datafiles) are not in subversion and have to be downloaded separately and copied on top of your checked out project. This is a one time hassle, but it saves you lots of headaches in the future and makes working with subversion very comfortable.
_
One way of getting the binary dependencies is to use the repobrowser, move up to the trunk and use "save as" to download the dependencies. Another way to get the dependencies would be to point your browser to that same url and download it that way. Copy all of the datafiles into your Hammer\Data folder and you are done.

Sync your source code with the project



This is called update in subversion lingo and it means that you download the changes made by other people. It will leave your changes alone at all times. If there's a conflict while merging the source, subversion will ask you.

Check for changes



Basically this just means using the "Check for modifications" option. The files that are displayed as changed can be inspected for the changes by using the context menu (right click) while selecting the changed file in the repobrowser and click "compare with base". This will popup TortoiseMerge and display you the changes between the 2 files just as WinDiff or other comparable products would do. Of course you can change this to your preferable Diff/Merge client under the general preferences.

Another very important part here is the option to see the log as it displays each comment as has been stored while commiting changes.

Add a new file



If you want to add a new file to the repository - and the file is already part of the directory structure - then just right click: -> subversion submenu -> Add

A dialog will popup asking for your confirmation. The new file will be uploaded and added to the repository during the next commit.

Remove a file



If you want to remove a file from the repository - then use shifft+right click: -> subversion submenu -> Local delete

A dialog will popup asking for your confirmation. During the next commit, your file will be removed from the project and after that commit you can safely delete it from your folder.

Rename/move a file



If you want to rename a file in your repository - then use shifft+right click: -> subversion submenu -> rename

A dialog will popup asking for your new name, this may include a new -but existing- folder. During the next commit, your file is immediately moved.

Commit a change



Now suppose you edit one of the files and want to bring the edits back to the public project. In that case, the steps are as follows:

  1. right click the file (or folder holding the file) and select "SVN Commit"
  2. A dialog comes up for you to enter a log message. Enter a short message explaining what you changed and click "OK"
  3. You are now asked for your subversion user id and password.

That's all, the change is committed and visible for everyone.

Commit access



In order to submit a change directly into the repository, you'll need commit access. When you have a vdf-guidance subversion account, you automatically have commit access to each project at vdf-guidance. This makes it MUCH easier to incorporate changes from others, but it also means that you should be a bit careful

The following general COMMIT RULES apply:
- only commit complete changes, so making sure that the project still compiles BEFORE you commit your changes. The reason for this is that your changes should not stop someone else from being able to checkout the project and compile successfully.
- add proper comments to the commit dialog, they are part of your documentation!

Getting the source code OTOH doesn't require you to have an account at all. The subversion server is setup in a way that all projects can be checked out anonymously. If you have the URL then you can download the project.

Another important part to remember is to add a useful comment when committing your changes, as they can be read while using the "show log" option.

Removing a project



If you want to remove a project from your local disk, then you can simply delete the folder you created from your system. There's nothing more to it.

That's it, hope you liked this introduction to subversion.

Shameless advertisement


Now it is time for some shameless self promotion. If you would like to have a similar subversion server then contact Wil van Antwerpen from Antwise Solutions.

It is possible to set up and host for you a subversion server with the most common install options. For example, private access on a VMware virtual subversion server with root access and direct access to that server behind a VPN.