~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/lockdir.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2006-08-25 20:06:24 UTC
  • mfrom: (1955.1.2 create-lock-dir-56974)
  • Revision ID: pqm@pqm.ubuntu.com-20060825200624-719b2ca847a04dfa
(jam) LockDir.lock_write() can create the base directory if it is missing

Show diffs side-by-side

added added

removed removed

Lines of Context:
189
189
            raise UnlockableTransport(self.transport)
190
190
        try:
191
191
            tmpname = '%s/pending.%s.tmp' % (self.path, rand_chars(20))
192
 
            self.transport.mkdir(tmpname)
 
192
            try:
 
193
                self.transport.mkdir(tmpname)
 
194
            except NoSuchFile:
 
195
                # This may raise a FileExists exception
 
196
                # which is okay, it will be caught later and determined
 
197
                # to be a LockContention.
 
198
                self.create(mode=self._dir_modebits)
 
199
                
 
200
                # After creating the lock directory, try again
 
201
                self.transport.mkdir(tmpname)
 
202
 
193
203
            sio = StringIO()
194
204
            self._prepare_info(sio)
195
205
            sio.seek(0)
198
208
            # into place, because that's going to happen to the whole
199
209
            # directory
200
210
            self.transport.append(tmpname + self.__INFO_NAME, sio)
 
211
 
201
212
            self.transport.rename(tmpname, self._held_dir)
202
213
            self._lock_held = True
203
214
            self.confirm()