Staying on top of Changes with Mercurial

If there’s one constant in software development, it’s change. Little changes here and there, and the occasional big change happen all the time.

Web development is the same, and arguably even more so. Freed from the need to package everything up and ship it in a numbered release, it’s all to easy to fix a single small bug and immediately make it live on the site. Or change a single word on one page, and make that live.

If you have more than one person working on a project (web or otherwise), keeping everyone’s changes in sync can be a chore. Back in the day when Jared and I were working on Redux together it was a simple matter for one of us to “claim” a chunk of the source code for an hour (or a day), telling the other to keep their hands off it.

Nowadays there is an entire genre of Source Code Management programs that keep track of everyone’s changes with a minimum of fuss. In addition they document changes, keep track of different revisions, know what files were changed when and by who (and why). They eliminate the possibility of one person stepping on another’s code (and wiping out their changes), and should a change go completely astray, they even let you revert to any earlier (working) version.

After looking at a few different SCM programs, I settled on Mercurial, which seemed the best fit for my working style. It’s lightweight, and installs easily on Mac OSX as well as the various Unix servers that host my web sites. You control Mercurial from the command line, using the new hg command it installs (from the chemical symbol for mercury: Hg).

After installing Mercurial, the first step was to pick one of my websites and tell Mercurial which files I want to keep track of for the site. I then made a snapshot of those files, or as Mercurial refers to it, a “changeset”. It asked me to include a brief comment with the changeset to describe it; for the first changeset a comment like “added key site files” worked just fine.

Now I make changes as usual, and Mercurial keeps track of what changed. I frequently commit a set of changes to a new changeset, along with a brief note describing the change. At any point if I don’t remember what I’ve changed a simple hg diff command will tell me not only which files changed, but which lines in those files changed (both old and current versions).

What’s very cool is that I can keep a local copy of the website on my MacBook, make changes locally and testing them, and when I’m satisfied that the changes are ready to go live I can send those changes to the website with a simple command: hg push.

Once the changes have been pushed to the site, I can make them live at my leisure; a simple hg update command instantly makes the changes live. No more fussing with uploading changes with ftp, messing with renaming files or worrying about copying files to the wrong directory.

Mercurial is easy to install, easy to learn, and easy to use. It makes it easy to keep track of changes, and to migrate those changes to different developers (or different locations, like live web sites). I’ve only scratched the surface of what it can do, but even after just a few days it’s already made my life easier.

GTD Update

So after trying out a bunch of different GTD apps, I’ve gone back to using “Thinking Rock”:1 as it’s the closest fit to how I imagine a GTD app should work. I can enter to-do items by project, then view them by date or by context. Thinking Rock automatically saves my actions periodically and backs them up, and even auto-saves a calendar file of my actions that iCal automatically imports. Finally, a short, custom perl script runs periodically to convert any action I haven’t set a time for into an ‘all day’ item for iCal.

With this setup I can see my list chronologically within Thinking Rock, which helpfully displays overdue items in red, today’s items are blue, while future items are green. I can sort the list by context, or just show a single context. I’ve got it set up so that it only shows me the next 7 days worth of items, thankfully hiding that March dentist appointment until the week before it happens. iCal gives me a calendar view, which I can look at by week, month or day. I usually leave it open to the current week, then periodically review the entire month and future months.

To capture items I use the kNotes widget if I’m at the computer, or a moleskine pocket notebook (with a slim bookmark pen inside that I discovered at Barnes and Noble). The moleskine is useful for capturing actions (pick up stamps soon) as well as notes to myself (books I need to research, or a word to be looked up).

For the most part this system works well for me, keeps me on top of the various things I need to do. I am far more organized than I was a year ago, and remembering meetings, commitments, milestones and other actions has never been easier.


A few months ago I noticed that Mail’s search was broken, because searches within “Entire Message” always turned up nothing, altho searching Subject, From or To seemed to be working fine. After a little detective work I found out that uses Spotlight when searching Entire Message, so maybe Spotlight wasn’t indexing the mail folders? I tried forcing the issue with various utilities and the command line, but nothing seemed to work.

Today I tried using mdutil to turn on indexing for the main volume, and it worked! The command I used was
> sudo mdutil -i on /

