Skip to content

Commit

Permalink
fix for issue pypa#5375
Browse files Browse the repository at this point in the history
  • Loading branch information
Eric Lapouyade committed May 7, 2018
1 parent ff578b8 commit e0e1382
Showing 1 changed file with 33 additions and 24 deletions.
57 changes: 33 additions & 24 deletions src/pip/_internal/vcs/subversion.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,14 +229,20 @@ def remove_auth_from_url(url):

# parsed url
purl = urllib_parse.urlsplit(url)
stripped_netloc = \
purl.netloc.split('@')[-1]
# Do not remove auth for svn+ssh
# (svn --username is not recognized for that scheme)
if purl[0] == 'svn+ssh':
surl = url
else:
stripped_netloc = \
purl.netloc.split('@')[-1]

# stripped url
url_pieces = (
purl.scheme, stripped_netloc, purl.path, purl.query, purl.fragment
)
surl = urllib_parse.urlunsplit(url_pieces)
# stripped url
url_pieces = (
purl.scheme, stripped_netloc, purl.path, purl.query,
purl.fragment
)
surl = urllib_parse.urlunsplit(url_pieces)
return surl


Expand All @@ -245,25 +251,28 @@ def get_rev_options(vcs, url, rev):
Return a RevOptions object.
"""
r = urllib_parse.urlsplit(url)
if hasattr(r, 'username'):
# >= Python-2.5
username, password = r.username, r.password
else:
netloc = r[1]
if '@' in netloc:
auth = netloc.split('@')[0]
if ':' in auth:
username, password = auth.split(':', 1)
else:
username, password = auth, None
extra_args = []
# Do not get auth for svn+ssh
# (svn --username is not recognized for that scheme)
if r[0] != 'svn+ssh':
if hasattr(r, 'username'):
# >= Python-2.5
username, password = r.username, r.password
else:
username, password = None, None
netloc = r[1]
if '@' in netloc:
auth = netloc.split('@')[0]
if ':' in auth:
username, password = auth.split(':', 1)
else:
username, password = auth, None
else:
username, password = None, None

extra_args = []
if username:
extra_args += ['--username', username]
if password:
extra_args += ['--password', password]
if username:
extra_args += ['--username', username]
if password:
extra_args += ['--password', password]

return vcs.make_rev_options(rev, extra_args=extra_args)

Expand Down

0 comments on commit e0e1382

Please sign in to comment.