~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/lock.py

  • Committer: Martin Pool
  • Date: 2007-04-04 01:22:11 UTC
  • mfrom: (2393.1.1 bzr.docs)
  • mto: This revision was merged to the branch mainline in revision 2397.
  • Revision ID: mbp@sourcefrog.net-20070404012211-sq269me6bai9m6xk
merge trunk and doc fix from elliot

Show diffs side-by-side

added added

removed removed

Lines of Context:
143
143
                    self.unlock()
144
144
                # we should be more precise about whats a locking
145
145
                # error and whats a random-other error
146
 
                raise errors.LockError(e)
 
146
                raise errors.LockContention(e)
147
147
 
148
148
        def unlock(self):
149
149
            _fcntl_WriteLock._open_locks.remove(self.filename)
167
167
            except IOError, e:
168
168
                # we should be more precise about whats a locking
169
169
                # error and whats a random-other error
170
 
                raise errors.LockError(e)
 
170
                raise errors.LockContention(e)
171
171
 
172
172
        def unlock(self):
173
173
            count = _fcntl_ReadLock._open_locks[self.filename]
228
228
            try:
229
229
                # LOCK_NB will cause IOError to be raised if we can't grab a
230
230
                # lock right away.
231
 
                fcntl.lockf(new_f, fcntl.LOCK_SH | fcntl.LOCK_NB)
 
231
                fcntl.lockf(new_f, fcntl.LOCK_EX | fcntl.LOCK_NB)
232
232
            except IOError, e:
233
233
                # TODO: Raise a more specific error based on the type of error
234
 
                raise errors.LockError(e)
 
234
                raise errors.LockContention(e)
235
235
            _fcntl_WriteLock._open_locks.add(self.filename)
236
236
 
237
237
            self.f = new_f
276
276
                raise
277
277
            except Exception, e:
278
278
                self._clear_f()
279
 
                raise errors.LockError(e)
 
279
                raise errors.LockContention(e)
280
280
 
281
281
        def unlock(self):
282
282
            overlapped = pywintypes.OVERLAPPED()
284
284
                win32file.UnlockFileEx(self.hfile, 0, 0x7fff0000, overlapped)
285
285
                self._clear_f()
286
286
            except Exception, e:
287
 
                raise errors.LockError(e)
 
287
                raise errors.LockContention(e)
288
288
 
289
289
 
290
290
    class _w32c_ReadLock(_w32c_FileLock):
393
393
                last_err = _GetLastError()
394
394
                if last_err in (ERROR_LOCK_VIOLATION,):
395
395
                    raise errors.LockContention(filename)
396
 
                raise errors.LockError('Unknown locking error: %s'
397
 
                                       % (last_err,))
 
396
                raise errors.LockContention('Unknown locking error: %s'
 
397
                                            % (last_err,))
398
398
 
399
399
        def unlock(self):
400
400
            overlapped = OVERLAPPED()
408
408
            if result == 0:
409
409
                self._clear_f()
410
410
                last_err = _GetLastError()
411
 
                raise errors.LockError('Unknown unlocking error: %s'
412
 
                                       % (last_err,))
 
411
                raise errors.LockContention('Unknown unlocking error: %s'
 
412
                                            % (last_err,))
413
413
 
414
414
 
415
415
    class _ctypes_ReadLock(_ctypes_FileLock):