28
28
('a', 'V', 'file', tree.path2id('a')),
29
29
('b', 'V', 'directory', tree.path2id('b')),
30
30
('b/c', 'V', 'file', tree.path2id('b/c')),
34
actual = [(path, status, kind, file_id)
35
for path, status, kind, file_id, ie in
36
tree.list_files(include_root=True)]
32
with tree.lock_read():
33
actual = [(path, status, kind, ie.file_id)
34
for path, status, kind, ie in
35
tree.list_files(include_root=True)]
39
36
self.assertEqual(expected, actual)
41
38
def test_list_files_no_root(self):
44
41
expected = [('a', 'V', 'file', tree.path2id('a')),
45
42
('b', 'V', 'directory', tree.path2id('b')),
46
43
('b/c', 'V', 'file', tree.path2id('b/c')),
50
actual = [(path, status, kind, file_id)
51
for path, status, kind, file_id, ie in
45
with tree.lock_read():
46
actual = [(path, status, kind, ie.file_id)
47
for path, status, kind, ie in
55
49
self.assertEqual(expected, actual)
57
51
def test_list_files_with_root_no_recurse(self):
59
53
tree = self.get_tree_no_parents_abc_content(work_tree)
60
54
expected = [('', 'V', 'directory', tree.path2id('')),
61
55
('a', 'V', 'file', tree.path2id('a')),
64
58
('b', 'V', 'directory', tree.path2id('b')))
65
59
with tree.lock_read():
66
actual = [(path, status, kind, file_id)
67
for path, status, kind, file_id, ie in
68
tree.list_files(include_root=True, recursive=False)]
60
actual = [(path, status, kind, ie.file_id)
61
for path, status, kind, ie in
62
tree.list_files(include_root=True, recursive=False)]
69
63
self.assertEqual(expected, actual)
71
65
def test_list_files_no_root_no_recurse(self):
74
68
expected = [('a', 'V', 'file', tree.path2id('a'))]
76
70
('b', 'V', 'directory', tree.path2id('b')))
79
actual = [(path, status, kind, file_id)
80
for path, status, kind, file_id, ie in
81
tree.list_files(recursive=False)]
71
with tree.lock_read():
72
actual = [(path, status, kind, ie.file_id)
73
for path, status, kind, ie in
74
tree.list_files(recursive=False)]
84
75
self.assertEqual(expected, actual)
86
77
def test_list_files_from_dir(self):
87
78
work_tree = self.make_branch_and_tree('wt')
88
79
tree = self.get_tree_no_parents_abc_content(work_tree)
89
80
expected = [('c', 'V', 'file', tree.path2id('b/c')),
93
actual = [(path, status, kind, file_id)
94
for path, status, kind, file_id, ie in
95
tree.list_files(from_dir=u'b')]
82
with tree.lock_read():
83
actual = [(path, status, kind, ie.file_id)
84
for path, status, kind, ie in
85
tree.list_files(from_dir=u'b')]
98
86
self.assertEqual(expected, actual)
100
88
def test_list_files_from_dir_no_recurse(self):
106
94
('b', 'V', 'directory', tree.path2id('b')))
108
96
with tree.lock_read():
109
actual = [(path, status, kind, file_id)
110
for path, status, kind, file_id, ie in
111
tree.list_files(from_dir='', recursive=False)]
97
actual = [(path, status, kind, ie.file_id)
98
for path, status, kind, ie in
99
tree.list_files(from_dir='', recursive=False)]
112
100
self.assertEqual(expected, actual)