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