• David H's avatar
    Got mercurial hook working, with improvements · d1b77726
    David H authored
    This commit fixes a problem that caused "flake8 --install-hook mercurial" to
    die with this message:
        Could not find the mercurial directory
    Also fixes two usages of configparser (can't supply a non-text value when
    calling .set(), and need to use .getboolean() to convert the value to a
    This commit converts the hook itself from a function hook to a script hook.
    This enables the hook to run even when flake8 is installed in a virtual
    environment and Mercurial is installed globally (a common case.) This also
    makes it possible for flake8 to be installed for Python 3; Mercurial is
    Python 2.x only.
    Also convert the hook event from "commit" to "pretxncommit" so that strict
    mode would actually work. A regular commit hook runs only after the commit
    is completed; a pretxncommit hook will cause the transaction to be rolled
    back if it exits with a non-zero code.
    Finally, put extensions on the hook names: pretxncommit.flake8 and
    qrefresh.flake8. This allows the flake8 hook to coexist with other hooks the
    user might have put in place.
    I tested flake8 mercurial hook installation and execution on both Python 2.7
    and Python 3.5. I did *not* test the qrefresh.flake8 hook. I could not find
    documentation on qrefresh hook event; I presume it has something to do with
    the Mercurial MQ extension, which I have never used. Probably this commit
    does not make it any worse than it was before.
    For more info see:
    Closes #283
Last commit
Last update
api Loading commit data...
formatting Loading commit data...
main Loading commit data...
options Loading commit data...
plugins Loading commit data...
__init__.py Loading commit data...
__main__.py Loading commit data...
checker.py Loading commit data...
defaults.py Loading commit data...
exceptions.py Loading commit data...
processor.py Loading commit data...
statistics.py Loading commit data...
style_guide.py Loading commit data...
utils.py Loading commit data...