More robust discovery of Git and hg repository root directories

* Allows to run `flake8 --install-hook .` outside of repository root.
* Small bug fix for the case where no vcs directory was found