Remove query interface, add whole-repository interface; add hg support

The code's still a bit messy, but I wanted to submit this so it was on your radar.