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():