~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/transform.py

(jameinel) Change ``bzrlib.transform.build_tree`` to pass the sha1 of newly
 created files. This avoids re-hashing content on the next 'bzr st'. Saving
 ~30s on a gcc-sized tree. (John A Meinel)

Show diffs side-by-side

added added

removed removed

Lines of Context:
2541
2541
                    executable = tree.is_executable(file_id, tree_path)
2542
2542
                    if executable:
2543
2543
                        tt.set_executability(executable, trans_id)
2544
 
                    trans_data = (trans_id, tree_path)
 
2544
                    trans_data = (trans_id, tree_path, entry.text_sha1)
2545
2545
                    deferred_contents.append((file_id, trans_data))
2546
2546
                else:
2547
2547
                    file_trans_id[file_id] = new_by_entry(tt, entry, parent_id,
2592
2592
        unchanged = dict(unchanged)
2593
2593
        new_desired_files = []
2594
2594
        count = 0
2595
 
        for file_id, (trans_id, tree_path) in desired_files:
 
2595
        for file_id, (trans_id, tree_path, text_sha1) in desired_files:
2596
2596
            accelerator_path = unchanged.get(file_id)
2597
2597
            if accelerator_path is None:
2598
 
                new_desired_files.append((file_id, (trans_id, tree_path)))
 
2598
                new_desired_files.append((file_id,
 
2599
                    (trans_id, tree_path, text_sha1)))
2599
2600
                continue
2600
2601
            pb.update('Adding file contents', count + offset, total)
2601
2602
            if hardlink:
2608
2609
                    contents = filtered_output_bytes(contents, filters,
2609
2610
                        ContentFilterContext(tree_path, tree))
2610
2611
                try:
2611
 
                    tt.create_file(contents, trans_id)
 
2612
                    tt.create_file(contents, trans_id, sha1=text_sha1)
2612
2613
                finally:
2613
2614
                    try:
2614
2615
                        contents.close()
2617
2618
                        pass
2618
2619
            count += 1
2619
2620
        offset += count
2620
 
    for count, ((trans_id, tree_path), contents) in enumerate(
 
2621
    for count, ((trans_id, tree_path, text_sha1), contents) in enumerate(
2621
2622
            tree.iter_files_bytes(new_desired_files)):
2622
2623
        if wt.supports_content_filtering():
2623
2624
            filters = wt._content_filter_stack(tree_path)
2624
2625
            contents = filtered_output_bytes(contents, filters,
2625
2626
                ContentFilterContext(tree_path, tree))
2626
 
        tt.create_file(contents, trans_id)
 
2627
        tt.create_file(contents, trans_id, sha1=text_sha1)
2627
2628
        pb.update('Adding file contents', count + offset, total)
2628
2629
 
2629
2630