65
68
def clone_git_repo(self, from_url, to_url, revision_id=None):
66
69
oldrepos = self.open_git_repo(from_url)
67
dir = BzrDir.create(to_url)
70
dir = BzrDir.create(to_url, get_rich_root_format())
68
71
newrepos = dir.create_repository()
69
72
oldrepos.copy_content_into(newrepos, revision_id=revision_id)
281
284
ret = import_git_blob(self._texts, self._mapping, "bla", "bla",
282
285
(None, "blobname"),
283
286
base_inv, None, "somerevid", [], objs.__getitem__,
284
(None, DEFAULT_FILE_MODE), DummyStoreUpdater(),
285
self._mapping.generate_file_id)
287
(None, DEFAULT_FILE_MODE), DummyStoreUpdater())
286
288
self.assertEquals(set([('bla', 'somerevid')]), self._texts.keys())
287
289
self.assertEquals(self._texts.get_record_stream([('bla', 'somerevid')],
288
290
"unordered", True).next().get_bytes_as("fulltext"), "bar")
298
300
def test_import_tree_empty_root(self):
299
301
base_inv = Inventory(root_id=None)
301
ret, child_modes = import_git_tree(self._texts, self._mapping, "", "",
303
ret, _ = import_git_tree(self._texts, self._mapping, "", "",
302
304
(None, tree.id), base_inv,
303
305
None, "somerevid", [], {tree.id: tree}.__getitem__,
304
(None, stat.S_IFDIR), DummyStoreUpdater(),
305
self._mapping.generate_file_id)
306
self.assertEquals(child_modes, {})
306
(None, stat.S_IFDIR), DummyStoreUpdater())
307
307
self.assertEquals(set([("TREE_ROOT", 'somerevid')]), self._texts.keys())
308
308
self.assertEquals(1, len(ret))
309
309
self.assertEquals(None, ret[0][0])
318
318
def test_import_tree_empty(self):
319
319
base_inv = Inventory()
321
ret, child_modes = import_git_tree(self._texts, self._mapping, "bla", "bla",
321
ret, _ = import_git_tree(self._texts, self._mapping, "bla", "bla",
322
322
(None, tree.id), base_inv, None, "somerevid", [],
323
323
{ tree.id: tree }.__getitem__,
324
(None, stat.S_IFDIR), DummyStoreUpdater(),
325
self._mapping.generate_file_id)
326
self.assertEquals(child_modes, {})
324
(None, stat.S_IFDIR), DummyStoreUpdater())
327
325
self.assertEquals(set([("bla", 'somerevid')]), self._texts.keys())
328
326
self.assertEquals(1, len(ret))
329
327
self.assertEquals(None, ret[0][0])
339
337
base_inv = Inventory()
340
338
blob = Blob.from_string("bar1")
342
tree.add(stat.S_IFREG | 0644, "foo", blob.id)
340
tree.add(0100600, "foo", blob.id)
343
341
objects = { blob.id: blob, tree.id: tree }
344
ret, child_modes = import_git_tree(self._texts, self._mapping, "bla", "bla",
342
ret, _ = import_git_tree(self._texts, self._mapping, "bla", "bla",
345
343
(None, tree.id), base_inv, None, "somerevid", [],
346
objects.__getitem__, (None, stat.S_IFDIR), DummyStoreUpdater(),
347
self._mapping.generate_file_id)
348
self.assertEquals(child_modes, {})
344
objects.__getitem__, (None, stat.S_IFDIR), DummyStoreUpdater())
349
345
self.assertEquals(2, len(ret))
350
346
self.assertEquals(None, ret[0][0])
351
347
self.assertEquals("bla", ret[0][1])
360
356
self.assertEquals(osutils.sha_strings(["bar1"]), ie.text_sha1)
361
357
self.assertEquals(False, ie.executable)
363
def test_import_tree_with_unusual_mode_file(self):
364
base_inv = Inventory()
365
blob = Blob.from_string("bar1")
367
tree.add(stat.S_IFREG | 0664, "foo", blob.id)
368
objects = { blob.id: blob, tree.id: tree }
369
ret, child_modes = import_git_tree(self._texts, self._mapping, "bla", "bla",
370
(None, tree.id), base_inv, None, "somerevid", [],
371
objects.__getitem__, (None, stat.S_IFDIR), DummyStoreUpdater(),
372
self._mapping.generate_file_id)
373
self.assertEquals(child_modes, { "bla/foo": stat.S_IFREG | 0664 })
375
359
def test_import_tree_with_file_exe(self):
376
360
base_inv = Inventory(root_id=None)
377
361
blob = Blob.from_string("bar")
379
363
tree.add(0100755, "foo", blob.id)
380
364
objects = { blob.id: blob, tree.id: tree }
381
ret, child_modes = import_git_tree(self._texts, self._mapping, "", "",
365
ret, _ = import_git_tree(self._texts, self._mapping, "", "",
382
366
(None, tree.id), base_inv, None, "somerevid", [],
383
objects.__getitem__, (None, stat.S_IFDIR), DummyStoreUpdater(),
384
self._mapping.generate_file_id)
385
self.assertEquals(child_modes, {})
367
objects.__getitem__, (None, stat.S_IFDIR), DummyStoreUpdater())
386
368
self.assertEquals(2, len(ret))
387
369
self.assertEquals(None, ret[0][0])
388
370
self.assertEquals("", ret[0][1])