|
@@ -47,17 +47,14 @@ import socket
|
|
|
import subprocess
|
|
|
import sys
|
|
|
|
|
|
-try:
|
|
|
- from urllib import quote as urlquote
|
|
|
- from urllib import unquote as urlunquote
|
|
|
-except ImportError:
|
|
|
- from urllib.parse import quote as urlquote
|
|
|
- from urllib.parse import unquote as urlunquote
|
|
|
-
|
|
|
-try:
|
|
|
- import urlparse
|
|
|
-except ImportError:
|
|
|
- import urllib.parse as urlparse
|
|
|
+from urllib.parse import (
|
|
|
+ quote as urlquote,
|
|
|
+ unquote as urlunquote,
|
|
|
+ urlparse,
|
|
|
+ urljoin,
|
|
|
+ urlunparse,
|
|
|
+ urlunsplit,
|
|
|
+ )
|
|
|
|
|
|
import dulwich
|
|
|
from dulwich.config import get_xdg_config_home_path
|
|
@@ -357,7 +354,7 @@ class GitClient(object):
|
|
|
"""Create an instance of this client from a urlparse.parsed object.
|
|
|
|
|
|
Args:
|
|
|
- parsedurl: Result of urlparse.urlparse()
|
|
|
+ parsedurl: Result of urlparse()
|
|
|
|
|
|
Returns:
|
|
|
A `GitClient` object
|
|
@@ -976,7 +973,7 @@ class TCPGitClient(TraditionalGitClient):
|
|
|
netloc = self._host
|
|
|
if self._port is not None and self._port != TCP_GIT_PORT:
|
|
|
netloc += ":%d" % self._port
|
|
|
- return urlparse.urlunsplit(("git", netloc, path, '', ''))
|
|
|
+ return urlunsplit(("git", netloc, path, '', ''))
|
|
|
|
|
|
def _connect(self, cmd, path):
|
|
|
if not isinstance(cmd, bytes):
|
|
@@ -1103,7 +1100,7 @@ class LocalGitClient(GitClient):
|
|
|
# Ignore the thin_packs argument
|
|
|
|
|
|
def get_url(self, path):
|
|
|
- return urlparse.urlunsplit(('file', '', path, '', ''))
|
|
|
+ return urlunsplit(('file', '', path, '', ''))
|
|
|
|
|
|
@classmethod
|
|
|
def from_parsedurl(cls, parsedurl, **kwargs):
|
|
@@ -1387,7 +1384,7 @@ class SSHGitClient(TraditionalGitClient):
|
|
|
if self.username is not None:
|
|
|
netloc = urlquote(self.username, '@/:') + "@" + netloc
|
|
|
|
|
|
- return urlparse.urlunsplit(('ssh', netloc, path, '', ''))
|
|
|
+ return urlunsplit(('ssh', netloc, path, '', ''))
|
|
|
|
|
|
@classmethod
|
|
|
def from_parsedurl(cls, parsedurl, **kwargs):
|
|
@@ -1553,7 +1550,7 @@ class HttpGitClient(GitClient):
|
|
|
if parsedurl.username:
|
|
|
netloc = "%s@%s" % (parsedurl.username, netloc)
|
|
|
parsedurl = parsedurl._replace(netloc=netloc)
|
|
|
- return cls(urlparse.urlunparse(parsedurl), **kwargs)
|
|
|
+ return cls(urlunparse(parsedurl), **kwargs)
|
|
|
|
|
|
def __repr__(self):
|
|
|
return "%s(%r, dumb=%r)" % (
|
|
@@ -1564,7 +1561,7 @@ class HttpGitClient(GitClient):
|
|
|
# urllib3.util.url._encode_invalid_chars() converts the path back
|
|
|
# to bytes using the utf-8 codec.
|
|
|
path = path.decode('utf-8')
|
|
|
- return urlparse.urljoin(self._base_url, path).rstrip("/") + "/"
|
|
|
+ return urljoin(self._base_url, path).rstrip("/") + "/"
|
|
|
|
|
|
def _http_request(self, url, headers=None, data=None,
|
|
|
allow_compression=False):
|
|
@@ -1628,7 +1625,7 @@ class HttpGitClient(GitClient):
|
|
|
headers = {"Accept": "*/*"}
|
|
|
if self.dumb is not True:
|
|
|
tail += "?service=%s" % service.decode('ascii')
|
|
|
- url = urlparse.urljoin(base_url, tail)
|
|
|
+ url = urljoin(base_url, tail)
|
|
|
resp, read = self._http_request(url, headers, allow_compression=True)
|
|
|
|
|
|
if resp.redirect_location:
|
|
@@ -1660,7 +1657,7 @@ class HttpGitClient(GitClient):
|
|
|
|
|
|
def _smart_request(self, service, url, data):
|
|
|
assert url[-1] == "/"
|
|
|
- url = urlparse.urljoin(url, service)
|
|
|
+ url = urljoin(url, service)
|
|
|
result_content_type = "application/x-%s-result" % service
|
|
|
headers = {
|
|
|
"Content-Type": "application/x-%s-request" % service,
|
|
@@ -1805,7 +1802,7 @@ def get_transport_and_path_from_url(url, config=None, **kwargs):
|
|
|
Tuple with client instance and relative path.
|
|
|
|
|
|
"""
|
|
|
- parsed = urlparse.urlparse(url)
|
|
|
+ parsed = urlparse(url)
|
|
|
if parsed.scheme == 'git':
|
|
|
return (TCPGitClient.from_parsedurl(parsed, **kwargs),
|
|
|
parsed.path)
|