~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/transform.py

Merge bzr.dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
1269
1269
            tt.trans_id_tree_file_id(wt.get_root_id())
1270
1270
        pb = bzrlib.ui.ui_factory.nested_progress_bar()
1271
1271
        try:
 
1272
            deferred_contents = []
1272
1273
            for num, (tree_path, entry) in \
1273
1274
                enumerate(tree.inventory.iter_entries_by_dir()):
1274
 
                pb.update("Building tree", num, len(tree.inventory))
 
1275
                pb.update("Building tree", num - len(deferred_contents),
 
1276
                          len(tree.inventory))
1275
1277
                if entry.parent_id is None:
1276
1278
                    continue
1277
1279
                reparent = False
1300
1302
                        'entry %s parent id %r is not in file_trans_id %r'
1301
1303
                        % (entry, entry.parent_id, file_trans_id))
1302
1304
                parent_id = file_trans_id[entry.parent_id]
1303
 
                file_trans_id[file_id] = new_by_entry(tt, entry, parent_id,
1304
 
                                                      tree)
 
1305
                if entry.kind == 'file':
 
1306
                    # We *almost* replicate new_by_entry, so that we can defer
 
1307
                    # getting the file text, and get them all at once.
 
1308
                    trans_id = tt.create_path(entry.name, parent_id)
 
1309
                    file_trans_id[file_id] = trans_id
 
1310
                    tt.version_file(entry.file_id, trans_id)
 
1311
                    executable = tree.is_executable(entry.file_id, tree_path)
 
1312
                    if executable is not None:
 
1313
                        tt.set_executability(executable, trans_id)
 
1314
                    deferred_contents.append((entry.file_id, trans_id))
 
1315
                else:
 
1316
                    file_trans_id[file_id] = new_by_entry(tt, entry, parent_id,
 
1317
                                                          tree)
1305
1318
                if reparent:
1306
1319
                    new_trans_id = file_trans_id[file_id]
1307
1320
                    old_parent = tt.trans_id_tree_path(tree_path)
1308
1321
                    _reparent_children(tt, old_parent, new_trans_id)
 
1322
            for num, (trans_id, bytes) in enumerate(
 
1323
                tree.iter_files_bytes(deferred_contents)):
 
1324
                tt.create_file(bytes, trans_id)
 
1325
                pb.update('Adding file contents',
 
1326
                          (num + len(tree.inventory) - len(deferred_contents)),
 
1327
                          len(tree.inventory))
1309
1328
        finally:
1310
1329
            pb.finished()
1311
1330
        pp.next_phase()
1563
1582
        skip_root = False
1564
1583
    basis_tree = None
1565
1584
    try:
 
1585
        deferred_files = []
1566
1586
        for id_num, (file_id, path, changed_content, versioned, parent, name,
1567
1587
                kind, executable) in enumerate(change_list):
1568
1588
            if skip_root and file_id[0] is not None and parent[0] is None:
1608
1628
                    tt.create_symlink(target_tree.get_symlink_target(file_id),
1609
1629
                                      trans_id)
1610
1630
                elif kind[1] == 'file':
1611
 
                    tt.create_file(target_tree.get_file_lines(file_id),
1612
 
                                   trans_id, mode_id)
 
1631
                    deferred_files.append((file_id, (trans_id, mode_id)))
1613
1632
                    if basis_tree is None:
1614
1633
                        basis_tree = working_tree.basis_tree()
1615
1634
                        basis_tree.lock_read()
1636
1655
                    name[1], tt.trans_id_file_id(parent[1]), trans_id)
1637
1656
            if executable[0] != executable[1] and kind[1] == "file":
1638
1657
                tt.set_executability(executable[1], trans_id)
 
1658
        for (trans_id, mode_id), bytes in target_tree.iter_files_bytes(
 
1659
            deferred_files):
 
1660
            tt.create_file(bytes, trans_id, mode_id)
1639
1661
    finally:
1640
1662
        if basis_tree is not None:
1641
1663
            basis_tree.unlock()