mirror of
https://github.com/PyCQA/flake8.git
synced 2026-03-31 03:06:53 +00:00
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:
parent
84456866a5
commit
deb59817cf
2 changed files with 9 additions and 4 deletions
|
|
@ -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(
|
||||
|
|
|
|||
|
|
@ -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():
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue