~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

Add WorkingTree4.paths2ids which is inventory-usage free if the trees being examined are in the dirstate.

Show diffs side-by-side

added added

removed removed

Lines of Context:
36
36
# TODO: test that supplying paths with duplication - i.e. foo, foo, foo/bar -
37
37
# does not result in garbage out.
38
38
 
 
39
# TODO: Are we meant to raise the precise unversioned paths when some are
 
40
# unversioned - if so, test this.
39
41
 
40
42
class TestPaths2Ids(TestCaseWithWorkingTree):
41
43
 
54
56
        self.assertEqual(set(ids), result)
55
57
        tree.unlock()
56
58
 
 
59
    def test_paths_none_result_none(self):
 
60
        tree = self.make_branch_and_tree('tree')
 
61
        tree.lock_read()
 
62
        self.assertEqual(None, tree.paths2ids(None))
 
63
        tree.unlock()
 
64
 
57
65
    def test_find_single_root(self):
58
66
        tree = self.make_branch_and_tree('tree')
59
67
        self.assertExpectedIds([tree.path2id('')], tree, [''])
152
160
        self.assertRaises(errors.PathsNotVersionedError, tree.paths2ids, ['unversioned'])
153
161
        tree.unlock()
154
162
 
155
 
    def test_unversioned_multiple_trees(self):
156
 
        # in this test, the path is unversioned in only one tree, but it should
157
 
        # still raise an error.
158
 
        tree = self.make_branch_and_tree('tree')
159
 
        tree.commit('make basis')
160
 
        basis = tree.basis_tree()
161
 
        self.build_tree(['tree/unversioned'])
 
163
    def test_unversioned_in_one_of_multiple_trees(self):
 
164
        # in this test, the path is unversioned in only one tree, and thus
 
165
        # should not raise an error: it must be unversioned in *all* trees to
 
166
        # error.
 
167
        tree = self.make_branch_and_tree('tree')
 
168
        tree.commit('make basis')
 
169
        basis = tree.basis_tree()
 
170
        self.build_tree(['tree/in-one'])
 
171
        tree.add(['in-one'], ['in-one'])
 
172
        self.assertExpectedIds(['in-one'], tree, ['in-one'], [basis])
 
173
 
 
174
    def test_unversioned_all_of_multiple_trees(self):
 
175
        # in this test, the path is unversioned in every tree, and thus
 
176
        # should not raise an error: it must be unversioned in *all* trees to
 
177
        # error.
 
178
        tree = self.make_branch_and_tree('tree')
 
179
        tree.commit('make basis')
 
180
        basis = tree.basis_tree()
162
181
        self.assertExpectedIds([], tree, ['unversioned'], [basis],
163
182
            require_versioned=False)
164
183
        tree.lock_read()