~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/lock.py

  • Committer: Martin Pool
  • Date: 2009-03-11 06:26:54 UTC
  • mto: This revision was merged to the branch mainline in revision 4114.
  • Revision ID: mbp@sourcefrog.net-20090311062654-xe3rp86l6npg2m9q
LockContention on OS locks now includes the filename

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2005, 2006, 2007, 2008 Canonical Ltd
 
1
# Copyright (C) 2005, 2006, 2007, 2008, 2009 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
185
185
                    self.unlock()
186
186
                # we should be more precise about whats a locking
187
187
                # error and whats a random-other error
188
 
                raise errors.LockContention(e)
 
188
                raise errors.LockContention(self.filename, e)
189
189
 
190
190
        def unlock(self):
191
191
            _fcntl_WriteLock._open_locks.remove(self.filename)
209
209
            except IOError, e:
210
210
                # we should be more precise about whats a locking
211
211
                # error and whats a random-other error
212
 
                raise errors.LockContention(e)
 
212
                raise errors.LockContention(self.filename, e)
213
213
 
214
214
        def unlock(self):
215
215
            count = _fcntl_ReadLock._open_locks[self.filename]
277
277
                fcntl.lockf(new_f, fcntl.LOCK_EX | fcntl.LOCK_NB)
278
278
            except IOError, e:
279
279
                # TODO: Raise a more specific error based on the type of error
280
 
                raise errors.LockContention(e)
 
280
                raise errors.LockContention(self.filename, e)
281
281
            _fcntl_WriteLock._open_locks.add(self.filename)
282
282
 
283
283
            self.f = new_f
322
322
                raise
323
323
            except Exception, e:
324
324
                self._clear_f()
325
 
                raise errors.LockContention(e)
 
325
                raise errors.LockContention(filename, e)
326
326
 
327
327
        def unlock(self):
328
328
            overlapped = pywintypes.OVERLAPPED()
330
330
                win32file.UnlockFileEx(self.hfile, 0, 0x7fff0000, overlapped)
331
331
                self._clear_f()
332
332
            except Exception, e:
333
 
                raise errors.LockContention(e)
 
333
                raise errors.LockContention(self.filename, e)
334
334
 
335
335
 
336
336
    class _w32c_ReadLock(_w32c_FileLock):
439
439
                last_err = _GetLastError()
440
440
                if last_err in (ERROR_LOCK_VIOLATION,):
441
441
                    raise errors.LockContention(filename)
442
 
                raise errors.LockContention('Unknown locking error: %s'
443
 
                                            % (last_err,))
 
442
                raise errors.LockContention(filename,
 
443
                    'Unknown locking error: %s' % (last_err,))
444
444
 
445
445
        def unlock(self):
446
446
            overlapped = OVERLAPPED()
454
454
            if result == 0:
455
455
                self._clear_f()
456
456
                last_err = _GetLastError()
457
 
                raise errors.LockContention('Unknown unlocking error: %s'
458
 
                                            % (last_err,))
 
457
                raise errors.LockContention(self.filename,
 
458
                    'Unknown unlocking error: %s' % (last_err,))
459
459
 
460
460
 
461
461
    class _ctypes_ReadLock(_ctypes_FileLock):