Monday, January 31, 2011

RapidSVN: A Primer for the rest of us

I recall once speaking to a friend in a concert lineup. Both of us being the nerds that we were, we'd been in an excited conversation about Perl. It somehow dawned on another person in line that we were talking about something or other related to computers, and in the interest of conversation asked, "So you guys are in IT, huh?" at which my friend bristled. His reply was simply, "I suppose...but don't ask me to fix your computer."

I often recall this comment in the midst of coding or simply using an application when what I think ought to be a simple task escapes me. It makes me feel frustrated and vulnerable. Most recently, I was setting up and making use of the revision control program, RapidSVN, and ended up having a great deal of trouble creating a directory structure within my branch as well as being able to get what I needed out of the repository. I spoke to Fardad after class (as this happened during the class where he was introducing SVN in detail, as well as the process involved in collaborative coding with SVN), and we arranged the needful.

Afterwards, I found myself with some free time during the afternoon, and decided to boot up RapidSVN and try again. This time I was more successful, and so I decided to create a step-by-step pseudo-transposition of the steps provided on the OOP344 wiki for Mac users who shall likely end up with RapidSVN. It is (at least for me) a bit slow, but it is functional and handy, and with a little practice, one can get used to it as well as SVN in general.

Get RapidSVN (of course)

From the OOP344 wiki, here's a link to the disk image. It's one of the simpler ones that simply includes the executable for you to copy to your Applications folder. Peanuts.

Create a folder to house a working copy of the repo on your home computer.

Another easy step: simply use Finder or Terminal to create a folder that's named logically to which RapidSVN can route a working copy to. Terminal may be preferable, because you can copy the path, which you'll need for the next step

Add the repository to RapidSVN

Ready to sink your teeth into RapidSVN? Launch the app. 



Fairly Spartan interface. I'll go through some of the more relevant (to us) commands, but first click on Bookmarks.



You'll get a list of options. Add Existing Working Copy, Add Existing Repository, Switch Repository URL, Edit Bookmark and Remove Bookmark. We're going to select Add Existing Repository.

Add your SVN account URL. You will have to provide a username and password. Obviously, this can refer to any applicable repository. Check out your bookmarks tab. If the add was successful, your repository is now available to browse! Also, you will no longer have to log in to the repo (from the current workstation). Click on the account in the Bookmarks tab.



The directory structure will be familiar to you, but it's incomplete. Now to make it feel a bit more like home (I guess). The next two steps can be done in any order, but if you perform them as presented, you'll save yourself the trouble of having to merge multiple times.

Create the directory structure Pt. 1 - create your workspace


It's important to be careful of this; it's where I got into a bit of trouble, mostly because of my overzealousness and because, admittedly, I didn't listen as closely as I ought to have. I entered the Modify menu and attempted to create a new directory, for which we don't have permissions. Eep. Here's a tip for you: just don't open the Modify menu at all. I was about to type, "in the root", but I think using the contextual menus is more reliable in almost all cases. Anyway, open up the branches directory.



Right-click anywhere inside the whitespace. Select Make directory A prompt shows up which allows you to name it. Do so, and click OK. The message that appears tells you that your action has resulted in a commit. I provided a comment. I suppose you should, too.




Create the directory structure Pt. 2 - create a task folder
Follow the same instructions as in the previous step to create a folder called task inside your workspace. This is simply a placeholder; you will be renaming it as need be.

Create the directory structure Pt. 3 - branch the trunk into your workspace
Go back to the root and right-click trunk. Select copy, open up your branch, and paste. And that's it, your workspace is complete...on the repository. Your workstation still doesn't have your directory structure.

Merge workstation with repository
Click on the Repository menu and click merge. Enter the path/to/your/working/copy, and click OK. Your workstation now has the same directory structure as the repo.



Follow Steps 4-6 from the Development and Submission steps using SVN entry on the OOP344 wiki



And that's that. Hopefully this reference proves to be handy to coders using revision control on OS X.

Addendum: Useful hints

If the idea of having to create a new working copy is daunting to you, consider storing the one from your working computer on  the always handy Dropbox application. You can be fairly assured that you have the latest version of the code in case you're working on a computer other than your own this way, and it acts as a backup in disaster scenarios.

One other thought might be to use RapidSVN to version control files on your own hard drive if only to practice with the interface and version control example code of your own. This may also be great for rolling back extreme changes to your code. You can accomplish this by using the svnadmin create command as follows:

~ User$ svnadmin create /path/to/repository

And you're set!

Coda

Any error indications, comments or suggestions would be appreciated. I want this to be as accurate as possible. Thanks!

(Postscript: Sorry about the image sizes messing with the layout. Still working out the kinks in the Blogger platform)

No comments:

Post a Comment