Cleanup build script

The build script was a bit messy and inconsistent, it also printed out the get_revision mercurial stderr in an unclear format, making it seem as if the build script itself had failed. I made only minor changes to the actual codepaths, but instead made a few lexical/organizational and readability changes. Along with this, I included some better error printing for get_revision, PEP8 cleanup, and various other minor tweaks to make the script more "pythonic". Also, I noticed a few instances of murderous intent towards cute little kittens (semicolons), which where removed abruptly.

Hopefully this helps make the build script more extendable and usable in the future.