~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_workingtree.py

  • Committer: abentley
  • Date: 2006-04-20 23:47:53 UTC
  • mfrom: (1681 +trunk)
  • mto: This revision was merged to the branch mainline in revision 1683.
  • Revision ID: abentley@lappy-20060420234753-6a6874b76f09f86d
Merge bzr.dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
22
22
from bzrlib.branch import Branch
23
23
import bzrlib.bzrdir as bzrdir
24
24
from bzrlib.bzrdir import BzrDir
 
25
from bzrlib.conflicts import *
25
26
import bzrlib.errors as errors
26
27
from bzrlib.errors import NotBranchError, NotVersionedError
27
28
from bzrlib.lockdir import LockDir
28
29
from bzrlib.osutils import pathjoin, getcwd, has_symlinks
29
 
from bzrlib.tests import TestCaseWithTransport
 
30
from bzrlib.tests import TestCaseWithTransport, TestSkipped
30
31
from bzrlib.trace import mutter
31
32
from bzrlib.transport import get_transport
32
33
import bzrlib.workingtree as workingtree
190
191
        dir = bzrdir.BzrDirMetaFormat1().initialize(url)
191
192
        repo = dir.create_repository()
192
193
        branch = dir.create_branch()
193
 
        tree = workingtree.WorkingTreeFormat3().initialize(dir)
 
194
        try:
 
195
            tree = workingtree.WorkingTreeFormat3().initialize(dir)
 
196
        except errors.NotLocalUrl:
 
197
            raise TestSkipped('Not a local URL')
194
198
        self.assertIsDirectory('.bzr', t)
195
199
        self.assertIsDirectory('.bzr/checkout', t)
196
200
        self.assertIsDirectory('.bzr/checkout/lock', t)
200
204
        self.assertTrue(our_lock.peek())
201
205
        tree.unlock()
202
206
        self.assertEquals(our_lock.peek(), None)
 
207
 
 
208
 
 
209
class TestFormat2WorkingTree(TestCaseWithTransport):
 
210
    """Tests that are specific to format 2 trees."""
 
211
 
 
212
    def create_format2_tree(self, url):
 
213
        return self.make_branch_and_tree(
 
214
            url, format=bzrlib.bzrdir.BzrDirFormat6())
 
215
 
 
216
    def test_conflicts(self):
 
217
        # test backwards compatability
 
218
        tree = self.create_format2_tree('.')
 
219
        self.assertRaises(errors.UnsupportedOperation, tree.set_conflicts,
 
220
                          None)
 
221
        file('lala.BASE', 'wb').write('labase')
 
222
        expected = ContentsConflict('lala')
 
223
        self.assertEqual(list(tree.conflicts()), [expected])
 
224
        file('lala', 'wb').write('la')
 
225
        tree.add('lala', 'lala-id')
 
226
        expected = ContentsConflict('lala', file_id='lala-id')
 
227
        self.assertEqual(list(tree.conflicts()), [expected])
 
228
        file('lala.THIS', 'wb').write('lathis')
 
229
        file('lala.OTHER', 'wb').write('laother')
 
230
        # When "text conflict"s happen, stem, THIS and OTHER are text
 
231
        expected = TextConflict('lala', file_id='lala-id')
 
232
        self.assertEqual(list(tree.conflicts()), [expected])
 
233
        os.unlink('lala.OTHER')
 
234
        os.mkdir('lala.OTHER')
 
235
        expected = ContentsConflict('lala', file_id='lala-id')
 
236
        self.assertEqual(list(tree.conflicts()), [expected])