So now Spotlight is happily chugging away, and it says it will be done in about twelve hours.

I don’t remember turning off Spotlight, but I can easily imagine turning it off “temporarily” (because indexing was slowing down something or other) only to forget all about turning it back on again. Ooo look, shiny!

Update: It only took about an hour to update, not twelve.

TextMate: Can Text Editing really be this much fun?

Much of my Developer life revolves around working with text files: web pages, perl scripts, php scripts, SQL exports, javascript, log files, config files, time logs, and even plain ol’ text files.

BBEdit has been my text editor of choice since the late 90s, and it’s done a great job with pretty much everything I’ve thrown at it. It’s handled huge 30meg files with ease, displayed scripts with syntax coloring, let me convert between Mac, PC and Unix formats, preview web pages, given me a Jump command and a function popup that instantly transport me to the relevant section of long files, and even let me enhance it by adding my own scripts (for instance to total client hours in my time log).

Still, I passed on upgrading from version 7, as the new version 8 didn’t seem to offer much that was useful to me. BBEdit is a workhorse prduct and it’s certainly served me well over the years, but to be honest it just feels, well, stale.

I’ve been hearing about the new kid on the block, TextMate, for a while now. There’s even a cool video about Ruby on Rails that showcases TextMate as much as it does the ease of developing in RoR (the TextMate windows are the ones with colored text on a dark background; notice the hierarchy on the left, the tabs, and how stuff appears automatically).

In January I took advantage TextMate’s free 30 day trial, and bought it about a week later and have been using it ever since. TextMate is a joy to use; it looks and acts like an OSX app, and tailoring it to work like I do is far, far easier than BBEdit ever was. Things like text folding, language context macros, tabbed windows, smart snippets, tab completion, and one key “compare against saved version” make programming easier and more fun, and I’m more productive.

The TextMate community provides great support, many people have contributed plug-ins, themes, and bundles to enhance TextMate. It supports a number of programming languages as well as HTML, CSS, XML, Textile, Markdown and more. My little script to total client hours that I wrote for BBEdit ported over to TextMate in about two minutes, most of the time was spent figuring out where BBEdit had hidden it. TextMate’s built-in Bundle Editor saved it for me and call it back later — I didn’t have to save the file myself, nor did I have to read the manual to find out where I should save it (both of which I had to do with BBEdit).

Oh, I still keep BBEdit open while I work, but it’s pretty much just for doing multi-file searches (one of the few thing it does better than TextMate). BBEdit has served me well, but it’s time to be put that workhorse out to pasture.

Tracks: Ruby on Rails Meets GTD

I love it when two of my interests collide, and when it’s two fresh new interests that’s even better. The theme for this entire week as been Getting Things Done, and I’ve spent a fair amount of time collecting and organizing the things I need to do. I’ve also been curious about Ruby On Rails, a cool new tool for web development.

It turns out that there’s a GTD tool written using Rails called Tracks that does a great job of tracking projects, next actions and contexts. It’s free and it runs on my PowerBook, both big plusses as well.

Tracks was written to do GTD, which it does really well. Adding a new Next Action item (say “call to order a gate for the fence”) is as easy as clicking on the “Add the next action” link and typing it. Optionally you can add more details about that Next Action: you can attach a longer note to it, give it a due date, assign it to a project (Pool Fence Project), or give the action a context where it can be done (“next time I’m at the phone”). It’s easy to edit all three GTD pieces: Next Actions, Projects and Contexts, and to check off items as they’re completed. And it’s easy to print out the current state of things, so you can carry your To Do list in your pocket and leave the computer at home.

I’ve been keeping Tracks open in a browser tab, so it’s quick to switch to it and keep my To Do list up to date. So far Tracks has been trouble-free, and it’s way more fun to use than the Palm Desktop software (which was replaced by Tracks after just one day of using it to do GTD).

The downside of Tracks is that it’s still pretty geeky to set up, as you need use Terminal and set up a mySQL database. There was also a conflict between Tracks and Instiki (which also uses Rails), but I found a quick fix for that little problem.

