from subvertpy._ra import *
from subvertpy import ra_svn
-import urllib
+try:
+ from urllib2 import splittype
+except ImportError:
+ from urllib.parse import splittype
url_handlers = {
"svn": _ra.RemoteAccess,
"""
if isinstance(url, bytes):
url = url.decode("utf-8")
- (type, opaque) = urllib.splittype(url)
+ (type, opaque) = splittype(url)
if not type in url_handlers:
raise SubversionException("Unknown URL type '%s'" % type, ERR_BAD_URL)
return url_handlers[type](url, *args, **kwargs)
import os
import socket
import subprocess
-import urllib
from errno import EPIPE
+try:
+ import urlparse
+except ImportError:
+ import urllib.parse as urlparse
from subvertpy import (
ERR_RA_SVN_UNKNOWN_CMD,
def __init__(self, url, progress_cb=None, auth=None, config=None,
client_string_func=None, open_tmp_file_func=None):
self.url = url
- (type, opaque) = urllib.splittype(url)
+ (type, opaque) = urlparse.splittype(url)
assert type in ("svn", "svn+ssh")
- (host, path) = urllib.splithost(opaque)
+ (host, path) = urlparse.splithost(opaque)
self._progress_cb = progress_cb
self._auth = auth
self._config = config
_recv_ack = _unpack
def _connect(self, host):
- (host, port) = urllib.splitnport(host, SVN_PORT)
+ (host, port) = urlparse.splitnport(host, SVN_PORT)
sockaddrs = socket.getaddrinfo(host, port, socket.AF_UNSPEC,
socket.SOCK_STREAM, 0, 0)
self._socket = None
try:
self._socket = socket.socket(family, socktype, proto)
self._socket.connect(sockaddr)
- except socket.error:
+ except socket.error as err:
if self._socket is not None:
self._socket.close()
self._socket = None
return (self._socket.recv, self._socket.send)
def _connect_ssh(self, host):
- (user, host) = urllib.splituser(host)
+ (user, host) = urlparse.splituser(host)
if user is not None:
- (user, password) = urllib.splitpassword(user)
+ (user, password) = urlparse.splitpassword(user)
else:
password = None
- (host, port) = urllib.splitnport(host, 22)
+ (host, port) = urlparse.splitnport(host, 22)
self._tunnel = get_ssh_vendor().connect_ssh(user, password, host, port, ["svnserve", "-t"])
return (self._tunnel.recv, self._tunnel.send)
self.send_success()
def open_backend(self, url):
- (rooturl, location) = urllib.splithost(url)
+ (rooturl, location) = urlparse.splithost(url)
self.repo_backend, self.relpath = self.backend.open_repository(location)
def reparent(self, parent):
import sys
import tempfile
import unittest
-import urllib2
-import urllib
try:
import urlparse
except ImportError:
import urllib.parse as urlparse
+try:
+ from urllib import pathname2url
+except ImportError:
+ from urllib.request import pathname2url
from subvertpy import (
client,
def modify(self, contents=None):
if contents is None:
- contents = urllib2.randombytes(100)
+ contents = os.urandom(100)
txdelta = self.file.apply_textdelta()
delta.send_stream(BytesIO(contents), txdelta)
os.chmod(revprop_hook, os.stat(revprop_hook).st_mode | 0o111)
if sys.platform == 'win32':
- return 'file:%s' % urllib.pathname2url(abspath)
+ return 'file:%s' % pathname2url(abspath)
else:
return "file://%s" % abspath