Although I use Git all day long, I actually prefer to use Mercurial for my personal stuff. When I started working on this project to maintain slaptijack.com with Pelican rather than continuing to use Wordpress, one of the things that really interested me was the ability to keep Markdown files in a Mercurial repository hosted at Bitbucket. In fact, although I have the repository marked private right now, one of my goals is to eventually open-source this project, too.
All of this is to say that when I go to publish the site via Fabric (
fab publish), I don't want to publish anything that has not been checked into the repository. Although it's just me working on the site, there's a good chance that I might be using a different computer at any given time. The solution to my problem is for
publish() to ensure everything is checked in before pushing to the site.
I solved this problem by creating a new function in
hg_check(). This function runs
hg status and barfs if there is any output. Since there is only output when something needs to be committed or added and committed, this suits the bill. It's worth noting that barfing on files that need to be added is just as important as files that merely need to be committed. Here's a diff of the changes I made to
fabfile.py and the (non-colorized) output you see when
fabric.colors to print big red warnings. Danger, Will Robinson!
Anyway, best of luck!
As a brief aside, I used Christophe Marois' awesome hack to float the Fabric logo to the right. Now, there's nothing more than
[![Fabric logo -right]] in my Markdown source for this article. Thanks, Christophe!