/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to breezy/tests/per_tree/test_list_files.py

  • Committer: Jelmer Vernooij
  • Date: 2019-03-04 00:16:27 UTC
  • mfrom: (7293 work)
  • mto: This revision was merged to the branch mainline in revision 7318.
  • Revision ID: jelmer@jelmer.uk-20190304001627-v6u7o6pf97tukhek
Merge trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
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')),
31
 
                   ]
32
 
        tree.lock_read()
33
 
        try:
34
 
            actual = [(path, status, kind, file_id)
35
 
                      for path, status, kind, file_id, ie in
36
 
                          tree.list_files(include_root=True)]
37
 
        finally:
38
 
            tree.unlock()
 
31
                    ]
 
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)
40
37
 
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')),
47
 
                   ]
48
 
        tree.lock_read()
49
 
        try:
50
 
            actual = [(path, status, kind, file_id)
51
 
                      for path, status, kind, file_id, ie in
52
 
                          tree.list_files()]
53
 
        finally:
54
 
            tree.unlock()
 
44
                    ]
 
45
        with tree.lock_read():
 
46
            actual = [(path, status, kind, ie.file_id)
 
47
                      for path, status, kind, ie in
 
48
                      tree.list_files()]
55
49
        self.assertEqual(expected, actual)
56
50
 
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')),
62
 
                   ]
 
56
                    ]
63
57
        expected.append(
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)
70
64
 
71
65
    def test_list_files_no_root_no_recurse(self):
74
68
        expected = [('a', 'V', 'file', tree.path2id('a'))]
75
69
        expected.append(
76
70
            ('b', 'V', 'directory', tree.path2id('b')))
77
 
        tree.lock_read()
78
 
        try:
79
 
            actual = [(path, status, kind, file_id)
80
 
                for path, status, kind, file_id, ie in
81
 
                    tree.list_files(recursive=False)]
82
 
        finally:
83
 
            tree.unlock()
 
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)
85
76
 
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')),
90
 
                   ]
91
 
        tree.lock_read()
92
 
        try:
93
 
            actual = [(path, status, kind, file_id)
94
 
                      for path, status, kind, file_id, ie in
95
 
                          tree.list_files(from_dir=u'b')]
96
 
        finally:
97
 
            tree.unlock()
 
81
                    ]
 
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)
99
87
 
100
88
    def test_list_files_from_dir_no_recurse(self):
106
94
            ('b', 'V', 'directory', tree.path2id('b')))
107
95
 
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)