~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/export/dir_exporter.py

Merge bzr.dev 4187, and revert the change to fix refcycle issues.

I apparently didn't run the smart fetch tests. Which show that we access inv+chk pages
as a fulltext, and then insert the stream, which expects to get the block as a compressed
block. :(.
Need to rethink how to do it, possibly with weakrefs.


This also brings in CommitBuilder.record_iter_changes() and the updates to btree_index
and backing indices.

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
 
20
20
 
21
21
import os
 
22
import StringIO
22
23
 
23
24
from bzrlib import errors, osutils
24
25
from bzrlib.export import _export_iter_entries
 
26
from bzrlib.filters import (
 
27
    ContentFilterContext,
 
28
    filtered_output_bytes,
 
29
    )
25
30
from bzrlib.trace import mutter
26
31
 
27
32
 
28
 
def dir_exporter(tree, dest, root, subdir):
 
33
def dir_exporter(tree, dest, root, subdir, filtered=False):
29
34
    """Export this tree to a new directory.
30
35
 
31
36
    `dest` should not exist, and will be created holding the
42
47
    for dp, ie in _export_iter_entries(tree, subdir):
43
48
        fullpath = osutils.pathjoin(dest, dp)
44
49
        if ie.kind == "file":
45
 
            fileobj = tree.get_file(ie.file_id)
 
50
            if filtered:
 
51
                chunks = tree.get_file_lines(ie.file_id)
 
52
                filters = tree._content_filter_stack(dp)
 
53
                context = ContentFilterContext(dp, tree, ie)
 
54
                contents = filtered_output_bytes(chunks, filters, context)
 
55
                content = ''.join(contents)
 
56
                fileobj = StringIO.StringIO(content)
 
57
            else:
 
58
                fileobj = tree.get_file(ie.file_id)
46
59
            osutils.pumpfile(fileobj, file(fullpath, 'wb'))
47
60
            if tree.is_executable(ie.file_id):
48
61
                os.chmod(fullpath, 0755)