/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/transport/__init__.py

Merge from bzr.dev.

Show diffs side-by-side

added added

removed removed

Lines of Context:
50
50
        deprecated_function,
51
51
        DEPRECATED_PARAMETER,
52
52
        one_four,
53
 
        zero_ninety,
54
53
        )
55
54
from bzrlib.trace import (
56
55
    mutter,
135
134
                             register_netloc=False):
136
135
    transport_list_registry.register_transport(prefix, help)
137
136
    if register_netloc:
138
 
        assert prefix.endswith('://')
 
137
        if not prefix.endswith('://'):
 
138
            raise ValueError(prefix)
139
139
        register_urlparse_netloc_protocol(prefix[:-3])
140
140
 
141
141
 
179
179
        transport_list_registry.remove(scheme)
180
180
 
181
181
 
182
 
 
183
 
@deprecated_function(zero_ninety)
184
 
def split_url(url):
185
 
    # TODO: jam 20060606 urls should only be ascii, or they should raise InvalidURL
186
 
    if isinstance(url, unicode):
187
 
        url = url.encode('utf-8')
188
 
    (scheme, netloc, path, params,
189
 
     query, fragment) = urlparse.urlparse(url, allow_fragments=False)
190
 
    username = password = host = port = None
191
 
    if '@' in netloc:
192
 
        username, host = netloc.split('@', 1)
193
 
        if ':' in username:
194
 
            username, password = username.split(':', 1)
195
 
            password = urllib.unquote(password)
196
 
        username = urllib.unquote(username)
197
 
    else:
198
 
        host = netloc
199
 
 
200
 
    if ':' in host:
201
 
        host, port = host.rsplit(':', 1)
202
 
        try:
203
 
            port = int(port)
204
 
        except ValueError:
205
 
            # TODO: Should this be ConnectionError?
206
 
            raise errors.TransportError(
207
 
                'invalid port number %s in url:\n%s' % (port, url))
208
 
    host = urllib.unquote(host)
209
 
 
210
 
    path = urllib.unquote(path)
211
 
 
212
 
    return (scheme, username, password, host, port, path)
213
 
 
214
 
 
215
182
class _CoalescedOffset(object):
216
183
    """A data container for keeping track of coalesced offsets."""
217
184
 
404
371
        object or string to another one.
405
372
        This just gives them something easy to call.
406
373
        """
407
 
        assert not isinstance(from_file, basestring), \
408
 
            '_pump should only be called on files not %s' % (type(from_file,))
409
374
        return osutils.pumpfile(from_file, to_file)
410
375
 
411
376
    def _get_total(self, multi):
1000
965
 
1001
966
        :returns: the length of relpath before the content was written to it.
1002
967
        """
1003
 
        assert isinstance(bytes, str), \
1004
 
            'bytes must be a plain string, not %s' % type(bytes)
 
968
        if not isinstance(bytes, str):
 
969
            raise TypeError(
 
970
                'bytes must be a plain string, not %s' % type(bytes))
1005
971
        return self.append_file(relpath, StringIO(bytes), mode=mode)
1006
972
 
1007
973
    def append_multi(self, files, pb=None):
1540
1506
        return transport
1541
1507
 
1542
1508
 
1543
 
@deprecated_function(zero_ninety)
1544
 
def urlescape(relpath):
1545
 
    urlutils.escape(relpath)
1546
 
 
1547
 
 
1548
 
@deprecated_function(zero_ninety)
1549
 
def urlunescape(url):
1550
 
    urlutils.unescape(url)
1551
 
 
1552
1509
# We try to recognize an url lazily (ignoring user, password, etc)
1553
1510
_urlRE = re.compile(r'^(?P<proto>[^:/\\]+)://(?P<rest>.*)$')
1554
1511
 
1604
1561
            transport, last_err = _try_transport_factories(base, factory_list)
1605
1562
            if transport:
1606
1563
                if possible_transports is not None:
1607
 
                    assert transport not in possible_transports
 
1564
                    if transport in possible_transports:
 
1565
                        raise AssertionError()
1608
1566
                    possible_transports.append(transport)
1609
1567
                return transport
1610
1568