It’s interesting that I’m relying more and more on browser-based tools like Instiki and Tracks to keep track of my life. They run on my machine and I don’t have to be connected to the net to use them.

*Update Oct 6*
Woke up way too early this morning and decided Tracks was running too slow as a CGI under Apache, so I installed Lighttpd and FastCGI per These instructions, but it barfed on the @sudo gem install fastcgi@ step, til I ran across this solution:

sudo gem install fcgi -- --with-fcgi-include=/opt/local/include --with-fcgi-lib=/opt/local/lib

Tiger: The First Day

After using Tiger (Mac OS X 10.4) all day today, here are my first impressions. Apple’s official Tiger page with lots of screenshots and feature lists is “here”:1.

I’m pleased that just about every program I use works just fine under Tiger. Not just applications, but low level system additions like “MenuMeters”:2 and “iKey”:3. I did have to replace “Virtue”:4 with “Desktop Manager”:5, but I’m missing how Virtue let me tag each virtual desktop with a different “graphic”:6.

Safari displays web pages much faster than before, and Help is finally fast enough to be usable. Graphic effects (like the Expose effect) seem twice as fast. Scrolling in the Terminal is wicked fast, it just it about a second to scroll thru a 200k text file.

“Dashboard”:7 is cool and widgets like the Calendar and Dictionary are useful enough to be incorporated into my workflow. The Stickies widget is my new To Do list, always an F12 key away. I like that Dashboard is yet another virtual desktop for me, and that the widgets don’t clutter up my workspace or take much CPU power when they’re not visible.

I wasn’t so sure about “Spotlight”:8 at first, since it wasn’t finding the things I expected, tho it is amazingly fast. I know now that adding keywords to photos lets Spotlight find them, and that I can tag individual files by adding a comment to them. It would still be nice if there was a way to easily apply a tag/property (like “Final Project”) to set of files *[update: there is, see below]*, and I’m not sure if there’s a way to specify “all pictures with a height less than 100 and a width more than 200” in the Spotlight text box. I could do that by searching in a window, and clicking the plus icon a couple times, then choosing from a few popup menus; that seems like a lot of work however. Still, it’s nice that it’s possible, short of writing a little perl script I don’t know how else that would be possible.

There are some nice little improvements in Tiger: choosing Get Info when more than one item is selected opens up multiple Get Info windows, just like the old MacOS days. The Apple menu and Spotlight buttons work if you mouse all the way up to the corner, so you don’t have to click right on them. Icons are now updated immediately when files are created and deleted (no more having to click on the desktop or in a folder to force a refresh). Command-Control-D shows the definition of the word the mouse is over.

The cool factor is there for show-off Tiger demos. The RSS screensaver is very nicely done, and Dashboard’s widgets are brightly colored and showy. Spotlight makes for an impressive demo, like using it to find a set of photos that you then turn into a slideshow.

Tiger is fast and usable and useful, and a pleasure to use. I recommend it highly.

**Update May 11:** Giles Turnbull wrote an “excellent article”:9 describing how he made **@taggit** with Automator to add tags to selected files in the Finder. A cool introduction to Automator, it solves the problem of how to easily tag multiple files all at once.


Waiting for Tiger

A few weeks ago I ordered the new Mac OS X, codename Tiger, from Amazon. Tiger was released on Friday, and I’ve been checking my order status several times a day since then to see when it will arrive. Amazon makes it really easy to track your order, and I love being able to track packages on their way to my door. Delivery was promised by today, and I’ve been checking the order status obsessively from time to time since Friday, but the site has only reported a frustrating “This item will be shipped soon.” Yesterday I figured they’d send the package out for next-day delivery and (finally) show a tracking number, but that wasn’t the case. Not even right before I went to bed, dammit.

But this morning Amazon shows it was shipped out on the 29th after all, and that headed out from Chelmsford, MA at 4 this morning. Woohoo! Looks like their delivery estimate was right after all, and there was no need to panic worry.

To the Mac faithful, an update to the system software is a major event. As satisfying as buying a new computer, these updates not only add spiffy new features, but generally make computer life more pleasant **and** they usually make your computer run faster (contrast with Windows updates which require ever-more horsepower and memory). Tiger’s brings us Spotlight, which effectively adds a database to the file system and makes it possible to do things like instantly find photos of Julie’s graduation in June 2003 (turning them into a slide show if you wish). Did I mention instant? It’s like a wicked fast Google for your hard drive, results show up **as you’re typing**. I’m really looking forward to playing around with Spotlight.

