~jelmer/ubuntu/maverick/bzr/2.2.5

« back to all changes in this revision

Viewing changes to bzrlib/transport/local.py

  • Committer: Bazaar Package Importer
  • Author(s): Jelmer Vernooij
  • Date: 2009-03-10 14:11:59 UTC
  • mfrom: (1.2.1 upstream) (3.1.68 jaunty)
  • Revision ID: james.westby@ubuntu.com-20090310141159-lwzzo5c1fwrtzgj4
New upstream release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
63
63
            base = urlutils.local_path_to_url(base)
64
64
        if base[-1] != '/':
65
65
            base = base + '/'
 
66
 
 
67
        # Special case : windows has no "root", but does have
 
68
        # multiple lettered drives inside it. #240910
 
69
        if sys.platform == 'win32' and base == 'file:///':
 
70
            base = ''
 
71
            self._local_base = ''
 
72
            super(LocalTransport, self).__init__(base)
 
73
            return
 
74
 
66
75
        super(LocalTransport, self).__init__(base)
67
76
        self._local_base = urlutils.local_path_from_url(base)
68
77
 
69
78
    def clone(self, offset=None):
70
79
        """Return a new LocalTransport with root at self.base + offset
71
 
        Because the local filesystem does not require a connection, 
 
80
        Because the local filesystem does not require a connection,
72
81
        we can just return a new object.
73
82
        """
74
83
        if offset is None:
100
109
        #       proper handling of stuff like
101
110
        path = osutils.normpath(osutils.pathjoin(
102
111
                    self._local_base, urlutils.unescape(relpath)))
 
112
        # on windows, our _local_base may or may not have a drive specified
 
113
        # (ie, it may be "/" or "c:/foo").
 
114
        # If 'relpath' is '/' we *always* get back an abspath without
 
115
        # the drive letter - but if our transport already has a drive letter,
 
116
        # we want our abspaths to have a drive letter too - so handle that
 
117
        # here.
 
118
        if (sys.platform == "win32" and self._local_base[1:2] == ":"
 
119
            and path == '/'):
 
120
            path = self._local_base[:3]
 
121
 
103
122
        return urlutils.local_path_to_url(path)
104
123
 
105
124
    def local_abspath(self, relpath):
108
127
        This function only exists for the LocalTransport, since it is
109
128
        the only one that has direct local access.
110
129
        This is mostly for stuff like WorkingTree which needs to know
111
 
        the local working directory.
112
 
        
 
130
        the local working directory.  The returned path will always contain
 
131
        forward slashes as the path separator, regardless of the platform.
 
132
 
113
133
        This function is quite expensive: it calls realpath which resolves
114
134
        symlinks.
115
135
        """
151
171
 
152
172
        :param relpath: Location to put the contents, relative to base.
153
173
        :param f:       File-like object.
154
 
        :param mode: The mode for the newly created file, 
 
174
        :param mode: The mode for the newly created file,
155
175
                     None means just use the default
156
176
        """
157
177
 
377
397
    def rename(self, rel_from, rel_to):
378
398
        path_from = self._abspath(rel_from)
379
399
        try:
380
 
            # *don't* call bzrlib.osutils.rename, because we want to 
 
400
            # *don't* call bzrlib.osutils.rename, because we want to
381
401
            # detect errors on rename
382
402
            os.rename(path_from, self._abspath(rel_to))
383
403
        except (IOError, OSError),e:
516
536
 
517
537
    def clone(self, offset=None):
518
538
        """Return a new LocalTransport with root at self.base + offset
519
 
        Because the local filesystem does not require a connection, 
 
539
        Because the local filesystem does not require a connection,
520
540
        we can just return a new object.
521
541
        """
522
542
        if offset is None:
533
553
 
534
554
class LocalURLServer(Server):
535
555
    """A pretend server for local transports, using file:// urls.
536
 
    
 
556
 
537
557
    Of course no actual server is required to access the local filesystem, so
538
558
    this just exists to tell the test code how to get to it.
539
559
    """
540
560
 
541
561
    def setUp(self):
542
562
        """Setup the server to service requests.
543
 
        
 
563
 
544
564
        :param decorated_transport: ignored by this implementation.
545
565
        """
546
566