/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

  • Committer: Robert J. Tanner
  • Date: 2009-04-29 05:53:21 UTC
  • mfrom: (4311 +trunk)
  • mto: This revision was merged to the branch mainline in revision 4312.
  • Revision ID: tanner@real-time.com-20090429055321-v2s5l1mgki9f6cgn
[merge] 1.14 back to trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2005, 2006, 2007 Canonical Ltd
 
1
# Copyright (C) 2005, 2006, 2007, 2008 Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
328
328
        """
329
329
        raise NotImplementedError(self.clone)
330
330
 
 
331
    def create_prefix(self):
 
332
        """Create all the directories leading down to self.base."""
 
333
        cur_transport = self
 
334
        needed = [cur_transport]
 
335
        # Recurse upwards until we can create a directory successfully
 
336
        while True:
 
337
            new_transport = cur_transport.clone('..')
 
338
            if new_transport.base == cur_transport.base:
 
339
                raise errors.BzrCommandError(
 
340
                    "Failed to create path prefix for %s."
 
341
                    % cur_transport.base)
 
342
            try:
 
343
                new_transport.mkdir('.')
 
344
            except errors.NoSuchFile:
 
345
                needed.append(new_transport)
 
346
                cur_transport = new_transport
 
347
            except errors.FileExists:
 
348
                break
 
349
            else:
 
350
                break
 
351
        # Now we only need to create child directories
 
352
        while needed:
 
353
            cur_transport = needed.pop()
 
354
            cur_transport.ensure_base()
 
355
 
331
356
    def ensure_base(self):
332
357
        """Ensure that the directory this transport references exists.
333
358
 
515
540
        """
516
541
        raise errors.NotLocalUrl(self.abspath(relpath))
517
542
 
518
 
 
519
543
    def has(self, relpath):
520
544
        """Does the file relpath exist?
521
545
 
1334
1358
 
1335
1359
    @staticmethod
1336
1360
    def _split_url(url):
1337
 
        """
1338
 
        Extract the server address, the credentials and the path from the url.
1339
 
 
1340
 
        user, password, host and path should be quoted if they contain reserved
1341
 
        chars.
1342
 
 
1343
 
        :param url: an quoted url
1344
 
 
1345
 
        :return: (scheme, user, password, host, port, path) tuple, all fields
1346
 
            are unquoted.
1347
 
        """
1348
 
        if isinstance(url, unicode):
1349
 
            raise errors.InvalidURL('should be ascii:\n%r' % url)
1350
 
        url = url.encode('utf-8')
1351
 
        (scheme, netloc, path, params,
1352
 
         query, fragment) = urlparse.urlparse(url, allow_fragments=False)
1353
 
        user = password = host = port = None
1354
 
        if '@' in netloc:
1355
 
            user, host = netloc.rsplit('@', 1)
1356
 
            if ':' in user:
1357
 
                user, password = user.split(':', 1)
1358
 
                password = urllib.unquote(password)
1359
 
            user = urllib.unquote(user)
1360
 
        else:
1361
 
            host = netloc
1362
 
 
1363
 
        if ':' in host:
1364
 
            host, port = host.rsplit(':', 1)
1365
 
            try:
1366
 
                port = int(port)
1367
 
            except ValueError:
1368
 
                raise errors.InvalidURL('invalid port number %s in url:\n%s' %
1369
 
                                        (port, url))
1370
 
        if host == '':
1371
 
            raise errors.InvalidURL('Host empty in: %s' % url)
1372
 
 
1373
 
        host = urllib.unquote(host)
1374
 
        path = urllib.unquote(path)
1375
 
 
1376
 
        return (scheme, user, password, host, port, path)
 
1361
        return urlutils.parse_url(url)
1377
1362
 
1378
1363
    @staticmethod
1379
1364
    def _unsplit_url(scheme, user, password, host, port, path):