mirror of
https://github.com/pypa/pip
synced 2023-12-13 21:30:23 +01:00
Use guard clause in VersionControl.check_destination().
This commit is contained in:
parent
9ab837e30d
commit
9a7564e5c5
0
news/4BCF6244-41AE-4085-9E20-7C2A0336FB1D.trivial
Normal file
0
news/4BCF6244-41AE-4085-9E20-7C2A0336FB1D.trivial
Normal file
|
@ -298,49 +298,51 @@ class VersionControl(object):
|
|||
Args:
|
||||
rev_options: a RevOptions object.
|
||||
"""
|
||||
checkout = True
|
||||
if not os.path.exists(dest):
|
||||
return True
|
||||
|
||||
checkout = False
|
||||
prompt = False
|
||||
rev_display = rev_options.to_display()
|
||||
if os.path.exists(dest):
|
||||
checkout = False
|
||||
if os.path.exists(os.path.join(dest, self.dirname)):
|
||||
existing_url = self.get_url(dest)
|
||||
if self.compare_urls(existing_url, url):
|
||||
logger.debug(
|
||||
'%s in %s exists, and has correct URL (%s)',
|
||||
self.repo_name.title(),
|
||||
if os.path.exists(os.path.join(dest, self.dirname)):
|
||||
existing_url = self.get_url(dest)
|
||||
if self.compare_urls(existing_url, url):
|
||||
logger.debug(
|
||||
'%s in %s exists, and has correct URL (%s)',
|
||||
self.repo_name.title(),
|
||||
display_path(dest),
|
||||
url,
|
||||
)
|
||||
if not self.is_commit_id_equal(dest, rev_options.rev):
|
||||
logger.info(
|
||||
'Updating %s %s%s',
|
||||
display_path(dest),
|
||||
url,
|
||||
)
|
||||
if not self.is_commit_id_equal(dest, rev_options.rev):
|
||||
logger.info(
|
||||
'Updating %s %s%s',
|
||||
display_path(dest),
|
||||
self.repo_name,
|
||||
rev_display,
|
||||
)
|
||||
self.update(dest, rev_options)
|
||||
else:
|
||||
logger.info(
|
||||
'Skipping because already up-to-date.')
|
||||
else:
|
||||
logger.warning(
|
||||
'%s %s in %s exists with URL %s',
|
||||
self.name,
|
||||
self.repo_name,
|
||||
display_path(dest),
|
||||
existing_url,
|
||||
rev_display,
|
||||
)
|
||||
prompt = ('(s)witch, (i)gnore, (w)ipe, (b)ackup ',
|
||||
('s', 'i', 'w', 'b'))
|
||||
self.update(dest, rev_options)
|
||||
else:
|
||||
logger.info(
|
||||
'Skipping because already up-to-date.')
|
||||
else:
|
||||
logger.warning(
|
||||
'Directory %s already exists, and is not a %s %s.',
|
||||
dest,
|
||||
'%s %s in %s exists with URL %s',
|
||||
self.name,
|
||||
self.repo_name,
|
||||
display_path(dest),
|
||||
existing_url,
|
||||
)
|
||||
prompt = ('(i)gnore, (w)ipe, (b)ackup ', ('i', 'w', 'b'))
|
||||
prompt = ('(s)witch, (i)gnore, (w)ipe, (b)ackup ',
|
||||
('s', 'i', 'w', 'b'))
|
||||
else:
|
||||
logger.warning(
|
||||
'Directory %s already exists, and is not a %s %s.',
|
||||
dest,
|
||||
self.name,
|
||||
self.repo_name,
|
||||
)
|
||||
prompt = ('(i)gnore, (w)ipe, (b)ackup ', ('i', 'w', 'b'))
|
||||
|
||||
if prompt:
|
||||
logger.warning(
|
||||
'The plan is to install the %s repository %s',
|
||||
|
|
Loading…
Reference in a new issue