~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/lockdir.py

  • Committer: abentley
  • Date: 2006-04-20 23:47:53 UTC
  • mfrom: (1681 +trunk)
  • mto: This revision was merged to the branch mainline in revision 1683.
  • Revision ID: abentley@lappy-20060420234753-6a6874b76f09f86d
Merge bzr.dev

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