From deb59817cf8958e7899142a3c492d1b8463cf30f Mon Sep 17 00:00:00 2001 From: Ian Cordasco Date: Tue, 14 Jun 2016 08:04:13 -0500 Subject: [PATCH] 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. --- flake8/main/mercurial.py | 5 +++-- flake8/main/vcs.py | 8 ++++++-- 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():