~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/export/tar_exporter.py

  • Committer: Martin Pool
  • Date: 2011-07-04 21:10:37 UTC
  • mto: (6034.1.1 filter-tree)
  • mto: This revision was merged to the branch mainline in revision 6035.
  • Revision ID: mbp@canonical.com-20110704211037-ro3417imj3oqnqxp
Support exporting tarballs from ContentFilterTree

Show diffs side-by-side

added added

removed removed

Lines of Context:
14
14
# along with this program; if not, write to the Free Software
15
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
16
 
17
 
"""Export a Tree to a non-versioned directory."""
 
17
"""Export a tree to a tarball."""
18
18
 
19
19
import os
20
20
import StringIO
62
62
        else:
63
63
            item.mode = 0644
64
64
        if filtered:
65
 
            chunks = tree.get_file_lines(entry.file_id)
66
 
            filters = tree._content_filter_stack(final_path)
67
 
            context = ContentFilterContext(final_path, tree, entry)
68
 
            contents = filtered_output_bytes(chunks, filters, context)
69
 
            content = ''.join(contents)
70
 
            item.size = len(content)
71
 
            fileobj = StringIO.StringIO(content)
72
 
        else:
73
 
            item.size = tree.get_file_size(entry.file_id)
74
 
            fileobj = tree.get_file(entry.file_id)
 
65
            raise AssertionError("exporters should now be given a "
 
66
                "ContentFilterTree instead of filtered=True")
 
67
        # This brings the whole file into memory, but that's almost needed for
 
68
        # the tarfile contract, which wants the size of the file up front.  We
 
69
        # want to make sure it doesn't change, and we need to read it in one
 
70
        # go for content filtering.
 
71
        content = tree.get_file_text(entry.file_id)
 
72
        item.size = len(content)
 
73
        fileobj = StringIO.StringIO(content)
75
74
    elif entry.kind == "directory":
76
75
        item.type = tarfile.DIRTYPE
77
76
        item.name += '/'