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 minor changes to the actual code function, but instead made mostly 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 also removed.

Hopefully this helps make the build script more extendable and usable in the future.