~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/lockdir.py

  • Committer: John Arbash Meinel
  • Date: 2006-08-24 20:04:13 UTC
  • mto: This revision was merged to the branch mainline in revision 1959.
  • Revision ID: john@arbash-meinel.com-20060824200413-62b12d0a3650f510
LockDir can create the root directory if it fails to create a pending directory due to NoSuchFile.
This solves the problem where people manually delete the .bzr/repository/lock/ directory, and can no-longer commit
bug #56974

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()