/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/tests/workingtree_implementations/test_workingtree.py

  • Committer: Robert Collins
  • Date: 2006-07-03 08:12:23 UTC
  • mfrom: (1832 +trunk)
  • mto: (1832.1.1 integration)
  • mto: This revision was merged to the branch mainline in revision 1833.
  • Revision ID: robertc@robertcollins.net-20060703081223-b106037c3fb29160
Merge from integration.

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
19
19
import os
20
20
 
21
21
import bzrlib
22
 
import bzrlib.branch
23
 
from bzrlib.branch import Branch
24
 
import bzrlib.bzrdir as bzrdir
25
 
from bzrlib.bzrdir import BzrDir
26
 
import bzrlib.errors as errors
 
22
from bzrlib import branch, bzrdir, errors, urlutils, workingtree
27
23
from bzrlib.errors import (NotBranchError, NotVersionedError, 
28
24
                           UnsupportedOperation)
29
25
from bzrlib.osutils import pathjoin, getcwd, has_symlinks
30
26
from bzrlib.tests import TestSkipped
31
27
from bzrlib.tests.workingtree_implementations import TestCaseWithWorkingTree
32
28
from bzrlib.trace import mutter
33
 
import bzrlib.urlutils as urlutils
34
 
import bzrlib.workingtree as workingtree
35
29
from bzrlib.workingtree import (TreeEntry, TreeDirectory, TreeFile, TreeLink,
36
30
                                WorkingTree)
37
 
 
 
31
from bzrlib.conflicts import ConflictList, TextConflict, ContentsConflict
38
32
 
39
33
class TestWorkingTree(TestCaseWithWorkingTree):
40
34
 
151
145
        tree.revert(['hello.txt'])
152
146
        self.failUnlessExists('hello.txt')
153
147
 
 
148
    def test_versioned_files_not_unknown(self):
 
149
        tree = self.make_branch_and_tree('.')
 
150
        self.build_tree(['hello.txt'])
 
151
        tree.add('hello.txt')
 
152
        self.assertEquals(list(tree.unknowns()),
 
153
                          [])
 
154
 
154
155
    def test_unknowns(self):
155
156
        tree = self.make_branch_and_tree('.')
156
157
        self.build_tree(['hello.txt',
177
178
    def test_initialize(self):
178
179
        # initialize should create a working tree and branch in an existing dir
179
180
        t = self.make_branch_and_tree('.')
180
 
        b = Branch.open('.')
 
181
        b = branch.Branch.open('.')
181
182
        self.assertEqual(t.branch.base, b.base)
182
183
        t2 = WorkingTree.open('.')
183
184
        self.assertEqual(t.basedir, t2.basedir)
390
391
        # current format
391
392
        self.build_tree(['checkout/', 'tree/file'])
392
393
        checkout = bzrdir.BzrDirMetaFormat1().initialize('checkout')
393
 
        bzrlib.branch.BranchReferenceFormat().initialize(checkout, main_branch)
 
394
        branch.BranchReferenceFormat().initialize(checkout, main_branch)
394
395
        old_tree = self.workingtree_format.initialize(checkout)
395
396
        # now commit to 'tree'
396
397
        wt.add('file')
421
422
        # current format
422
423
        self.build_tree(['checkout/', 'tree/file'])
423
424
        checkout = bzrdir.BzrDirMetaFormat1().initialize('checkout')
424
 
        bzrlib.branch.BranchReferenceFormat().initialize(checkout, main_branch)
 
425
        branch.BranchReferenceFormat().initialize(checkout, main_branch)
425
426
        old_tree = self.workingtree_format.initialize(checkout)
426
427
        # now commit to 'tree'
427
428
        wt.add('file')
528
529
        tree.add('blo')
529
530
        tree.commit("blah", allow_pointless=False)
530
531
        base = tree.basis_tree()
531
 
        BzrDir.open("mine").sprout("other")
 
532
        bzrdir.BzrDir.open("mine").sprout("other")
532
533
        file('other/bloo', 'wb').write('two')
533
534
        othertree = WorkingTree.open('other')
534
535
        othertree.commit('blah', allow_pointless=False)
542
543
        self.assertEqual(len(tree.conflicts()), 1)
543
544
 
544
545
    def test_clear_merge_conflicts(self):
545
 
        from bzrlib.conflicts import ConflictList
546
546
        tree = self.make_merge_conflicts()
547
547
        self.assertEqual(len(tree.conflicts()), 1)
548
548
        try:
551
551
            raise TestSkipped
552
552
        self.assertEqual(tree.conflicts(), ConflictList())
553
553
 
 
554
    def test_add_conflicts(self):
 
555
        tree = self.make_branch_and_tree('tree')
 
556
        try:
 
557
            tree.add_conflicts([TextConflict('path_a')])
 
558
        except UnsupportedOperation:
 
559
            raise TestSkipped()
 
560
        self.assertEqual(ConflictList([TextConflict('path_a')]),
 
561
                         tree.conflicts())
 
562
        tree.add_conflicts([TextConflict('path_a')])
 
563
        self.assertEqual(ConflictList([TextConflict('path_a')]), 
 
564
                         tree.conflicts())
 
565
        tree.add_conflicts([ContentsConflict('path_a')])
 
566
        self.assertEqual(ConflictList([ContentsConflict('path_a'), 
 
567
                                       TextConflict('path_a')]),
 
568
                         tree.conflicts())
 
569
        tree.add_conflicts([TextConflict('path_b')])
 
570
        self.assertEqual(ConflictList([ContentsConflict('path_a'), 
 
571
                                       TextConflict('path_a'),
 
572
                                       TextConflict('path_b')]),
 
573
                         tree.conflicts())
 
574
 
554
575
    def test_revert_clear_conflicts(self):
555
576
        tree = self.make_merge_conflicts()
556
577
        self.assertEqual(len(tree.conflicts()), 1)