~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_workingtree.py

MergeĀ fromĀ mainline

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# (C) 2005,2006 Canonical Ltd
 
1
# Copyright (C) 2005, 2006 Canonical Ltd
2
2
# Authors:  Robert Collins <robert.collins@canonical.com>
3
3
#
4
4
# This program is free software; you can redistribute it and/or modify
24
24
from bzrlib.bzrdir import BzrDir
25
25
import bzrlib.errors as errors
26
26
from bzrlib.errors import NotBranchError, NotVersionedError
 
27
from bzrlib.lockdir import LockDir
27
28
from bzrlib.osutils import pathjoin, getcwd, has_symlinks
28
29
from bzrlib.tests import TestCaseWithTransport
29
30
from bzrlib.trace import mutter
160
161
        tree = workingtree.WorkingTreeFormat3().initialize(control)
161
162
        # we want:
162
163
        # format 'Bazaar-NG Working Tree format 3'
163
 
        # lock ''
164
164
        # inventory = blank inventory
165
165
        # pending-merges = ''
166
166
        # stat-cache = ??
168
168
        t = control.get_workingtree_transport(None)
169
169
        self.assertEqualDiff('Bazaar-NG Working Tree format 3',
170
170
                             t.get('format').read())
171
 
        self.assertEqualDiff('', t.get('lock').read())
172
171
        self.assertEqualDiff('<inventory format="5">\n'
173
172
                             '</inventory>\n',
174
173
                             t.get('inventory').read())
179
178
        self.assertFalse(t.has('last-revision'))
180
179
        # TODO RBC 20060210 do a commit, check the inventory.basis is created 
181
180
        # correctly and last-revision file becomes present.
 
181
 
 
182
    def test_uses_lockdir(self):
 
183
        """WorkingTreeFormat3 uses its own LockDir:
 
184
            
 
185
            - lock is a directory
 
186
            - when the WorkingTree is locked, LockDir can see that
 
187
        """
 
188
        t = self.get_transport()
 
189
        url = self.get_url()
 
190
        dir = bzrdir.BzrDirMetaFormat1().initialize(url)
 
191
        repo = dir.create_repository()
 
192
        branch = dir.create_branch()
 
193
        tree = workingtree.WorkingTreeFormat3().initialize(dir)
 
194
        self.assertIsDirectory('.bzr', t)
 
195
        self.assertIsDirectory('.bzr/checkout', t)
 
196
        self.assertIsDirectory('.bzr/checkout/lock', t)
 
197
        our_lock = LockDir(t, '.bzr/checkout/lock')
 
198
        self.assertEquals(our_lock.peek(), None)
 
199
        tree.lock_write()
 
200
        self.assertTrue(our_lock.peek())
 
201
        tree.unlock()
 
202
        self.assertEquals(our_lock.peek(), None)