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:
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.