~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_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:
352
352
            self.assertRaises(LockBroken, ld1.unlock)
353
353
        finally:
354
354
            bzrlib.ui.ui_factory = orig_factory
 
355
 
 
356
    def test_create_missing_base_directory(self):
 
357
        """If LockDir.path doesn't exist, it can be created
 
358
 
 
359
        Some people manually remove the entire lock/ directory trying
 
360
        to unlock a stuck repository/branch/etc. Rather than failing
 
361
        after that, just create the lock directory when needed.
 
362
        """
 
363
        t = self.get_transport()
 
364
        lf1 = LockDir(t, 'test_lock')
 
365
 
 
366
        lf1.create()
 
367
        self.failUnless(t.has('test_lock'))
 
368
 
 
369
        t.rmdir('test_lock')
 
370
        self.failIf(t.has('test_lock'))
 
371
 
 
372
        # This will create 'test_lock' if it needs to
 
373
        lf1.lock_write()
 
374
        self.failUnless(t.has('test_lock'))
 
375
        self.failUnless(t.has('test_lock/held/info'))
 
376
 
 
377
        lf1.unlock()
 
378
        self.failIf(t.has('test_lock/held/info'))