~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-09-10 20:59:01 UTC
  • mto: This revision was merged to the branch mainline in revision 2004.
  • Revision ID: john@arbash-meinel.com-20060910205901-ceb5929c1497f81f
start working on some lazy importing code

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
# Copyright (C) 2006 Canonical Ltd
2
 
 
 
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
5
5
# the Free Software Foundation; either version 2 of the License, or
6
6
# (at your option) any later version.
7
 
 
 
7
#
8
8
# This program is distributed in the hope that it will be useful,
9
9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
10
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11
11
# GNU General Public License for more details.
12
 
 
 
12
#
13
13
# You should have received a copy of the GNU General Public License
14
14
# along with this program; if not, write to the Free Software
15
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
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'))