~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/local_transport.py

  • Committer: John Arbash Meinel
  • Date: 2005-07-11 22:24:03 UTC
  • mto: (1185.11.1)
  • mto: This revision was merged to the branch mainline in revision 1396.
  • Revision ID: john@arbash-meinel.com-20050711222403-5dc86e254b69f7ab
Remote functionality work.
Added lock_read/write() to Transport.
Turns out that both urllib2 and urlgrabber don't let you
seek on files that are returned, and GzipFile wants to
seek on the file when it is read. So instead,
we check, and wrap in a StringIO when required.

Show diffs side-by-side

added added

removed removed

Lines of Context:
36
36
            relpath = [relpath]
37
37
        return os.path.join(self.base, *relpath)
38
38
 
 
39
    def relpath(self, abspath):
 
40
        """Return the local path portion from a given absolute path.
 
41
        """
 
42
        from branch import _relpath
 
43
        return _relpath(self.base, abspath)
 
44
 
39
45
    def has(self, relpath):
40
46
        return os.access(self.abspath(relpath), os.F_OK)
41
47
 
121
127
        """
122
128
        return os.stat(self.abspath(relpath))
123
129
 
 
130
    def lock_read(self, relpath):
 
131
        """Lock the given file for shared (read) access.
 
132
        :return: A lock object, which should be passed to Transport.unlock()
 
133
        """
 
134
        from bzrlib.lock import ReadLock
 
135
        return ReadLock(self.abspath(relpath))
 
136
 
 
137
    def lock_write(self, relpath):
 
138
        """Lock the given file for exclusive (write) access.
 
139
        WARNING: many transports do not support this, so trying avoid using it
 
140
 
 
141
        :return: A lock object, which should be passed to Transport.unlock()
 
142
        """
 
143
        from bzrlib.lock import WriteLock
 
144
        return WriteLock(self.abspath(relpath))
 
145
 
124
146
# If nothing else matches, try the LocalTransport
125
147
protocol_handlers[None] = LocalTransport
126
148