|
@@ -1031,16 +1031,16 @@ def default_urllib2_opener(config):
|
|
|
class HttpGitClient(GitClient):
|
|
|
|
|
|
def __init__(self, base_url, dumb=None, opener=None, config=None,
|
|
|
- user='',passwd='', **kwargs):
|
|
|
+ username=None, password=None, **kwargs):
|
|
|
self._base_url = base_url.rstrip("/") + "/"
|
|
|
self.dumb = dumb
|
|
|
if opener is None:
|
|
|
self.opener = default_urllib2_opener(config)
|
|
|
else:
|
|
|
self.opener = opener
|
|
|
- if user:
|
|
|
- pass_man=urllib2.HTTPPasswordMgrWithDefaultRealm()
|
|
|
- pass_man.add_password(None,base_url,user,passwd)
|
|
|
+ if username is not None:
|
|
|
+ pass_man = urllib2.HTTPPasswordMgrWithDefaultRealm()
|
|
|
+ pass_man.add_password(None, base_url, user, password)
|
|
|
self.opener.add_handler(urllib2.HTTPBasicAuthHandler(pass_man))
|
|
|
GitClient.__init__(self, **kwargs)
|
|
|
|
|
@@ -1049,7 +1049,12 @@ class HttpGitClient(GitClient):
|
|
|
|
|
|
@classmethod
|
|
|
def from_parsedurl(cls, parsedurl, **kwargs):
|
|
|
- return cls(urlparse.urlunparse(parsedurl), **kwargs)
|
|
|
+ auth, host = urllib2.splituser(parsedurl.netloc)
|
|
|
+ password = parsedurl.password
|
|
|
+ # TODO(jelmer): This also strips the username
|
|
|
+ parsedurl = parsedurl._replace(netloc=host)
|
|
|
+ return cls(urlparse.urlunparse(parsedurl),
|
|
|
+ password=password, **kwargs)
|
|
|
|
|
|
def __repr__(self):
|
|
|
return "%s(%r, dumb=%r)" % (type(self).__name__, self._base_url, self.dumb)
|
|
@@ -1223,7 +1228,6 @@ def get_transport_and_path_from_url(url, config=None, **kwargs):
|
|
|
:return: Tuple with client instance and relative path.
|
|
|
"""
|
|
|
parsed = urlparse.urlparse(url)
|
|
|
- auth, host = urllib2.splituser(parsed.netloc)
|
|
|
if parsed.scheme == 'git':
|
|
|
return (TCPGitClient.from_parsedurl(parsed, **kwargs),
|
|
|
parsed.path)
|
|
@@ -1233,8 +1237,8 @@ def get_transport_and_path_from_url(url, config=None, **kwargs):
|
|
|
path = parsed.path[1:]
|
|
|
return SSHGitClient.from_parsedurl(parsed, **kwargs), path
|
|
|
elif parsed.scheme in ('http', 'https'):
|
|
|
- return HttpGitClient.from_parsedurl(parsed._replace(netloc=host),
|
|
|
- config=config, passwd=parsed.password, **kwargs), parsed.path
|
|
|
+ return HttpGitClient.from_parsedurl(
|
|
|
+ parsed, config=config, **kwargs), parsed.path
|
|
|
elif parsed.scheme == 'file':
|
|
|
return default_local_git_client_cls.from_parsedurl(
|
|
|
parsed, **kwargs), parsed.path
|