Source Code Control (SCC), sometimes called Version Control, allows a software developer to maintain a complete history of his/her software development on a project. For projects that require significant collaboration between team members it is crucial to use a SCC system. But, even when working alone on a project it is useful to use a SCC system to maintain your the code that you develop.
There are many SCC systems that will work with LabVIEW but we will use one called Subversion (abbreviated SVN). Subversion is an open source version control system founded in 2000 that is maintained at subversion.apache.org. It touts itself as being an enterprise-class centralized version control system for the masses.
Using SVN
SVN is a centralized revision control system meaning that the code repository is kept in a central location and each user checks out a copy of the code to work on. The user edits his/her working copy of the code and when can commit these changes back into the code when ready. If multiple persons are working on the same code a user may wish to update his/her working copy before editing. The basics of this workflow are depicted in the figure below.
Subversion File Systems
To be fluent in using SVN it is very important to understand where files are stored and to understand the differences between the repository and the working copy.
When a client reads data from the repository, it normally sees only the latest version of the filesystem tree. But the client also has the ability to view previous states of the filesystem. For example, a client can ask historical questions like, “ what did this directory contain last Wednesday? ”, or “ who was the last person to change this file, and what changes did they make? ” These are the sorts of questions that are at the heart of any version control system: systems that are designed to record and track changes to data over time.
We have SVN installed on our departmental server at physics.wku.edu. This server hosts a source-code control repository that will be used by the class for all assignments and project submissions. The root address for our SVN repository is
svn://physics.wku.edu/phys318/
After you’ve made some changes to the files in your working copy and verified that they work properly, Subversion provides you with commands to publish your changes to the other people working with you on your project (by writing to the repository). If other people publish their own changes, Subversion provides you with commands to merge those changes into your working directory (by reading from the repository).
A working copy also contains some extra files, created and maintained by Subversion, to help it carry out these commands. In particular, your working copy contains a (normally hidden) subdirectory named .svn
, also known as the working copy administrative directory . The files in this administrative directory help Subversion recognize which files contain unpublished changes, and which files are out-of-date with respect to others’ work.
Subversion Commands
Subversion contains a large number of commands for interacting with the files in the working copy and the repository. TortoiseSVN incorporates these commands into a graphical user interface that is rather easy to use and that can be accessed via right-click menus in the windows file system. A comprehensive list of SVN commands can be found in the subversion glossary, but the most important ones for our use are described below.
A svn commit operation can publish changes to any number of files and directories as a single atomic transaction. In your working copy, you can change files’ contents, create, delete, rename and copy files and directories, and then commit the complete set of changes as a unit.
In the repository, each commit is treated as an atomic transaction: either all the commits changes take place, or none of them take place. Subversion retains this atomicity in the face of program crashes, system crashes, network problems, and other users’ actions.
Each time the repository accepts a commit, this creates a new state of the filesystem tree, called a revision. Each revision is assigned a unique natural number, one greater than the number of the previous revision. The initial revision of a freshly created repository is numbered zero, and consists of nothing but an empty root directory.
TortoiseSVN Icon Overlays
Unchanged and Current
The file is unchanged in the working directory, and no changes to that file have been committed to the repository since its working revision. A commit of the file will do nothing, and an update of the file will do nothing.
Unchanged and Out -of-Date
The file has not been changed in the working directory, but it has been changed in the repository. The file should eventually be updated, to make it current with the public revision. A commit of the file will do nothing, and an update of the file will fold the latest changes into your working copy.
Locally Changed and Current
The file has been changed in the working directory, and no changes to that file have been committed to the repository since its base revision. There are local changes that have not been committed to the repository, thus a commit of the file will succeed in publishing your changes, and an update of the file will do nothing.
Locally Changed and Out-of-Date
The file has been changed both in the working directory, and in the repository. A commit of the file will fail with an out-of-date error. The file should be updated first; an update command will attempt to merge the public changes with the local changes. If Subversion can’t complete the merge in a plausible way automatically, it leaves it to the user to resolve the conflict.
added
status when an item has been added to version control. This status indicates that this file is new to version control meaning that it only exists in the working copy and not in the repository. It will be copied to the repository during the next commit.unversioned
state. This is an item in a versioned folder, but which is not under version control itself. This overlay is optional and may not show up on your system.