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

Proposed by Jelmer Vernooij
Status: Merged
Approved by: Jelmer Vernooij
Approved revision: no longer in the source branch.
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 Approve
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.
Revision history for this message
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
=== modified file 'breezy/tests/per_tree/__init__.py'
--- breezy/tests/per_tree/__init__.py 2018-09-15 00:32:05 +0000
+++ breezy/tests/per_tree/__init__.py 2018-09-17 12:34:26 +0000
@@ -347,13 +347,13 @@
347 'get_root_id',347 'get_root_id',
348 'get_symlink_target',348 'get_symlink_target',
349 'ids',349 'ids',
350 'inv',
351 'iter_search_rules',350 'iter_search_rules',
352 'is_executable',351 'is_executable',
353 'list_files',352 'list_files',
354 'locking',353 'locking',
355 'path_content_summary',354 'path_content_summary',
356 'revision_tree',355 'revision_tree',
356 'symlinks',
357 'test_trees',357 'test_trees',
358 'tree',358 'tree',
359 'walkdirs',359 'walkdirs',
360360
=== modified file 'breezy/tests/per_tree/test_ids.py'
--- breezy/tests/per_tree/test_ids.py 2018-02-18 15:21:06 +0000
+++ breezy/tests/per_tree/test_ids.py 2018-09-17 12:34:26 +0000
@@ -16,14 +16,15 @@
1616
17from breezy import (17from breezy import (
18 errors,18 errors,
19)19 tests,
20 )
20from breezy.tests.per_tree import TestCaseWithTree21from breezy.tests.per_tree import TestCaseWithTree
2122
2223
23class IdTests(TestCaseWithTree):24class Path2IdTests(TestCaseWithTree):
2425
25 def setUp(self):26 def setUp(self):
26 super(IdTests, self).setUp()27 super(Path2IdTests, self).setUp()
27 work_a = self.make_branch_and_tree('wta')28 work_a = self.make_branch_and_tree('wta')
28 if not work_a.supports_setting_file_ids():29 if not work_a.supports_setting_file_ids():
29 self.skipTest("working tree does not support setting file ids")30 self.skipTest("working tree does not support setting file ids")
@@ -52,3 +53,33 @@
52 self.assertEqual('dir', self.tree_a.id2path(b'dir-id'))53 self.assertEqual('dir', self.tree_a.id2path(b'dir-id'))
53 self.assertEqual('dir/file', self.tree_a.id2path(b'file-id'))54 self.assertEqual('dir/file', self.tree_a.id2path(b'file-id'))
54 self.assertRaises(errors.NoSuchId, self.tree_a.id2path, b'nonexistant')55 self.assertRaises(errors.NoSuchId, self.tree_a.id2path, b'nonexistant')
56
57class Path2IdsTests(TestCaseWithTree):
58
59 def test_paths2ids_recursive(self):
60 work_tree = self.make_branch_and_tree('tree')
61 self.build_tree(['tree/dir/', 'tree/dir/file'])
62 work_tree.add(['dir', 'dir/file'])
63 if not work_tree.supports_setting_file_ids():
64 raise tests.TestNotApplicable(
65 "test not applicable on non-inventory tests")
66 tree = self._convert_tree(work_tree)
67 tree.lock_read()
68 self.addCleanup(tree.unlock)
69 self.assertEqual({tree.path2id('dir'), tree.path2id('dir/file')},
70 tree.paths2ids(['dir']))
71
72 def test_paths2ids_forget_old(self):
73 work_tree = self.make_branch_and_tree('tree')
74 self.build_tree(['tree/file'])
75 work_tree.add('file')
76 work_tree.commit('commit old state')
77 work_tree.remove('file')
78 if not work_tree.supports_setting_file_ids():
79 raise tests.TestNotApplicable(
80 "test not applicable on non-inventory tests")
81 tree = self._convert_tree(work_tree)
82 tree.lock_read()
83 self.addCleanup(tree.unlock)
84 self.assertEqual(set([]), tree.paths2ids(['file'],
85 require_versioned=False))
5586
=== renamed file 'breezy/tests/per_tree/test_inv.py' => 'breezy/tests/per_tree/test_symlinks.py'
--- breezy/tests/per_tree/test_inv.py 2018-09-14 13:54:04 +0000
+++ breezy/tests/per_tree/test_symlinks.py 2018-09-17 12:34:26 +0000
@@ -23,7 +23,6 @@
23from breezy.tests import (23from breezy.tests import (
24 per_tree,24 per_tree,
25 )25 )
26from breezy.bzr.inventorytree import InventoryTree
27from breezy.mutabletree import MutableTree26from breezy.mutabletree import MutableTree
28from breezy.tests import TestSkipped27from breezy.tests import TestSkipped
29from breezy.transform import _PreviewTree28from breezy.transform import _PreviewTree
@@ -36,12 +35,12 @@
36 return next(tree.iter_entries_by_dir(specific_files=[path]))[1]35 return next(tree.iter_entries_by_dir(specific_files=[path]))[1]
3736
3837
39class TestInventoryWithSymlinks(per_tree.TestCaseWithTree):38class TestTreeWithSymlinks(per_tree.TestCaseWithTree):
4039
41 _test_needs_features = [features.SymlinkFeature]40 _test_needs_features = [features.SymlinkFeature]
4241
43 def setUp(self):42 def setUp(self):
44 super(TestInventoryWithSymlinks, self).setUp()43 super(TestTreeWithSymlinks, self).setUp()
45 self.tree = self.get_tree_with_subdirs_and_all_content_types()44 self.tree = self.get_tree_with_subdirs_and_all_content_types()
46 self.tree.lock_read()45 self.tree.lock_read()
47 self.addCleanup(self.tree.unlock)46 self.addCleanup(self.tree.unlock)
@@ -67,33 +66,3 @@
67 self.assertEqual(entry.kind, 'symlink')66 self.assertEqual(entry.kind, 'symlink')
68 self.assertEqual(None, entry.text_size)67 self.assertEqual(None, entry.text_size)
6968
70
71class TestInventory(per_tree.TestCaseWithTree):
72
73 def test_paths2ids_recursive(self):
74 work_tree = self.make_branch_and_tree('tree')
75 self.build_tree(['tree/dir/', 'tree/dir/file'])
76 work_tree.add(['dir', 'dir/file'])
77 tree = self._convert_tree(work_tree)
78 if not isinstance(tree, InventoryTree):
79 raise tests.TestNotApplicable(
80 "test not applicable on non-inventory tests")
81 tree.lock_read()
82 self.addCleanup(tree.unlock)
83 self.assertEqual({tree.path2id('dir'), tree.path2id('dir/file')},
84 tree.paths2ids(['dir']))
85
86 def test_paths2ids_forget_old(self):
87 work_tree = self.make_branch_and_tree('tree')
88 self.build_tree(['tree/file'])
89 work_tree.add('file')
90 work_tree.commit('commit old state')
91 work_tree.remove('file')
92 tree = self._convert_tree(work_tree)
93 if not isinstance(tree, InventoryTree):
94 raise tests.TestNotApplicable(
95 "test not applicable on non-inventory tests")
96 tree.lock_read()
97 self.addCleanup(tree.unlock)
98 self.assertEqual(set([]), tree.paths2ids(['file'],
99 require_versioned=False))

Subscribers

People subscribed via source and target branches