Version control is a concept that has to do with keeping absolute copies of everything at every step of the way. So I'll go into a little history here at the top. In the beginning there was CVS and it was what everyone used back in the "old" days (I'm talking about the roaring '90s). CVS is "concurrent versioning system" or somesuch and if you look, it's possible to find some projects that still rely on CVS (and there are probably an awful lot of CVS repos behind the closed doors of a lot of industries holding their internal code/patches/documentation/websites/whatever). But CVS had some problems, so a bunch of clever open-source programmers created subversion (which from the beginning was designed to basically be "CVS without the warts"). And many projects and businesses now use subversion (or SVN as it's sometimes shortened) instead of CVS. But version control is a very complex topic and the world doesn't stand still. As of 2009, subversion is somewhat dated, as the newest wrinkle in version control is to have no canonical central repository. Instead systems like [git http://www.git.org], [mercurial http://mercurial.selenic.com/wiki/], [darcs http://darcs.net/], and [bazaar http://bazaar-vcs.org/] are all the rage. But since we have no need at all for decentralization (and in point of fact a version control system at all is a little bit overkill to begin with) we'll do just fine using subversion for this class.

So how does one use subversion?

If you're on windows, first you have to get it. I found SlikSVN(click on the red tabbed links to download) installed just fine on my XP-pro, please let me (charlie) know if you find out differently for Vista or whatever.

As I demonstrated in class, the command line is pretty simple. If you're using a windows computer, your command-line is called the DOS-prompt or the Command-prompt or perhaps a "DOS window" depending on who you're talking to. If you're on a Mac, you can just open up the "Terminal" application. One of the silly differences is that in Windows-land, the path separator character is a backslash: "\" whereas on a Mac (or GNU/linux) it's a forwardslash: "/". Don't get tripped up by that (actually it's even more confusing as the svn commands all use forward slashes within them even if you're on windows so you need to know to only use backslashes when referring to local directories). But the below examples assume windows, mac users will need to switch the backslashes to forward slashes (and leave the forward slashes alone) in order to get all the commands to work correctly.

To checkout the repository, first cd (change directory) to where you want to put it on the filesystem on your machine:

cd \my\favorite\directory

then you need to "check out" the repository (co):

svn co https://cssvn.simons-rock.edu/cmpt242

and then login using your simons-rock.edu username and password (just hit enter when you get prompted for a different username and it'll let you enter yours on the next line) -- also during this step if you haven't yet executed this command already (or if you chose the wrong option the last time you executed it), you may be prompted with a bunch of verbiage about a certificate like this:

[ni@proto ~]$ svn co https://cssvn.simons-rock.edu/cmpt242
Error validating server certificate for 'https://cmpt242.simons-rock.edu:443':
 - The certificate is not issued by a trusted authority. Use the
   fingerprint to validate the certificate manually!
 - The certificate hostname does not match.
Certificate information:
 - Hostname: ca.simons-rock.edu
 - Valid: from Jun 22 19:10:04 2009 GMT until Jun  1 19:10:04 2013 GMT
 - Issuer: Simons Rock College, Great Barrington, Massachusetts, US
 - Fingerprint: 08:e9:bc:0c:4e:36:36:11:6b:57:96:fb:e5:ec:a1:2e:76:f8:1a:64
(R)eject, accept (t)emporarily or accept (p)ermanently?

The right answer to the above is to type 'p' for permanently.

So now you have a local copy of the repo on your machine. Had you wanted to create it with a folder name other than cmpt242 that's easy too, just use another argument:

svn co https://cssvn.simons-rock.edu/cmpt242 myLEETlocalRepo

which would have created a folder:

\my\favorite\directory\myLEETlocalRepo

which would also work just fine, but I'm going to assume that you can live with the name cmpt242 for the sake of simplicity in continuing along with my examples. So now you have a local copy of the repository. Let's "go into it" to check out what's there:

cd cmpt242

so you could look around by executing a "dir" command (or 'ls' if you're on a Mac (or if you've installed cygwin)), but that's not essential for homework due on 9/9, so I'm not going to slow down for that now -- instead, let's assume your name is something generic like Your Name:

svn mkdir YourName

would be a natural choice, but maybe you don't like CamelCase just as a general rule or maybe you'd prefer to go by a nickname, so you could instead do:

svn mkdir nickname

which is fine as long as you use a name that you share with the class so we know who you are. It's also worth pointing out that you only want to execute one of the above two commands, not both.

So now let's assume that you took choice 2 (as most non-conforming Simon's Rockers probably would) and created the directory as 'nickname', so now you want to put something in it:

{{{ cd nickname notepad MyFirstSubversionCheckin.txt }}}

Type in a cute message (not too cute, remember everyone in the class can see what you put here if they look) and save the file. (Mac users obviously won't have notepad, I'm assuming you folks can find a working editor though). So now you need to add the file to your local copy of the repository:

svn add MyFirstSubversionCheckin.txt

And now you can "commit" it to the repo:

svn ci -m "I'm checking in a simple text file to show that I can."

(feel free to edit your commit message (the argument in double quotes after the -m) to something more clever than my example as well -- for that matter, feel free to use a better filename than MyFirstSubversionCheckin?.txt if you wish)

If you tried the above and it didn't work for you, please email cderr@… with exact error messages (and where things went horribly wrong) and I'll hopefully be able to help. But please don't wait for Wednesday 9/9 to let me know you couldn't succeed.

If you haven't made any changes to your local copy (and this part is very important) and you want to see new code others may have checked into the repo, you can update your local copy to the "fresh" state of the central repo by executing an update command:

{{{svn up}}

And that's pretty much all that you need to know for now. But feel free to add your own tips about subversion if you discover cool features that prove useful to you.

But I don't want to use the command-line, how do I use Tortoise-SVN? (Section by Quinn)

Tortoise-SVN isn't terribly difficult to use. Download the version relevant to your operating system from [here http://tortoisesvn.tigris.org/] and run the installer. Tortoise integrates with the windows shell, so using it is really as simple as right-clicking in a selected folder and clicking 'SVN Checkout'. You can enter the URL of the subversion directory into the resultant window ( https://cssvn.simons-rock.edu/cmpt242 ). Everything else should be fine as it is.

After a few seconds, Tortoise will have done it's thing and you'll have files downloaded from the SVN. You can then navigate to the cmpt242 directory (i.e. double-click on the icon) and create a new folder named your name. Right-click the folder and select TortoiseSVN -> Add (+). This will tell subversion that the selected directory exists.

Navigate back to wherever you created the cmpt242 directory. Right-click it and select SVN-Commit.

That's it. You're now set up to be using subversion.

AdamPage