~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/lockdir.py

  • Committer: Robert Collins
  • Date: 2006-03-28 14:29:13 UTC
  • mto: (1626.2.1 integration)
  • mto: This revision was merged to the branch mainline in revision 1628.
  • Revision ID: robertc@robertcollins.net-20060328142913-ac5afb37075719c6
Convert log to use the new tsort.merge_sort routine.

Show diffs side-by-side

added added

removed removed

Lines of Context:
109
109
        LockError,
110
110
        LockNotHeld,
111
111
        NoSuchFile,
112
 
        PathError,
113
 
        ResourceBusy,
114
112
        UnlockableTransport,
115
113
        )
116
 
from bzrlib.trace import mutter
117
114
from bzrlib.transport import Transport
118
115
from bzrlib.osutils import rand_chars
119
116
from bzrlib.rio import RioWriter, read_stanza, Stanza
173
170
 
174
171
    is_held = property(lambda self: self._lock_held)
175
172
 
176
 
    def create(self, mode=None):
 
173
    def create(self):
177
174
        """Create the on-disk lock.
178
175
 
179
176
        This is typically only called when the object/directory containing the 
181
178
        """
182
179
        if self.transport.is_readonly():
183
180
            raise UnlockableTransport(self.transport)
184
 
        self.transport.mkdir(self.path, mode=mode)
 
181
        self.transport.mkdir(self.path)
185
182
 
186
183
    def attempt_lock(self):
187
184
        """Take the lock; fail if it's already held.
203
200
            self.transport.rename(tmpname, self._held_dir)
204
201
            self._lock_held = True
205
202
            self.confirm()
206
 
        except (PathError, DirectoryNotEmpty, FileExists, ResourceBusy), e:
207
 
            mutter("contention on %r: %s", self, e)
208
 
            raise LockContention(self)
 
203
            return
 
204
        except (DirectoryNotEmpty, FileExists), e:
 
205
            pass
 
206
        # fall through to here on contention
 
207
        raise LockContention(self)
209
208
 
210
209
    def unlock(self):
211
210
        """Release a held lock