~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/lock.py

  • Committer: John Arbash Meinel
  • Date: 2007-03-19 22:11:28 UTC
  • mto: This revision was merged to the branch mainline in revision 2367.
  • Revision ID: john@arbash-meinel.com-20070319221128-iphfdqrrfqypfjva
make Write locks not block on Read locks, so that revert tests don't fail
Specifically: 
  test_revert.TestRevert.test_preserve_execute
  test_revert.TestRevert.test_revert_executable

fail if we fail to take a Write lock if we have a Read lock.

Show diffs side-by-side

added added

removed removed

Lines of Context:
124
124
            super(_fcntl_WriteLock, self).__init__()
125
125
            # Check we can grab a lock before we actually open the file.
126
126
            self.filename = osutils.realpath(filename)
127
 
            if (self.filename in _fcntl_WriteLock._open_locks
128
 
                or self.filename in _fcntl_ReadLock._open_locks):
 
127
            if self.filename in _fcntl_WriteLock._open_locks:
129
128
                self._clear_f()
130
129
                raise errors.LockContention(self.filename)
131
130
 
158
157
        def __init__(self, filename):
159
158
            super(_fcntl_ReadLock, self).__init__()
160
159
            self.filename = osutils.realpath(filename)
161
 
            # if self.filename in _fcntl_WriteLock._open_locks:
162
 
            #     raise errors.LockContention(self.filename)
163
160
            _fcntl_ReadLock._open_locks.setdefault(self.filename, 0)
164
161
            _fcntl_ReadLock._open_locks[self.filename] += 1
165
162
            self._open(filename, 'rb')