Today's goal is to get you reasonably comfortable with the basics of subversion . Do the following exercises. After today, I'll clear all your experiments out of the appropriate places and we can start with a clean slate, so don't worry about making a mess.

Subversion

  1. Bookmark whichever incarnation of the subversion documentation you prefer (pdf, html, etc.). Use it to figure out how to perform the tasks in the rest of this lab.

  2. For your project, Mike Tie and his student workers have created a subversion repository. The repository for your group is named augmentedreality, memorybox, motioncapture, musicstand, or netflixprize. For the rest of this tutorial, we will ues "augmentedreality", but you should use your group name. For some operations (notably "svn checkout"), you will need an url: https://lime.mathcs.carleton.edu/svn/augmentedreality etc.

    If you are using a CS lab macintosh, chances are that your default keychain is corrupt; you need to start with a blank keychain. To do this, open a terminal window and enter the following commands

    cd
    mv .subversion .oldsubversion
    cd Library
    mv Keychains oldKeychains

    To get started, check out the full repository using a command like "svn checkout https://lime.mathcs.carleton.edu/svn/augmentedreality augmentedreality" (see the svn documentation for details). The first time you do this, you will be asked to accept an unsigned certification or some such thing, select "p" for permanent. You will then be asked for your password; please enter it. If you are on a CS macintosh, you will now see a "Keychain not found" panel; click "reset to defaults", "yes", and then enter your password again (this saves the svn account info in the keychains), and click "ok". You should now see lots of files and drictories being saved into your directory.

    The CS Macs seem to create a number of resource forks; these resource forks create problems for subversion. At this point, we need to prevent the uploading and downloading of resource forks. To do this, use your favorite editor on the file ~/.subversion/config. Look for the following line (line number 71):

    # global-ignores = *.o *.lo *.la #*# .*.rej *.rej .*~ *~ .#* .DS_Store
    and add the following line of text under it:
    global-ignores = ._*
    Save your config file.

    Take a look at the checked out directory augmentedreality. You'll probably see other people's work there (including a small test directory called "jondich"). There will also be a directory named .svn. Take a look at the files in that directory. You won't edit these file manually (that's for the "svn" command to do), but it's worth having a sense of what kind of information subversion stores to support the work it does.

  3. Suppose you want to create your own project. First, create the new directory inside augmentedreality (named something unique such as your user name to avoid conflicts with other students) and put some files in it. Change directories to augmentedreality and execute "svn add yourprojectname". Then commit your changes with:

    svn commit -m "I added a new project called yourprojectname."
  4. Next, delete your entire augmentedreality folder and just check out your own project with:

    svn checkout https://lime.mathcs.carleton.edu/svn/augmentedreality/yourprojectname yourprojectname
  5. Have somebody else check out your project, make a change to one of the files, and commit the change.

  6. Now that somebody has changed the project, your copy is not up to date. Update your copy using "svn update", and take note of the revision number (you'll use this revision number in a later step). Do you see the other person's changes?

  7. Delete a file from your project, and then commit the changes (note that "svn delete" does not change the repository--it changes your local information, and the changes will be made to the repository when you next do "svn commit". Go ahead and commit your changes.

  8. Both you and the somebody-else should now make changes to different portions of the same file (e.g. one person should change a word on the first line of the file, while the other person adds a line to the end of the file). When you have done so, you should both commit the project. Assuming both commit operations succeeded, you should now both update via "svn update". Look at the file you changed. Are both changes present on each person's copy?

  9. Now, both of you should change the same portion of the same file (e.g. each person should modify the same line of the file). Now, only the first person should commit his/her changes.

    Here's where it gets entertaining. The copy in the subversion repository is now identical to the copy held by the first person. But that copy is inconsistent with the copy held by the second person. The second person should now perform an update (svn update). What messages do you get from the update operation? Do a listing of your directory. If the file you have been changing is called thefile.txt, you should see thefile.txt, thefile.txt.mine, thefile.txt.rXYZ, where XYZ is the revision number of the first person's most recent commit operation. Compare the contents of these three files.

    The second person should now repair thefile.txt by actually speaking with the first person and agreeing on the appropriate changes. Then, the second person should commit the changes and delete the .mine and .rXYZ files.

    There are some important lessons here:

    • Always do "svn update" before "svn commit".
    • Pay attention to the messages you get during update and commit operations.
    • Keep your eyes open for .mine and .rXYZ files.
    • Incompatible changes can only be resolved by human intervention, often only after some conversation between two or more people.
  10. Check out the revision that you took note of a few steps ago. Does it look right? Has the file you deleted reappeared?

  11. Export the same revision that you checked out in the previous step (make sure to use a different name for the exported directory). How does the exported directory differ from the checked out directory?

  12. Subversion is intended mostly for use with text files, but your projects can include binary files. For example, suppose you want to include an image file. Add such a file to your project. Does the "svn add" operation give you a different kind of response with a binary file than with a text file?

  13. When you do just "svn commit" without the "-m" flag, what happens?