summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIan Cordasco <graffatcolmingov@gmail.com>2016-06-14 08:04:13 -0500
committerIan Cordasco <graffatcolmingov@gmail.com>2016-06-14 08:04:13 -0500
commitdeb59817cf8958e7899142a3c492d1b8463cf30f (patch)
tree9ed8ff4d03d544aa4c964813d41144fefcf30037
parent84456866a5a8bbbe322ead206fe1e03309a0ad37 (diff)
downloadflake8-deb59817cf8958e7899142a3c492d1b8463cf30f.tar.gz
Use the same interface for vcs installation
flake8.main.git.install was already returning False if it couldn't find the directory to install into. This makes mercurial.install do the same thing and allows the vcs.install callback to understand that.
-rw-r--r--flake8/main/mercurial.py5
-rw-r--r--flake8/main/vcs.py8
2 files changed, 9 insertions, 4 deletions
diff --git a/flake8/main/mercurial.py b/flake8/main/mercurial.py
index 54725c6..10e5c06 100644
--- a/flake8/main/mercurial.py
+++ b/flake8/main/mercurial.py
@@ -44,8 +44,7 @@ def install():
"""Ensure that the mercurial hooks are installed."""
hgrc = find_hgrc(create_if_missing=True)
if hgrc is None:
- print('Could not locate your root mercurial repository.')
- raise SystemExit(True)
+ return False
hgconfig = configparser_for(hgrc)
@@ -76,6 +75,8 @@ def install():
with open(hgrc, 'w') as fd:
hgconfig.write(fd)
+ return True
+
def find_hgrc(create_if_missing=False):
root = subprocess.Popen(
diff --git a/flake8/main/vcs.py b/flake8/main/vcs.py
index 10e6256..6f7499e 100644
--- a/flake8/main/vcs.py
+++ b/flake8/main/vcs.py
@@ -22,12 +22,16 @@ def install(option, option_string, value, parser):
"""
installer = _INSTALLERS.get(value)
errored = False
+ successful = False
try:
- installer()
+ successful = installer()
except exc.HookInstallationError as hook_error:
print(str(hook_error))
errored = True
- raise SystemExit(errored)
+
+ if not successful:
+ print('Could not find the {0} directory'.format(value))
+ raise SystemExit(not successful and errored)
def choices():