~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/lock.py

  • Committer: Aaron Bentley
  • Date: 2005-09-21 15:33:23 UTC
  • mto: (1185.1.37)
  • mto: This revision was merged to the branch mainline in revision 1390.
  • Revision ID: abentley@panoramicfeedback.com-20050921153323-5db674d572d7649d
Fixed bug in distance-from-root graph operation

Show diffs side-by-side

added added

removed removed

Lines of Context:
52
52
                raise
53
53
 
54
54
            # maybe this is an old branch (before may 2005)
55
 
            mutter("trying to create missing branch lock %r", filename)
 
55
            mutter("trying to create missing branch lock %r" % filename)
56
56
            
57
57
            self.f = open(filename, 'wb')
58
58
            return self.f
84
84
        f = None
85
85
 
86
86
        def unlock(self):
87
 
            fcntl.lockf(self.f, fcntl.LOCK_UN)
 
87
            fcntl.flock(self.f, fcntl.LOCK_UN)
88
88
            self.f.close()
89
89
            del self.f 
90
90
 
92
92
    class _fcntl_WriteLock(_fcntl_FileLock):
93
93
        def __init__(self, filename):
94
94
            try:
95
 
                fcntl.lockf(self._open(filename, 'wb'), fcntl.LOCK_EX)
 
95
                fcntl.flock(self._open(filename, 'wb'), fcntl.LOCK_EX)
96
96
            except Exception, e:
97
97
                raise LockError(e)
98
98
 
100
100
    class _fcntl_ReadLock(_fcntl_FileLock):
101
101
        def __init__(self, filename):
102
102
            try:
103
 
                fcntl.lockf(self._open(filename, 'rb'), fcntl.LOCK_SH)
 
103
                fcntl.flock(self._open(filename, 'rb'), fcntl.LOCK_SH)
104
104
            except Exception, e:
105
105
                raise LockError(e)
106
106
 
112
112
        import win32con, win32file, pywintypes
113
113
 
114
114
 
115
 
        LOCK_SH = 0 # the default
116
 
        LOCK_EX = win32con.LOCKFILE_EXCLUSIVE_LOCK
117
 
        LOCK_NB = win32con.LOCKFILE_FAIL_IMMEDIATELY
 
115
        #LOCK_SH = 0 # the default
 
116
        #LOCK_EX = win32con.LOCKFILE_EXCLUSIVE_LOCK
 
117
        #LOCK_NB = win32con.LOCKFILE_FAIL_IMMEDIATELY
118
118
 
119
119
        class _w32c_FileLock(_base_Lock):
120
120
            def _lock(self, filename, openmode, lockmode):
139
139
 
140
140
        class _w32c_ReadLock(_w32c_FileLock):
141
141
            def __init__(self, filename):
142
 
                _w32c_FileLock._lock(self, filename, 'rb',
143
 
                                     LOCK_NB)
 
142
                _w32c_FileLock._lock(self, filename, 'rb', 0)
144
143
 
145
144
        class _w32c_WriteLock(_w32c_FileLock):
146
145
            def __init__(self, filename):
147
146
                _w32c_FileLock._lock(self, filename, 'wb',
148
 
                                     LOCK_EX + LOCK_NB)
 
147
                                     win32con.LOCKFILE_EXCLUSIVE_LOCK)
149
148
 
150
149
 
151
150