17
17
from breezy import (
20
21
from breezy.tests.per_tree import TestCaseWithTree
23
class IdTests(TestCaseWithTree):
24
class Path2IdTests(TestCaseWithTree):
26
super(IdTests, self).setUp()
27
super(Path2IdTests, self).setUp()
27
28
work_a = self.make_branch_and_tree('wta')
28
29
if not work_a.supports_setting_file_ids():
29
30
self.skipTest("working tree does not support setting file ids")
52
53
self.assertEqual('dir', self.tree_a.id2path(b'dir-id'))
53
54
self.assertEqual('dir/file', self.tree_a.id2path(b'file-id'))
54
55
self.assertRaises(errors.NoSuchId, self.tree_a.id2path, b'nonexistant')
57
class Path2IdsTests(TestCaseWithTree):
59
def test_paths2ids_recursive(self):
60
work_tree = self.make_branch_and_tree('tree')
61
self.build_tree(['tree/dir/', 'tree/dir/file'])
62
work_tree.add(['dir', 'dir/file'])
63
if not work_tree.supports_setting_file_ids():
64
raise tests.TestNotApplicable(
65
"test not applicable on non-inventory tests")
66
tree = self._convert_tree(work_tree)
68
self.addCleanup(tree.unlock)
69
self.assertEqual({tree.path2id('dir'), tree.path2id('dir/file')},
70
tree.paths2ids(['dir']))
72
def test_paths2ids_forget_old(self):
73
work_tree = self.make_branch_and_tree('tree')
74
self.build_tree(['tree/file'])
76
work_tree.commit('commit old state')
77
work_tree.remove('file')
78
if not work_tree.supports_setting_file_ids():
79
raise tests.TestNotApplicable(
80
"test not applicable on non-inventory tests")
81
tree = self._convert_tree(work_tree)
83
self.addCleanup(tree.unlock)
84
self.assertEqual(set([]), tree.paths2ids(['file'],
85
require_versioned=False))