1
# Copyright (C) 2006, 2007 Canonical Ltd
1
# Copyright (C) 2006-2009, 2011, 2012, 2016 Canonical Ltd
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
105
105
tree = self.create_nested()
107
107
self.addCleanup(tree.unlock)
108
entry = tree.inventory['sub-root']
108
entry = tree.root_inventory['sub-root']
109
109
self.assertEqual([(u'subtree', 'sub-root')],
110
110
list(tree.iter_references()))
158
158
work_tree = self.make_branch_and_tree('wt')
159
159
tree = self.get_tree_no_parents_abc_content_2(work_tree)
162
# Test lookup without path works
163
lines = tree.get_file('a-id').readlines()
164
self.assertEqual(['foobar\n'], lines)
165
# Test lookup with path works
166
lines = tree.get_file('a-id', path='a').readlines()
167
self.assertEqual(['foobar\n'], lines)
161
self.addCleanup(tree.unlock)
162
# Test lookup without path works
163
file_without_path = tree.get_file('a-id')
165
lines = file_without_path.readlines()
166
self.assertEqual(['foobar\n'], lines)
168
file_without_path.close()
169
# Test lookup with path works
170
file_with_path = tree.get_file('a-id', path='a')
172
lines = file_with_path.readlines()
173
self.assertEqual(['foobar\n'], lines)
175
file_with_path.close()
171
177
def test_get_file_text(self):
172
178
work_tree = self.make_branch_and_tree('wt')
252
class TestIterChildEntries(TestCaseWithTree):
254
def test_iteration_order(self):
255
work_tree = self.make_branch_and_tree('.')
256
self.build_tree(['a/', 'a/b/', 'a/b/c', 'a/d/', 'a/d/e', 'f/', 'f/g'])
257
work_tree.add(['a', 'a/b', 'a/b/c', 'a/d', 'a/d/e', 'f', 'f/g'])
258
tree = self._convert_tree(work_tree)
259
output = [e.name for e in
260
tree.iter_child_entries(tree.get_root_id())]
261
self.assertEqual(set(['a', 'f']), set(output))
262
output = [e.name for e in
263
tree.iter_child_entries(tree.path2id('a'))]
264
self.assertEqual(set(['b', 'd']), set(output))
266
def test_does_not_exist(self):
267
work_tree = self.make_branch_and_tree('.')
268
self.build_tree(['a/'])
270
tree = self._convert_tree(work_tree)
271
self.assertRaises(errors.NoSuchId, lambda:
272
list(tree.iter_child_entries('unknown')))
246
275
class TestHasId(TestCaseWithTree):
248
277
def test_has_id(self):
318
347
self.addCleanup(tree.unlock)
319
348
(kind, data) = tree.get_file_verifier('file-id-1')
321
350
tree.get_file_verifier('file-id-1'),
322
351
tree.get_file_verifier('file-id-2'))
323
352
if kind == "SHA1":