~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_lockdir.py

Merge from bzr.dev.

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