bzr branch
http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
0.358.2
by Jelmer Vernooij
Refresh copyright headers, add my email. |
1 |
# Copyright (C) 2010-2018 Jelmer Vernooij <jelmer@jelmer.uk>
|
0.200.799
by Jelmer Vernooij
Add trivial object store tests. |
2 |
#
|
3 |
# This program is free software; you can redistribute it and/or modify
|
|
4 |
# it under the terms of the GNU General Public License as published by
|
|
5 |
# the Free Software Foundation; either version 2 of the License, or
|
|
6 |
# (at your option) any later version.
|
|
7 |
#
|
|
8 |
# This program is distributed in the hope that it will be useful,
|
|
9 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
10 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
11 |
# GNU General Public License for more details.
|
|
12 |
#
|
|
13 |
# You should have received a copy of the GNU General Public License
|
|
14 |
# along with this program; if not, write to the Free Software
|
|
0.358.1
by Jelmer Vernooij
Fix FSF address. |
15 |
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
0.200.799
by Jelmer Vernooij
Add trivial object store tests. |
16 |
|
17 |
"""Tests for bzr-git's object store."""
|
|
18 |
||
7290.4.1
by Jelmer Vernooij
Fix pushing of revisions from bzr to git that convert directories to symlinks. |
19 |
import os |
20 |
import shutil |
|
7290.1.18
by Jelmer Vernooij
Fix a nasty corner case when the base tree contains symlinks. |
21 |
import stat |
7290.4.1
by Jelmer Vernooij
Fix pushing of revisions from bzr to git that convert directories to symlinks. |
22 |
|
0.200.799
by Jelmer Vernooij
Add trivial object store tests. |
23 |
from dulwich.objects import ( |
24 |
Blob, |
|
0.421.3
by Jelmer Vernooij
Move directory_to_tree to object_store. |
25 |
Tree, |
0.200.799
by Jelmer Vernooij
Add trivial object store tests. |
26 |
)
|
27 |
||
6986.2.1
by Jelmer Vernooij
Move breezy.plugins.git to breezy.git. |
28 |
from ...branchbuilder import ( |
0.200.963
by Jelmer Vernooij
Add some tests for LRUTreeCache. |
29 |
BranchBuilder, |
30 |
)
|
|
6986.2.1
by Jelmer Vernooij
Move breezy.plugins.git to breezy.git. |
31 |
from ...bzr.inventory import ( |
0.421.3
by Jelmer Vernooij
Move directory_to_tree to object_store. |
32 |
InventoryDirectory, |
33 |
InventoryFile, |
|
34 |
)
|
|
6986.2.1
by Jelmer Vernooij
Move breezy.plugins.git to breezy.git. |
35 |
from ...errors import ( |
0.200.963
by Jelmer Vernooij
Add some tests for LRUTreeCache. |
36 |
NoSuchRevision, |
37 |
)
|
|
6986.2.1
by Jelmer Vernooij
Move breezy.plugins.git to breezy.git. |
38 |
from ...graph import ( |
0.200.899
by Jelmer Vernooij
Add tests for find_missing_bzr_revids. |
39 |
DictParentsProvider, |
0.200.1059
by Jelmer Vernooij
Fix graph tests. |
40 |
Graph, |
0.200.899
by Jelmer Vernooij
Add tests for find_missing_bzr_revids. |
41 |
)
|
6986.2.1
by Jelmer Vernooij
Move breezy.plugins.git to breezy.git. |
42 |
from ...tests import ( |
0.200.799
by Jelmer Vernooij
Add trivial object store tests. |
43 |
TestCase, |
0.200.963
by Jelmer Vernooij
Add some tests for LRUTreeCache. |
44 |
TestCaseWithTransport, |
0.200.799
by Jelmer Vernooij
Add trivial object store tests. |
45 |
)
|
7290.18.6
by Jelmer Vernooij
Fix some more tests. |
46 |
from ...tests.features import SymlinkFeature |
0.200.799
by Jelmer Vernooij
Add trivial object store tests. |
47 |
|
0.200.1642
by Jelmer Vernooij
Use relative imports in tests. |
48 |
from ..cache import ( |
0.200.1016
by Jelmer Vernooij
add basic test for tree_to_objects. |
49 |
DictGitShaMap, |
50 |
)
|
|
0.200.1642
by Jelmer Vernooij
Use relative imports in tests. |
51 |
from ..object_store import ( |
0.200.964
by Jelmer Vernooij
Add some tests for object store. |
52 |
BazaarObjectStore, |
0.200.963
by Jelmer Vernooij
Add some tests for LRUTreeCache. |
53 |
LRUTreeCache, |
0.421.3
by Jelmer Vernooij
Move directory_to_tree to object_store. |
54 |
directory_to_tree, |
0.200.799
by Jelmer Vernooij
Add trivial object store tests. |
55 |
_check_expected_sha, |
0.200.899
by Jelmer Vernooij
Add tests for find_missing_bzr_revids. |
56 |
_find_missing_bzr_revids, |
0.200.1016
by Jelmer Vernooij
add basic test for tree_to_objects. |
57 |
_tree_to_objects, |
0.200.799
by Jelmer Vernooij
Add trivial object store tests. |
58 |
)
|
59 |
||
60 |
||
61 |
class ExpectedShaTests(TestCase): |
|
62 |
||
63 |
def setUp(self): |
|
64 |
super(ExpectedShaTests, self).setUp() |
|
65 |
self.obj = Blob() |
|
7018.3.8
by Jelmer Vernooij
Disable some flaky tests on python3, allow running without fastimport. |
66 |
self.obj.data = b"foo" |
0.200.799
by Jelmer Vernooij
Add trivial object store tests. |
67 |
|
68 |
def test_none(self): |
|
69 |
_check_expected_sha(None, self.obj) |
|
70 |
||
71 |
def test_hex(self): |
|
7027.2.1
by Jelmer Vernooij
Port fastimport to python3. |
72 |
_check_expected_sha( |
7143.15.2
by Jelmer Vernooij
Run autopep8. |
73 |
self.obj.sha().hexdigest().encode('ascii'), self.obj) |
0.424.1
by Jelmer Vernooij
Fix error message about .git directory. |
74 |
self.assertRaises(AssertionError, _check_expected_sha, |
7143.15.2
by Jelmer Vernooij
Run autopep8. |
75 |
b"0" * 40, self.obj) |
0.200.799
by Jelmer Vernooij
Add trivial object store tests. |
76 |
|
77 |
def test_binary(self): |
|
78 |
_check_expected_sha(self.obj.sha().digest(), self.obj) |
|
0.424.1
by Jelmer Vernooij
Fix error message about .git directory. |
79 |
self.assertRaises(AssertionError, _check_expected_sha, |
7143.15.2
by Jelmer Vernooij
Run autopep8. |
80 |
b"x" * 20, self.obj) |
0.200.899
by Jelmer Vernooij
Add tests for find_missing_bzr_revids. |
81 |
|
82 |
||
83 |
class FindMissingBzrRevidsTests(TestCase): |
|
84 |
||
85 |
def _find_missing(self, ancestry, want, have): |
|
86 |
return _find_missing_bzr_revids( |
|
0.200.1059
by Jelmer Vernooij
Fix graph tests. |
87 |
Graph(DictParentsProvider(ancestry)), |
0.200.899
by Jelmer Vernooij
Add tests for find_missing_bzr_revids. |
88 |
set(want), set(have)) |
89 |
||
90 |
def test_simple(self): |
|
6964.2.3
by Jelmer Vernooij
Review comments. |
91 |
self.assertEqual(set(), self._find_missing({}, [], [])) |
0.200.899
by Jelmer Vernooij
Add tests for find_missing_bzr_revids. |
92 |
|
93 |
def test_up_to_date(self): |
|
6964.2.3
by Jelmer Vernooij
Review comments. |
94 |
self.assertEqual(set(), |
7143.15.2
by Jelmer Vernooij
Run autopep8. |
95 |
self._find_missing({"a": ["b"]}, ["a"], ["a"])) |
0.200.899
by Jelmer Vernooij
Add tests for find_missing_bzr_revids. |
96 |
|
97 |
def test_one_missing(self): |
|
6964.2.3
by Jelmer Vernooij
Review comments. |
98 |
self.assertEqual(set(["a"]), |
7143.15.2
by Jelmer Vernooij
Run autopep8. |
99 |
self._find_missing({"a": ["b"]}, ["a"], ["b"])) |
0.200.905
by Jelmer Vernooij
More find missing revision tests. |
100 |
|
101 |
def test_two_missing(self): |
|
6964.2.3
by Jelmer Vernooij
Review comments. |
102 |
self.assertEqual(set(["a", "b"]), |
7143.15.2
by Jelmer Vernooij
Run autopep8. |
103 |
self._find_missing({"a": ["b"], "b": ["c"]}, ["a"], ["c"])) |
0.200.905
by Jelmer Vernooij
More find missing revision tests. |
104 |
|
105 |
def test_two_missing_history(self): |
|
6964.2.3
by Jelmer Vernooij
Review comments. |
106 |
self.assertEqual(set(["a", "b"]), |
7143.15.2
by Jelmer Vernooij
Run autopep8. |
107 |
self._find_missing({"a": ["b"], "b": ["c"], "c": ["d"]}, |
108 |
["a"], ["c"])) |
|
0.200.963
by Jelmer Vernooij
Add some tests for LRUTreeCache. |
109 |
|
110 |
||
111 |
class LRUTreeCacheTests(TestCaseWithTransport): |
|
112 |
||
113 |
def setUp(self): |
|
114 |
super(LRUTreeCacheTests, self).setUp() |
|
115 |
self.branch = self.make_branch(".") |
|
116 |
self.branch.lock_write() |
|
117 |
self.addCleanup(self.branch.unlock) |
|
118 |
self.cache = LRUTreeCache(self.branch.repository) |
|
119 |
||
120 |
def test_get_not_present(self): |
|
0.200.965
by Jelmer Vernooij
Formatting fixes. |
121 |
self.assertRaises(NoSuchRevision, self.cache.revision_tree, |
7143.15.2
by Jelmer Vernooij
Run autopep8. |
122 |
"unknown") |
0.200.963
by Jelmer Vernooij
Add some tests for LRUTreeCache. |
123 |
|
124 |
def test_revision_trees(self): |
|
0.200.965
by Jelmer Vernooij
Formatting fixes. |
125 |
self.assertRaises(NoSuchRevision, self.cache.revision_trees, |
7143.15.2
by Jelmer Vernooij
Run autopep8. |
126 |
["unknown", "la"]) |
0.200.963
by Jelmer Vernooij
Add some tests for LRUTreeCache. |
127 |
|
128 |
def test_iter_revision_trees(self): |
|
0.200.965
by Jelmer Vernooij
Formatting fixes. |
129 |
self.assertRaises(NoSuchRevision, self.cache.iter_revision_trees, |
7143.15.2
by Jelmer Vernooij
Run autopep8. |
130 |
["unknown", "la"]) |
0.200.963
by Jelmer Vernooij
Add some tests for LRUTreeCache. |
131 |
|
132 |
def test_get(self): |
|
133 |
bb = BranchBuilder(branch=self.branch) |
|
134 |
bb.start_series() |
|
0.285.8
by Jelmer Vernooij
Fix more tests for swapped arguments. |
135 |
revid = bb.build_snapshot(None, |
7143.15.2
by Jelmer Vernooij
Run autopep8. |
136 |
[('add', ('', None, 'directory', None)), |
137 |
('add', ('foo', b'foo-id', |
|
138 |
'file', b'a\nb\nc\nd\ne\n')), |
|
139 |
])
|
|
0.200.963
by Jelmer Vernooij
Add some tests for LRUTreeCache. |
140 |
bb.finish_series() |
0.285.8
by Jelmer Vernooij
Fix more tests for swapped arguments. |
141 |
tree = self.cache.revision_tree(revid) |
6964.2.3
by Jelmer Vernooij
Review comments. |
142 |
self.assertEqual(revid, tree.get_revision_id()) |
0.200.964
by Jelmer Vernooij
Add some tests for object store. |
143 |
|
144 |
||
145 |
class BazaarObjectStoreTests(TestCaseWithTransport): |
|
146 |
||
147 |
def setUp(self): |
|
148 |
super(BazaarObjectStoreTests, self).setUp() |
|
149 |
self.branch = self.make_branch(".") |
|
150 |
self.store = BazaarObjectStore(self.branch.repository) |
|
151 |
||
152 |
def test_get_blob(self): |
|
7290.4.1
by Jelmer Vernooij
Fix pushing of revisions from bzr to git that convert directories to symlinks. |
153 |
self.branch.lock_write() |
154 |
self.addCleanup(self.branch.unlock) |
|
0.200.964
by Jelmer Vernooij
Add some tests for object store. |
155 |
b = Blob() |
6973.5.10
by Jelmer Vernooij
Random bunch of python3 bee-improvements. |
156 |
b.data = b'a\nb\nc\nd\ne\n' |
0.200.1212
by Jelmer Vernooij
Support read locking object stores. |
157 |
self.store.lock_read() |
158 |
self.addCleanup(self.store.unlock) |
|
0.200.964
by Jelmer Vernooij
Add some tests for object store. |
159 |
self.assertRaises(KeyError, self.store.__getitem__, b.id) |
160 |
bb = BranchBuilder(branch=self.branch) |
|
161 |
bb.start_series() |
|
0.285.8
by Jelmer Vernooij
Fix more tests for swapped arguments. |
162 |
bb.build_snapshot(None, |
7143.15.2
by Jelmer Vernooij
Run autopep8. |
163 |
[('add', ('', None, 'directory', None)), |
164 |
('add', ('foo', b'foo-id', 'file', b'a\nb\nc\nd\ne\n')), |
|
165 |
])
|
|
0.200.964
by Jelmer Vernooij
Add some tests for object store. |
166 |
bb.finish_series() |
0.200.1212
by Jelmer Vernooij
Support read locking object stores. |
167 |
# read locks cache
|
168 |
self.assertRaises(KeyError, self.store.__getitem__, b.id) |
|
169 |
self.store.unlock() |
|
170 |
self.store.lock_read() |
|
6964.2.3
by Jelmer Vernooij
Review comments. |
171 |
self.assertEqual(b, self.store[b.id]) |
0.200.964
by Jelmer Vernooij
Add some tests for object store. |
172 |
|
7290.4.1
by Jelmer Vernooij
Fix pushing of revisions from bzr to git that convert directories to symlinks. |
173 |
def test_directory_converted_to_symlink(self): |
7290.18.6
by Jelmer Vernooij
Fix some more tests. |
174 |
self.requireFeature(SymlinkFeature) |
7290.4.1
by Jelmer Vernooij
Fix pushing of revisions from bzr to git that convert directories to symlinks. |
175 |
b = Blob() |
176 |
b.data = b'trgt' |
|
177 |
self.store.lock_read() |
|
178 |
self.addCleanup(self.store.unlock) |
|
179 |
self.assertRaises(KeyError, self.store.__getitem__, b.id) |
|
180 |
tree = self.branch.controldir.create_workingtree() |
|
181 |
self.build_tree_contents([ |
|
182 |
('foo/', ), |
|
183 |
('foo/bar', b'a\nb\nc\nd\ne\n')]) |
|
184 |
tree.add(['foo', 'foo/bar']) |
|
185 |
revid1 = tree.commit('commit 1') |
|
186 |
shutil.rmtree('foo') |
|
187 |
os.symlink('trgt', 'foo') |
|
188 |
revid2 = tree.commit('commit 2') |
|
189 |
# read locks cache
|
|
190 |
self.assertRaises(KeyError, self.store.__getitem__, b.id) |
|
191 |
self.store.unlock() |
|
192 |
self.store.lock_read() |
|
193 |
self.assertEqual(b, self.store[b.id]) |
|
194 |
||
0.200.964
by Jelmer Vernooij
Add some tests for object store. |
195 |
def test_get_raw(self): |
7290.4.1
by Jelmer Vernooij
Fix pushing of revisions from bzr to git that convert directories to symlinks. |
196 |
self.branch.lock_write() |
197 |
self.addCleanup(self.branch.unlock) |
|
0.200.964
by Jelmer Vernooij
Add some tests for object store. |
198 |
b = Blob() |
6973.5.10
by Jelmer Vernooij
Random bunch of python3 bee-improvements. |
199 |
b.data = b'a\nb\nc\nd\ne\n' |
0.200.1212
by Jelmer Vernooij
Support read locking object stores. |
200 |
self.store.lock_read() |
201 |
self.addCleanup(self.store.unlock) |
|
0.200.964
by Jelmer Vernooij
Add some tests for object store. |
202 |
self.assertRaises(KeyError, self.store.get_raw, b.id) |
203 |
bb = BranchBuilder(branch=self.branch) |
|
204 |
bb.start_series() |
|
0.285.8
by Jelmer Vernooij
Fix more tests for swapped arguments. |
205 |
bb.build_snapshot(None, |
7143.15.2
by Jelmer Vernooij
Run autopep8. |
206 |
[('add', ('', None, 'directory', None)), |
207 |
('add', ('foo', b'foo-id', 'file', b'a\nb\nc\nd\ne\n')), |
|
208 |
])
|
|
0.200.964
by Jelmer Vernooij
Add some tests for object store. |
209 |
bb.finish_series() |
0.200.1212
by Jelmer Vernooij
Support read locking object stores. |
210 |
# read locks cache
|
211 |
self.assertRaises(KeyError, self.store.get_raw, b.id) |
|
212 |
self.store.unlock() |
|
213 |
self.store.lock_read() |
|
6964.2.3
by Jelmer Vernooij
Review comments. |
214 |
self.assertEqual(b.as_raw_string(), self.store.get_raw(b.id)[1]) |
0.200.964
by Jelmer Vernooij
Add some tests for object store. |
215 |
|
216 |
def test_contains(self): |
|
7290.4.1
by Jelmer Vernooij
Fix pushing of revisions from bzr to git that convert directories to symlinks. |
217 |
self.branch.lock_write() |
218 |
self.addCleanup(self.branch.unlock) |
|
0.200.964
by Jelmer Vernooij
Add some tests for object store. |
219 |
b = Blob() |
6964.2.1
by Jelmer Vernooij
Initial work to support brz-git on python3. |
220 |
b.data = b'a\nb\nc\nd\ne\n' |
0.200.1212
by Jelmer Vernooij
Support read locking object stores. |
221 |
self.store.lock_read() |
222 |
self.addCleanup(self.store.unlock) |
|
0.200.964
by Jelmer Vernooij
Add some tests for object store. |
223 |
self.assertFalse(b.id in self.store) |
224 |
bb = BranchBuilder(branch=self.branch) |
|
225 |
bb.start_series() |
|
0.285.8
by Jelmer Vernooij
Fix more tests for swapped arguments. |
226 |
bb.build_snapshot(None, |
7143.15.2
by Jelmer Vernooij
Run autopep8. |
227 |
[('add', ('', None, 'directory', None)), |
228 |
('add', ('foo', b'foo-id', 'file', b'a\nb\nc\nd\ne\n')), |
|
229 |
])
|
|
0.200.964
by Jelmer Vernooij
Add some tests for object store. |
230 |
bb.finish_series() |
0.200.1212
by Jelmer Vernooij
Support read locking object stores. |
231 |
# read locks cache
|
232 |
self.assertFalse(b.id in self.store) |
|
233 |
self.store.unlock() |
|
234 |
self.store.lock_read() |
|
0.200.964
by Jelmer Vernooij
Add some tests for object store. |
235 |
self.assertTrue(b.id in self.store) |
236 |
||
0.200.1016
by Jelmer Vernooij
add basic test for tree_to_objects. |
237 |
|
238 |
class TreeToObjectsTests(TestCaseWithTransport): |
|
239 |
||
240 |
def setUp(self): |
|
241 |
super(TreeToObjectsTests, self).setUp() |
|
242 |
self.idmap = DictGitShaMap() |
|
243 |
||
244 |
def test_no_changes(self): |
|
245 |
tree = self.make_branch_and_tree('.') |
|
0.275.5
by Jelmer Vernooij
Cope with root_inventory and inventory. |
246 |
self.addCleanup(tree.lock_read().unlock) |
0.200.1016
by Jelmer Vernooij
add basic test for tree_to_objects. |
247 |
entries = list(_tree_to_objects(tree, [tree], self.idmap, {})) |
6964.2.3
by Jelmer Vernooij
Review comments. |
248 |
self.assertEqual([], entries) |
0.421.2
by Jelmer Vernooij
Move directory_to_tree. |
249 |
|
0.424.1
by Jelmer Vernooij
Fix error message about .git directory. |
250 |
def test_with_gitdir(self): |
251 |
tree = self.make_branch_and_tree('.') |
|
252 |
self.build_tree(['.git', 'foo']) |
|
253 |
tree.add(['.git', 'foo']) |
|
254 |
revid = tree.commit('commit') |
|
255 |
revtree = tree.branch.repository.revision_tree(revid) |
|
256 |
self.addCleanup(revtree.lock_read().unlock) |
|
257 |
entries = list(_tree_to_objects(revtree, [], self.idmap, {})) |
|
6964.2.3
by Jelmer Vernooij
Review comments. |
258 |
self.assertEqual(['foo', ''], [p[0] for p in entries]) |
0.424.1
by Jelmer Vernooij
Fix error message about .git directory. |
259 |
|
7290.1.18
by Jelmer Vernooij
Fix a nasty corner case when the base tree contains symlinks. |
260 |
def test_merge(self): |
261 |
basis_tree = self.make_branch_and_tree('base') |
|
262 |
self.build_tree(['base/foo/']) |
|
263 |
basis_tree.add(['foo']) |
|
264 |
basis_rev = basis_tree.commit('foo') |
|
265 |
basis_revtree = basis_tree.branch.repository.revision_tree(basis_rev) |
|
266 |
||
267 |
tree_a = self.make_branch_and_tree('a') |
|
268 |
tree_a.pull(basis_tree.branch) |
|
269 |
||
270 |
self.build_tree(['a/foo/file1']) |
|
271 |
self.build_tree(['a/foo/subdir-a/']) |
|
272 |
os.symlink('.', 'a/foo/subdir-a/symlink') |
|
273 |
tree_a.add(['foo/subdir-a', 'foo/subdir-a/symlink']) |
|
274 |
||
275 |
tree_a.add(['foo/file1']) |
|
276 |
rev_a = tree_a.commit('commit a') |
|
277 |
revtree_a = tree_a.branch.repository.revision_tree(rev_a) |
|
278 |
||
279 |
with revtree_a.lock_read(): |
|
280 |
entries = list(_tree_to_objects(revtree_a, [basis_revtree], |
|
281 |
self.idmap, {})) |
|
282 |
objects = {path: obj for (path, obj, key) in entries} |
|
7290.1.19
by Jelmer Vernooij
Fix test on python3. |
283 |
subdir_a = objects['foo/subdir-a'] |
7290.1.18
by Jelmer Vernooij
Fix a nasty corner case when the base tree contains symlinks. |
284 |
|
285 |
tree_b = self.make_branch_and_tree('b') |
|
286 |
tree_b.pull(basis_tree.branch) |
|
287 |
self.build_tree(['b/foo/subdir/']) |
|
288 |
os.symlink('.', 'b/foo/subdir/symlink') |
|
289 |
tree_b.add(['foo/subdir', 'foo/subdir/symlink']) |
|
290 |
rev_b = tree_b.commit('commit b') |
|
291 |
revtree_b = tree_b.branch.repository.revision_tree(rev_b) |
|
292 |
self.addCleanup(revtree_b.lock_read().unlock) |
|
293 |
||
294 |
with revtree_b.lock_read(): |
|
295 |
list(_tree_to_objects(revtree_b, [basis_revtree], self.idmap, {})) |
|
296 |
||
297 |
with tree_a.lock_write(): |
|
298 |
tree_a.merge_from_branch(tree_b.branch) |
|
299 |
rev_merge = tree_a.commit('merge') |
|
300 |
||
301 |
revtree_merge = tree_a.branch.basis_tree() |
|
302 |
self.addCleanup(revtree_merge.lock_read().unlock) |
|
303 |
||
304 |
entries = list(_tree_to_objects( |
|
305 |
revtree_merge, |
|
306 |
[tree_a.branch.repository.revision_tree(r) |
|
307 |
for r in revtree_merge.get_parent_ids()], |
|
308 |
self.idmap, {})) |
|
309 |
objects = {path: obj for (path, obj, key) in entries} |
|
310 |
self.assertEqual(set(['', 'foo', 'foo/subdir']), set(objects)) |
|
311 |
self.assertEqual( |
|
312 |
(stat.S_IFDIR, subdir_a.id), objects['foo'][b'subdir-a']) |
|
313 |
||
0.421.2
by Jelmer Vernooij
Move directory_to_tree. |
314 |
|
0.421.3
by Jelmer Vernooij
Move directory_to_tree to object_store. |
315 |
class DirectoryToTreeTests(TestCase): |
0.421.2
by Jelmer Vernooij
Move directory_to_tree. |
316 |
|
317 |
def test_empty(self): |
|
0.421.6
by Jelmer Vernooij
Some more simplifications. |
318 |
t = directory_to_tree('', [], None, {}, None, allow_empty=False) |
6964.2.3
by Jelmer Vernooij
Review comments. |
319 |
self.assertEqual(None, t) |
0.421.2
by Jelmer Vernooij
Move directory_to_tree. |
320 |
|
321 |
def test_empty_dir(self): |
|
6973.11.6
by Jelmer Vernooij
Fix more http tests. |
322 |
child_ie = InventoryDirectory(b'bar', 'bar', b'bar') |
0.421.6
by Jelmer Vernooij
Some more simplifications. |
323 |
t = directory_to_tree('', [child_ie], lambda p, x: None, {}, None, |
7143.15.2
by Jelmer Vernooij
Run autopep8. |
324 |
allow_empty=False) |
6964.2.3
by Jelmer Vernooij
Review comments. |
325 |
self.assertEqual(None, t) |
0.421.2
by Jelmer Vernooij
Move directory_to_tree. |
326 |
|
327 |
def test_empty_dir_dummy_files(self): |
|
6973.11.6
by Jelmer Vernooij
Fix more http tests. |
328 |
child_ie = InventoryDirectory(b'bar', 'bar', b'bar') |
0.421.6
by Jelmer Vernooij
Some more simplifications. |
329 |
t = directory_to_tree('', [child_ie], lambda p, x: None, {}, ".mydummy", |
7143.15.2
by Jelmer Vernooij
Run autopep8. |
330 |
allow_empty=False) |
0.421.2
by Jelmer Vernooij
Move directory_to_tree. |
331 |
self.assertTrue(".mydummy" in t) |
332 |
||
333 |
def test_empty_root(self): |
|
6973.11.6
by Jelmer Vernooij
Fix more http tests. |
334 |
child_ie = InventoryDirectory(b'bar', 'bar', b'bar') |
0.421.6
by Jelmer Vernooij
Some more simplifications. |
335 |
t = directory_to_tree('', [child_ie], lambda p, x: None, {}, None, |
7143.15.2
by Jelmer Vernooij
Run autopep8. |
336 |
allow_empty=True) |
6964.2.3
by Jelmer Vernooij
Review comments. |
337 |
self.assertEqual(Tree(), t) |
0.421.2
by Jelmer Vernooij
Move directory_to_tree. |
338 |
|
339 |
def test_with_file(self): |
|
6973.11.6
by Jelmer Vernooij
Fix more http tests. |
340 |
child_ie = InventoryFile(b'bar', 'bar', b'bar') |
6973.13.2
by Jelmer Vernooij
Fix some more tests. |
341 |
b = Blob.from_string(b"bla") |
0.421.6
by Jelmer Vernooij
Some more simplifications. |
342 |
t1 = directory_to_tree('', [child_ie], lambda p, x: b.id, {}, None, |
7143.15.2
by Jelmer Vernooij
Run autopep8. |
343 |
allow_empty=False) |
0.421.2
by Jelmer Vernooij
Move directory_to_tree. |
344 |
t2 = Tree() |
6973.13.2
by Jelmer Vernooij
Fix some more tests. |
345 |
t2.add(b"bar", 0o100644, b.id) |
6964.2.3
by Jelmer Vernooij
Review comments. |
346 |
self.assertEqual(t1, t2) |
0.424.1
by Jelmer Vernooij
Fix error message about .git directory. |
347 |
|
348 |
def test_with_gitdir(self): |
|
6973.11.6
by Jelmer Vernooij
Fix more http tests. |
349 |
child_ie = InventoryFile(b'bar', 'bar', b'bar') |
350 |
git_file_ie = InventoryFile(b'gitid', '.git', b'bar') |
|
6973.13.2
by Jelmer Vernooij
Fix some more tests. |
351 |
b = Blob.from_string(b"bla") |
0.424.1
by Jelmer Vernooij
Fix error message about .git directory. |
352 |
t1 = directory_to_tree('', [child_ie, git_file_ie], |
7143.15.2
by Jelmer Vernooij
Run autopep8. |
353 |
lambda p, x: b.id, {}, None, |
354 |
allow_empty=False) |
|
0.424.1
by Jelmer Vernooij
Fix error message about .git directory. |
355 |
t2 = Tree() |
6973.13.2
by Jelmer Vernooij
Fix some more tests. |
356 |
t2.add(b"bar", 0o100644, b.id) |
6964.2.3
by Jelmer Vernooij
Review comments. |
357 |
self.assertEqual(t1, t2) |