/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_paths2ids.py

Finish making Tree.ids2paths support the file_ids_across_trees api.

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
 
24
24
from operator import attrgetter
25
25
 
26
 
from bzrlib import errors, inventory
 
26
from bzrlib import errors
27
27
from bzrlib.tests.workingtree_implementations import TestCaseWithWorkingTree
28
28
 
29
29
 
30
30
class TestPaths2Ids(TestCaseWithWorkingTree):
31
31
 
32
 
    def assertExpectedIds(self, ids, tree, paths, trees=None):
 
32
    def assertExpectedIds(self, ids, tree, paths, trees=None,
 
33
        require_versioned=True):
33
34
        """Run paths2ids for tree, and check the result."""
34
35
        tree.lock_read()
35
36
        if trees:
36
37
            map(apply, map(attrgetter('lock_read'), trees))
37
 
            result = tree.paths2ids(paths, trees)
 
38
            result = tree.paths2ids(paths, trees,
 
39
                require_versioned=require_versioned)
38
40
            map(apply, map(attrgetter('unlock'), trees))
39
41
        else:
40
 
            result = tree.paths2ids(paths)
 
42
            result = tree.paths2ids(paths,
 
43
                require_versioned=require_versioned)
41
44
        self.assertEqual(set(ids), result)
42
45
        tree.unlock()
43
46
 
130
133
        self.assertExpectedIds(
131
134
            ['dir', 'child-moves', 'child-stays', 'child-goes', 'new-child'],
132
135
            tree, ['dir'], [basis])
 
136
 
 
137
    def test_unversioned_one_tree(self):
 
138
        tree = self.make_branch_and_tree('tree')
 
139
        self.build_tree(['tree/unversioned'])
 
140
        self.assertExpectedIds([], tree, ['unversioned'], require_versioned=False)
 
141
        tree.lock_read()
 
142
        self.assertRaises(errors.PathsNotVersionedError, tree.paths2ids, ['unversioned'])
 
143
        tree.unlock()
 
144
 
 
145
    def test_unversioned_multiple_trees(self):
 
146
        # in this test, the path is unversioned in only one tree, but it should
 
147
        # still raise an error.
 
148
        tree = self.make_branch_and_tree('tree')
 
149
        tree.commit('make basis')
 
150
        basis = tree.basis_tree()
 
151
        self.build_tree(['tree/unversioned'])
 
152
        self.assertExpectedIds([], tree, ['unversioned'], [basis],
 
153
            require_versioned=False)
 
154
        tree.lock_read()
 
155
        basis.lock_read()
 
156
        self.assertRaises(errors.PathsNotVersionedError, tree.paths2ids,
 
157
            ['unversioned'], [basis])
 
158
        self.assertRaises(errors.PathsNotVersionedError, basis.paths2ids,
 
159
            ['unversioned'], [tree])
 
160
        basis.unlock()
 
161
        tree.unlock()