Archive for the ‘Adam Sandler’ tag
The Not-So-Boring Guide to Subversion (Part 1)
And now a conversation between Present me and Past me.
Yo. (Present Chris)
What's going on? (2003 Chris)
Not much. Hey, what's with the Robot arms?
Oh. These? Yeah. You were really into dancing the Robot back in 2003. You thought it was hilarious.
Well you look dumb. Stop. It's definitely not cool to dance in the Robot in 2008. Mouse ears are cool now. And V-Neck tees. Look into them.
Got it. Hey, quick question. If you could go back to, uh, me and give you err me one piece of career/programming advice. What would it be?
Find a cute chick and marry her because you won't meet any more girls after college in your predominately male work-place.
Got it. Jotting it down. "Get married…" OK. Anything else?
Version Control, dude.
Wha..? Version Control? Why?
It's like time travel, dude.
…and, you're in love with it.
Welcome to the Not-So-Boring Guide to Subversion.
I created this guide because in the process of reading the Official Guide To SVN I feel asleep. Three times. The following is the result of trying to keep myself amused enough to stay awake and learn Version Control Which, I am told, is like Time Travel minus the Terminator nakedness.
Check-It-Out
To start, let's say you wanna work on an Open Source Project that you keep hearing all these kids talk about around the water cooler. It's a really cool project too. Lots of lasers.
Most of the files for open-source projects are stored in something called a Repository. Everytime I hear the word Repository, I think Dungeon. When I say Repository, you say Dungeon. Repository. (Dungeon). Repository. (Dungeon) The Repository is the creepy, spooky, wet and dank place all the files are kept.
So, first of all, if you wanna get files out of the Reposoitory, you have to check them out. Like library books. Go ahead, try it.
$ svn checkout http://www.codingwithcomments.com/SubversionTest/trunk/
These files that you've checked out, are what they refer to in the "biz" as a Working Copy. Some secret files are kept in our Working Copy directory in a secret folder ominously named ".svn." If you put a period before a folder name, it hides it. In your folder preferences, you need only enable "show hidden files" to see these secret monstrosities. These files help subversion keep track of all the unpublished and out-of-date files with respect to to all the folks who are publishing their changes.
$ svn checkout http://www.codingwithcomments.com/SubversionTest/trunk A trunk/ThreatenAnimal.rb Checked out revision 1.
Two Ruby files. Sweet. What? Did you think we'd have you checkout some Cobol? Heck no.
Now type:
$ ls -A trunk .svn ThreatenAnimal.rb
Look, you can see the .svn directory! Appending '-A' to 'ls' lets you see all the secret hidden files. It's like your asking '-Aren't you going to show me all the secret files?"
Now run ThreatenAnimal.rb.
$ ruby trunk/ThreatenAnimal.rb Stop Looking At Me Swan!
Adam Sandler is not a friend to animals. OK, now open ThreatenAnimal.rb in your favorite text editor and change 'Swan' to 'Adam Sandler'. My favorite editor is called 'Emacs Vim' It's a special brew of the two best text editors lumped into one. (This is a joke. There is no such editor. Some programmers find this sort of joke funny.)
Make a Commit-ment
So now you and ThreatenAnimal.rb have been going steady for awhile. You've been on several dates, and you are even thinking about asking it to prom in a few weeks. You are ready for a bigger commitment. You are ready to 'commit' your changes to the repository.
$svn commit ThreatenAnimal.rb -m "Adam Sandler != funny" Sending ThreatenAnimal.rb Transmitting file data . Committed revision 5.
'-m' appends a commit note. You should do this when you commit a file so everyone knows what changes you made. When I decide to commit to someone, I write them a note. "Do you want to be my girlfriend? Check yes or no." This way, they know what's up.
Note: Each file doesn't have to be commited individually. For example, if there was more than one file in the trunk directory, they could all be commited at once with a single command.
$svn commit trunkI need an update, pronto!
Uh oh. But there could be a problem. Say you are working on this project with the dreaded Ebeneezer Scrooge. Ebenezzer Scrooge checked out ThreatenAnimal.rb when you were still trying to decide if you wanted to make a commitment. His TheatenAnimal.rb file still threatens swans instead of Adam Sandler. Oh Ebeneezer, you're such a card. Simply type,
$svn update
U ThreatenAnimal.rb
Updated to revision 5.The update command brings Ebeneezer's files up to date. Ebeneezer is happy now. So happy, he sends me a message on google chat, 'No, you still can't have a lump of coal.' Oh frostbite!
Q and A
Question: What's with all the revision numbers?
Answer: Each time you make a 'commit' it updates something called a Revision Number. These numbers start at zero and go to infinity. Even If you 'commit' only one file in the repository, it creates a completely new file tree and updates the revision numbers of all the files in the repository. It's all or nothing. Think of it this way. If you make a commitment to a girl (or a guy), you are making a commitment to not just the girl (or guy) but to their friends, parents, and pets. It's an all or nothing deal, right? You can't just take one without taking all the rest. This sucks, I know, but that's why these Suversion guys refer to it as an Atomic Transaction. Because you feel like you've just been nuked.
There's a picture of how this works in the famous SVN book. It's pretty boring and drab but it gets the point across I suppose. 0 through 3 are the revision numbers.
However (comma) although all the revision numbers are updated for all the files in the Repository, your Working Copy (the copy of the project on your hard-drive) contains Mixed revision numbers.
Scandalous Revision Numbers
OK. Let's see an example shall we? Let's say you've got three files, you've recently done an svn Update, and all the files in your Working Copy and Repository are at Revision 5.
BlackBear.rb (Revision #5)
Santa.rb (Revision #5)
ElephantMan.rb (Revision #5)
We then make a change to ElephantMan.rb and Commit him to the Repository (where every Elephant-type man deserves to go). Just like we talked about, all the files in the Repository are at Revision #6.
BlackBear.rb (Revision #6)
Santa.rb (Revision #6)
ElephantMan.rb (Revision #6)
BUT, the files in your Working Copy have MIXED revision numbers.
BlackBear.rb (Revision #5)
Santa.rb (Revision #5)
ElephantMan.rb (Revision #6) <== the oddball
This is NORMAL. In fact, sometimes you want to purposefully backdate certain files of your Working Copy to an earlier revision. This makes Subversion, you know, kind of like a Time Machine. To understand the Time Machine, I suggest you rent '12 monkeys.' It is the definitive movie on Time Travel. Whatever you do, don't watch the Back To The Future movies. These are silly and Oedipal. How can those two adjectives co-exist? Only with the help of Steven Spielberg.
Just Remember: Commit != Update
A Commit does not equal an Update. An Update doesn't equal a Commit. You can Commit all day long, but until you run an update, you aren't going to incorporate anyone else's Commit(s) into your Working Copy.


What's going on? (2003 Chris)
