Merge lp:~jelmer/brz/nomore-invtree into lp:brz

Proposed by Jelmer Vernooij on 2018-09-17
Status: Merged
Approved by: Jelmer Vernooij on 2018-09-22
Approved revision: 7123
Merge reported by: The Breezy Bot
Merged at revision: not available
Proposed branch: lp:~jelmer/brz/nomore-invtree
Merge into: lp:brz
Diff against target: 136 lines (+37/-37)
3 files modified
breezy/tests/per_tree/__init__.py (+1/-1)
breezy/tests/per_tree/test_ids.py (+34/-3)
breezy/tests/per_tree/test_symlinks.py (+2/-33)
To merge this branch: bzr merge lp:~jelmer/brz/nomore-invtree
Reviewer Review Type Date Requested Status
Martin Packman 2018-09-17 Approve on 2018-09-21
Review via email: mp+355137@code.launchpad.net

Commit message

Some refactoring; check for features rather than a specific implementation (InventoryTree).

Description of the change

Some refactoring; check for features rather than a specific implementation (InventoryTree).

To post a comment you must log in.
Martin Packman (gz) wrote :

Makes sense, thanks.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'breezy/tests/per_tree/__init__.py'
2--- breezy/tests/per_tree/__init__.py 2018-09-15 00:32:05 +0000
3+++ breezy/tests/per_tree/__init__.py 2018-09-17 12:34:26 +0000
4@@ -347,13 +347,13 @@
5 'get_root_id',
6 'get_symlink_target',
7 'ids',
8- 'inv',
9 'iter_search_rules',
10 'is_executable',
11 'list_files',
12 'locking',
13 'path_content_summary',
14 'revision_tree',
15+ 'symlinks',
16 'test_trees',
17 'tree',
18 'walkdirs',
19
20=== modified file 'breezy/tests/per_tree/test_ids.py'
21--- breezy/tests/per_tree/test_ids.py 2018-02-18 15:21:06 +0000
22+++ breezy/tests/per_tree/test_ids.py 2018-09-17 12:34:26 +0000
23@@ -16,14 +16,15 @@
24
25 from breezy import (
26 errors,
27-)
28+ tests,
29+ )
30 from breezy.tests.per_tree import TestCaseWithTree
31
32
33-class IdTests(TestCaseWithTree):
34+class Path2IdTests(TestCaseWithTree):
35
36 def setUp(self):
37- super(IdTests, self).setUp()
38+ super(Path2IdTests, self).setUp()
39 work_a = self.make_branch_and_tree('wta')
40 if not work_a.supports_setting_file_ids():
41 self.skipTest("working tree does not support setting file ids")
42@@ -52,3 +53,33 @@
43 self.assertEqual('dir', self.tree_a.id2path(b'dir-id'))
44 self.assertEqual('dir/file', self.tree_a.id2path(b'file-id'))
45 self.assertRaises(errors.NoSuchId, self.tree_a.id2path, b'nonexistant')
46+
47+class Path2IdsTests(TestCaseWithTree):
48+
49+ def test_paths2ids_recursive(self):
50+ work_tree = self.make_branch_and_tree('tree')
51+ self.build_tree(['tree/dir/', 'tree/dir/file'])
52+ work_tree.add(['dir', 'dir/file'])
53+ if not work_tree.supports_setting_file_ids():
54+ raise tests.TestNotApplicable(
55+ "test not applicable on non-inventory tests")
56+ tree = self._convert_tree(work_tree)
57+ tree.lock_read()
58+ self.addCleanup(tree.unlock)
59+ self.assertEqual({tree.path2id('dir'), tree.path2id('dir/file')},
60+ tree.paths2ids(['dir']))
61+
62+ def test_paths2ids_forget_old(self):
63+ work_tree = self.make_branch_and_tree('tree')
64+ self.build_tree(['tree/file'])
65+ work_tree.add('file')
66+ work_tree.commit('commit old state')
67+ work_tree.remove('file')
68+ if not work_tree.supports_setting_file_ids():
69+ raise tests.TestNotApplicable(
70+ "test not applicable on non-inventory tests")
71+ tree = self._convert_tree(work_tree)
72+ tree.lock_read()
73+ self.addCleanup(tree.unlock)
74+ self.assertEqual(set([]), tree.paths2ids(['file'],
75+ require_versioned=False))
76
77=== renamed file 'breezy/tests/per_tree/test_inv.py' => 'breezy/tests/per_tree/test_symlinks.py'
78--- breezy/tests/per_tree/test_inv.py 2018-09-14 13:54:04 +0000
79+++ breezy/tests/per_tree/test_symlinks.py 2018-09-17 12:34:26 +0000
80@@ -23,7 +23,6 @@
81 from breezy.tests import (
82 per_tree,
83 )
84-from breezy.bzr.inventorytree import InventoryTree
85 from breezy.mutabletree import MutableTree
86 from breezy.tests import TestSkipped
87 from breezy.transform import _PreviewTree
88@@ -36,12 +35,12 @@
89 return next(tree.iter_entries_by_dir(specific_files=[path]))[1]
90
91
92-class TestInventoryWithSymlinks(per_tree.TestCaseWithTree):
93+class TestTreeWithSymlinks(per_tree.TestCaseWithTree):
94
95 _test_needs_features = [features.SymlinkFeature]
96
97 def setUp(self):
98- super(TestInventoryWithSymlinks, self).setUp()
99+ super(TestTreeWithSymlinks, self).setUp()
100 self.tree = self.get_tree_with_subdirs_and_all_content_types()
101 self.tree.lock_read()
102 self.addCleanup(self.tree.unlock)
103@@ -67,33 +66,3 @@
104 self.assertEqual(entry.kind, 'symlink')
105 self.assertEqual(None, entry.text_size)
106
107-
108-class TestInventory(per_tree.TestCaseWithTree):
109-
110- def test_paths2ids_recursive(self):
111- work_tree = self.make_branch_and_tree('tree')
112- self.build_tree(['tree/dir/', 'tree/dir/file'])
113- work_tree.add(['dir', 'dir/file'])
114- tree = self._convert_tree(work_tree)
115- if not isinstance(tree, InventoryTree):
116- raise tests.TestNotApplicable(
117- "test not applicable on non-inventory tests")
118- tree.lock_read()
119- self.addCleanup(tree.unlock)
120- self.assertEqual({tree.path2id('dir'), tree.path2id('dir/file')},
121- tree.paths2ids(['dir']))
122-
123- def test_paths2ids_forget_old(self):
124- work_tree = self.make_branch_and_tree('tree')
125- self.build_tree(['tree/file'])
126- work_tree.add('file')
127- work_tree.commit('commit old state')
128- work_tree.remove('file')
129- tree = self._convert_tree(work_tree)
130- if not isinstance(tree, InventoryTree):
131- raise tests.TestNotApplicable(
132- "test not applicable on non-inventory tests")
133- tree.lock_read()
134- self.addCleanup(tree.unlock)
135- self.assertEqual(set([]), tree.paths2ids(['file'],
136- require_versioned=False))

Subscribers

People subscribed via source and target branches