124
124
self.addCleanup(tree.unlock)
125
125
self.assertEqual(set([]), tree.paths2ids(['file'],
126
126
require_versioned=False))
128
def _make_canonical_test_tree(self, commit=True):
129
# make a tree used by all the 'canonical' tests below.
130
work_tree = self.make_branch_and_tree('tree')
131
self.build_tree(['tree/dir/', 'tree/dir/file'])
132
work_tree.add(['dir', 'dir/file'])
134
work_tree.commit('commit 1')
137
def test_canonical_path(self):
138
work_tree = self._make_canonical_test_tree()
139
self.assertEqual(work_tree.get_canonical_inventory_path('Dir/File'), 'dir/file')
141
def test_canonical_path_before_commit(self):
142
work_tree = self._make_canonical_test_tree(False)
143
# note: not committed.
144
self.assertEqual(work_tree.get_canonical_inventory_path('Dir/File'), 'dir/file')
146
def test_canonical_path_dir(self):
147
# check it works when asked for just the directory portion.
148
work_tree = self._make_canonical_test_tree()
149
self.assertEqual(work_tree.get_canonical_inventory_path('Dir'), 'dir')
151
def test_canonical_path_root(self):
152
work_tree = self._make_canonical_test_tree()
153
self.assertEqual(work_tree.get_canonical_inventory_path(''), '')
154
self.assertEqual(work_tree.get_canonical_inventory_path('/'), '/')
156
def test_canonical_path_invalid_all(self):
157
work_tree = self._make_canonical_test_tree()
158
self.assertEqual(work_tree.get_canonical_inventory_path('foo/bar'), 'foo/bar')
160
def test_canonical_invalid_child(self):
161
work_tree = self._make_canonical_test_tree()
162
self.assertEqual(work_tree.get_canonical_inventory_path('Dir/None'), 'dir/None')