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.
This commit is contained in:
Ian Cordasco 2016-06-14 08:04:13 -05:00
parent 84456866a5
commit deb59817cf
No known key found for this signature in database
GPG key ID: 656D3395E4A9791A
2 changed files with 9 additions and 4 deletions

View file

@ -44,8 +44,7 @@ def install():
"""Ensure that the mercurial hooks are installed.""" """Ensure that the mercurial hooks are installed."""
hgrc = find_hgrc(create_if_missing=True) hgrc = find_hgrc(create_if_missing=True)
if hgrc is None: if hgrc is None:
print('Could not locate your root mercurial repository.') return False
raise SystemExit(True)
hgconfig = configparser_for(hgrc) hgconfig = configparser_for(hgrc)
@ -76,6 +75,8 @@ def install():
with open(hgrc, 'w') as fd: with open(hgrc, 'w') as fd:
hgconfig.write(fd) hgconfig.write(fd)
return True
def find_hgrc(create_if_missing=False): def find_hgrc(create_if_missing=False):
root = subprocess.Popen( root = subprocess.Popen(

View file

@ -22,12 +22,16 @@ def install(option, option_string, value, parser):
""" """
installer = _INSTALLERS.get(value) installer = _INSTALLERS.get(value)
errored = False errored = False
successful = False
try: try:
installer() successful = installer()
except exc.HookInstallationError as hook_error: except exc.HookInstallationError as hook_error:
print(str(hook_error)) print(str(hook_error))
errored = True 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(): def choices():