Setting up SVN

In this lab you will If you are working from a CADE-supported machine, all of the software that you need should already be installed. Otherwise, in addition to installing Visual Studio 2010, you'll need to install both AnkhSVN and TortoiseSVN.

Creating a Repository

To set up a repository, you'll need to remotely log in to lenny.eng.utah.edu. You can do this using your favorite ssh software, such as putty. Use your regular CADE login name and your CADE Linux password.

Once you're connected to your home directory on lenny, issue the command:

svnsetup cs3500
This will create a repository called cs3500 in your home directory. Contrary to what I said in lecture, the repository needs to be at the top level of your home directory.

Next issue this command:

chmod 700 cs3500
This will ensure that your directory is accessible only by you.

Finally, issue the two commands:

cd ~cs3500
java GetPassword
You will be prompted for your 8-digit UID number, and it will respond with a grade password. Write this number down. You'll need it to access your online grade records, and you'll also need it in the next step.

The next step is to edit three configuration files. You can do this while logged into lenny if you know how to use a Linux text editor, or you can do it from a Windows computer and use Wordpad or the like. Your choice.

  1. First, edit ~/cs3500/conf/svnserve.conf. You need to delete exactly four characters. Change the line that reads
    # password-db = passwd
    
    so that it reads
    password-db = passwd
    
    and change the line that reads
    # authz-db = authz
    
    so that it reads
    authz-db = authz
    
    (In other words, uncomment them. But make sure that the edited line does not begin with a blank space.)

  2. Next, edit ~/cs3500/conf/passwd. Add two lines at the end. The first should be the SVN username and password that you plan to use. For example, if you want your SVN username to be "smith" and your password to be "monkey", add the line
    smith = monkey
    
    This is an unencrypted text file, and even though it is inside a protected directory, it is still vulnerable to misuse. For that reason, do not put any of your favorite passwords here! In particular, do not put your CADE password here!

    The second line will be the SVN username and password that the course staff will use to access your assignments. That line should read

    cs3500 = #########
    
    where ######### is your grading password from the previous step.

  3. Finally, edit ~/cs3500/conf/authz. Add these four lines to the end:
    [/]
    * =
    cs3500 = r
    smith = rw
    
    where smith is the SVN login name that you put in the passwd file. This gives you write access to the repository, gives the course staff read access to the repository, and denies everyone else access to the repository.
If you've done everything to the letter, this completes the repository setup step.

Using SVN from Visual Studio

Launch Visual Studio. Use the Tools menu to open the Options dialog. Expand Source Control. Under Plug-in Selection, make sure that "AnkhSVN" is selected. Under Subversion User Tools, choose "TortoiseSVN TortoiseMerge" as the value for all three options. Then click "OK".

Now let's create a new project. Pull down the File menu, select "New" and then select Project. Highlight Windows Forms Application. Choose a name, such as "lab1", for your project and type it into the Name box. Make sure that "Add to Subversion" is ticked. When you've done all this, click "OK" and a new project will be created.

In addition, you will be prompted for the Repository URL. Enter

svn://lenny.eng.utah.edu/home/login/cs3500
where "login" is your CADE login name. After a few seconds, you will be prompted for your SVN login name and password. Once you've entered those, some details about your repository will be displayed.

Select the line that says "home/login/cs3500" and tick "Add trunk Folder for Project". Look at the box that says "Project will be created in:" and it should say

svn://lenny.eng.utah.edu/home/login/cs3500/lab1/trunk
If that's what it says, click "OK". A directory for your brand new project will be created on the remote repository.

Now pull down the File menu, choose Subversion, and choose "Pending Changes". The Pending Changes window should appear.

Now look around a bit at all the hooks there are into SVN. You've already seen the Subversion menu.

Look at the Solution Explorer window, and you'll see blue plus signs next to all the newly created files. This means that they exist in the local working copy but haven't been copied to the repository yet.

Right click some of those files, and notice that there's a Subversion context menu.

But most importantly, check out the Pending Changes window. As you make additions, deletions, and changes to your project, the affected files will be listed here. The two main operations that you'll need to do are to Commit local changes back to the server, and to Update your local working copy with the latest versions from the server.

Right now we need to commit all the changes, so click "Commit" in the Pending Changes window. All the changed files will be copied to the repository and the file names will disappear. In the Solution Explorer, the little plus signs will have turned into check marks.

Open up one of the C# classes and add a comment somewhere. Notice that the file is now marked as modified in the Solution Explorer, and that it is also listed in the Pending Changes window. Click Commit and that change will also be sent to the repository.

How We'll Grade Your Work

Open up a command shell on a CADE Linux machine via your favorite ssh mechanism, such as putty. Then issue the command
svn --username cs3500 --password ######### checkout svn://lenny.eng.utah.edu/home/login/cs3500/lab1/trunk lab1
Here, ######### is your grading password and login is your CADE login name. If all goes well, a directory called lab1 will be created, and it will contain your project. If it doesn't work for you, it won't work for us, so make sure it works!

Updating

Now let's suppose that your computer has been incinerated and you need to work on your project on a different computer. To simulate that, start up a new Visual Studio window. Pull down the File menu, choose "Subversion", and then choose "Open from Subversion". Navigate through the repository until you find the lab1.sln file, which you should select. Click "OK" and a new working copy of the project will be created.

Change one of the C# files and commit the change. Now go to the original Visual Studio window and update the project. The change that you've just committed should appear.

You only to need to do "Open from Subversion" once per computer. Once you've done it, the working copy will remain behind. You can update this copy whenever necessary.

One More Thing to Try

If you have time, try this. Make sure that the working copies in both Visual Studio windows are up to date by Updating them. Now change a C# file in one VS window and commit the change. In the other VS window, make a change and try to commit it. What happens? Now try to update it. What happens? Try to feel your way through the merging procedure.