209
215
self.addCleanup(tree.lock_read().unlock)
210
216
entries = list(_tree_to_objects(tree, [tree], self.idmap, {}))
211
217
self.assertEquals([], entries)
219
def test_with_gitdir(self):
220
tree = self.make_branch_and_tree('.')
221
self.build_tree(['.git', 'foo'])
222
tree.add(['.git', 'foo'])
223
revid = tree.commit('commit')
224
revtree = tree.branch.repository.revision_tree(revid)
225
self.addCleanup(revtree.lock_read().unlock)
226
entries = list(_tree_to_objects(revtree, [], self.idmap, {}))
227
self.assertEquals(['foo', ''], [p[0] for p in entries])
230
class DirectoryToTreeTests(TestCase):
232
def test_empty(self):
233
t = directory_to_tree('', [], None, {}, None, allow_empty=False)
234
self.assertEquals(None, t)
236
def test_empty_dir(self):
237
child_ie = InventoryDirectory('bar', 'bar', 'bar')
238
t = directory_to_tree('', [child_ie], lambda p, x: None, {}, None,
240
self.assertEquals(None, t)
242
def test_empty_dir_dummy_files(self):
243
child_ie = InventoryDirectory('bar', 'bar', 'bar')
244
t = directory_to_tree('', [child_ie], lambda p, x: None, {}, ".mydummy",
246
self.assertTrue(".mydummy" in t)
248
def test_empty_root(self):
249
child_ie = InventoryDirectory('bar', 'bar', 'bar')
250
t = directory_to_tree('', [child_ie], lambda p, x: None, {}, None,
252
self.assertEquals(Tree(), t)
254
def test_with_file(self):
255
child_ie = InventoryFile('bar', 'bar', 'bar')
256
b = Blob.from_string("bla")
257
t1 = directory_to_tree('', [child_ie], lambda p, x: b.id, {}, None,
260
t2.add("bar", 0100644, b.id)
261
self.assertEquals(t1, t2)
263
def test_with_gitdir(self):
264
child_ie = InventoryFile('bar', 'bar', 'bar')
265
git_file_ie = InventoryFile('gitid', '.git', 'bar')
266
b = Blob.from_string("bla")
267
t1 = directory_to_tree('', [child_ie, git_file_ie],
268
lambda p, x: b.id, {}, None,
271
t2.add("bar", 0100644, b.id)
272
self.assertEquals(t1, t2)