Dashboard offers a lot of cool new “widgets,” little single-purpose programs. There’s a little calendar widget, a calculator widget, one that tracks flights, and one that shows you weather forecasts. Supposedly it’s easy to create new widgets with a little knowledge of HTML, CSS and JavaScript, so there’s something to play around with.

Automator puts a user interface on scripting, making it far easier to automate repetitive tasks like sizing a group of web images to a width of 155 pixels and saving them out to a given folder. This has the potential to bring out the geek in a lot of Mac users who (like me) find AppleScript too hard to deal with.

Oh look, my package just arrived at UPS in Williston! Woohoo!

GoodPage Review

I’ve been using Tari “GoodPage”:1 for the past week to redesign the House-Mouse site. Unlike other CSS editors, GoodPage edits a page’s style sheet **and** its HTML, which makes it easier to create a modern web site. It can also show a live preview of the web page you’re editing so you can see the results of your changes without having to switch to a web browser, thus it consolidates three major parts of web page design. With GoodPage you do have to edit your HTML and CSS code directly, but I prefer doing that anyway.

GoodPage offers many ways to view your web page, but the ones I’m finding most useful are:

* HTML source code
* style sheet CSS source code
* structure (a graphic, 2D hierarchical view of the web page contents)
* list of individual css selectors (handy to look at a specific selector, rather than being overwhelmed by the entire style sheet)
* brower preview of the web page

The main window can display any two of those views side by side, so you can preview your web page in the left pane while you edit the html (or the style sheet) in the right pane. Or edit the html source and the stylesheet side by side. Or whatever combination you need at the moment. It’s handy not having to switch between windows, or to switch between programs for editing or previewing.

GoodPage offers a bunch of handy little tools to make development easier. For instance you can select an element in the web page preview (like a div, a paragraph or an image), and view its CSS properties in the other pane, then edit them and immediately see the change. This is great for debugging things like figuring out why there’s too much space above an element: you can not only see that top margin (or top padding) is too big, but which style sheet and selector are setting that property. And from there you can just fix the problem. Another nice feature of the side-by-side views is that you can select an element in one view hit Command-L, and a blue arrow appears to point out the corresponding item in the other view. So you can select a paragraph in the page preview and instantly see the html source for that paragraph in the other pane. Nice, it saves scrolling thru the source looking for it.

The developers have sucessfully leveraged the features offered by Mac OS X, and the program is a pleasure to use and is visually pleasing as well. I’m a sucker for aesthetic and useful, which is why I use a Mac.

As nice as it is, my biggest frustration with the program is that it comes with no documentation. None. The developers feel that GoodPage is so intuitively obvious to use that a manual just isn’t necessary. Unfortunately they’re wrong, and it’s taken a bit of stumbled around the program to figure out how to use it. In addition to only using a fraction of its features, I also feel that I’m not getting the most out of the features I am using. Using the program is like using some piece of wonderful alien technology that does some really cool things, but you just have to puzzle it out yourself and learn how to think like the aliens. For instance I can’t see what the big deal is with Structure View, but I get the impression that with it you can edit a page without knowing HTML, but I’ll be darned if I can figure it out. Still, what I have been able to discover has made me so much more productive that even after using it for just a few days, designing CSS web pages without using GoodPage would be so much harder.

With a price of $99 (early adopter special), it’s more expensive than the shareware alternatives, but cheaper than Dreamweaver. At that price it should include decent documentation, a tutorial, and more than the minimal CSS reference it comes with. Some sample templates would be also be great.

GoodPage works they way I do (at least what I’ve figured out so far) and it lets me focus on design without the distractions of switching to other programs, or searching through various style sheets for a given selector. This is an early version (1.1), so now that Tari has released this solid and useful tool I’m hoping they put their energy into writing a manual and perhaps creating a tutorial to show people how to use it. After all, what good are all those wonderful features if nobody can figure out how to use them?