Coding in a Vacuum: Subversion Hooks

A month ago I wrote about setting up an in-house subversion server on the cheap. After a month of using my setup it’s been pretty successful, and I’ve learned even more about subversion.

One of the things I had to do was set up a post-commit hook to publish changes to a webserver.  The site I did this for is still in development, and every commit needed to be pushed to the webserver for testing.  I did this using rsync, (or, since the SVN server is in Windows, cwRsync), and it’s a pretty basic rsync/openSSH setup, but that’s for another day.

What I am talking about today is actually creating the hook script.  What a pain in the ass.  It’s not actually hard to create the script and run it.  On Windows you just write a batch file, debug it, call it post_commit.bat, and drop it in the hooks folder of the repository you want to use.  Sounds simple, doesn’t it?  Why then, when you commit a revision, does Subversion hang, and the script not execute?  Because subversion runs hooks in a near-null environment. This means that nothing is set.  In Windows, not PATH variable.  In everything, pretty much no environment variables of any kind.  So, when you tested your script yourself it ran great because it had lots of support, but now Subversion is running it entirely alone.  Poor, lonely script.

It gets even more frustrating.  Since Subversion is running the script, there’s nothing being printed to the screen to tell you what’s going on, so debugging is like shooting bugs in the dark.

There are a couple of things you can do, however, to make your script work.  First, use an absolute, full, path for everything.  For Windows this means start with the drive letter.  For *nix this means start with a slash.  If that doesn’t work, there’s a trick that allows you to see what’s going on.  You can log the hook’s output to a file.  This way you can find out what’s going on, read the errors, and fix them.  Thanks to Dan Switzer for posting about it. His blog showed up in a Google search and ended my frustration.  In my case, it was some more environment that had to be set up for cwrsync to work properly.

Would the MacBook Touch Really be Useful?

There’s been a lot of talk recently about a MacBook Touch – a Mac laptop with a touch screen, perhaps in tablet form, but each time I read a speculation like this I wonder – would a MacBook Touch really be useful?

Found at shinyshiny.tv/2008/07/rumour_macbook.html
Image found at http://www.shinyshiny.tv/2008/07/rumour_macbook.html

I sit at a desk, (or on a couch sometimes), and work on my MacBook Pro.  I spend most of my time coding in PHP, Javascript, HTML, or CSS, and I use the trackpad to control the mouse.  This way I rarely have to move my hands, (I know it sounds lazy).  I find that I can get things done fastest working like this.  If my computer were to have a touch, (or multi-touch), screen I would have to lift my arms, touch the screen, then find my position again on the keyboard.  I know it would be fast, but multiplied by a thousand, (or however many times I interact with the mouse), per day it would take a lot of time.  Really, if I can drag something across the screen by moving one finger five cenimetres on the trackpad, why would I involve my whole arm in dragging something twenty-five centimetres across the screen?  Call me lazy, but it seems like a lot of unneeded work to me.

Another more minor issue would be the dirty, dirty screen.  My screens, (on all of my computers, not just the MacBook Pro), get pretty dirty, I they would probably get pretty disgusting if I was touching them all of the time, instead of just sometimes as I do now.  True, I could, (and would), clean the screen, but it’s not just a one and a half second wipe like on an iPhone or iPod Touch – I imagine that it would get annoying after a while.

A tablet form factor would reduce these problems.  I have never owned a Tablet PC myself, but the demos I’ve seen were pretty cool and I can see how they would be useful in some situations, but for everyday computing I don’t really see how the added cost of a touch screen would give a MacBook Touch any added value.

Of course, they usually seem to figure out how to do it down there at Apple, so if they are actually working on a MacBook Touch, it may be excellent, we’ll have to wait and see.