Extract common code from githook and hghook into a separate lib file.

Test Plan:
Ran, in this directory:
   ./githook.py /etc/passwd
and verified it failed with a lint error ('commit message' had no
reviewers or test plan).  Then created a 'real' fake commit message in
/tmp/cm_R0LS7N.commit:
---
Test

Review: K123324
---
and ran
   ./githook.py /tmp/cm_R0LS7N.commit
and saw it succeed with exit code 0.

Then went to my old 'stable' repo (in hg) and ran
   ./hghook.py
and saw it succeed with exit code 0, which shows that at least the
python is running correctly.  I instrumented report_errors_and_exit to
print what it saw, and everything looked ok.

Reviewers: benkomalo, alpert

Reviewed By: benkomalo

Differential Revision: http://phabricator.khanacademy.org/D2184