~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/export/zip_exporter.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2011-07-21 07:51:22 UTC
  • mfrom: (6034.1.1 filter-tree)
  • Revision ID: pqm@pqm.ubuntu.com-20110721075122-l9d0n4d3pk4p3hfg
(mbp) add ContentFilterTree decorator and use it for cat and export (Martin
 Pool)

Show diffs side-by-side

added added

removed removed

Lines of Context:
27
27
    osutils,
28
28
    )
29
29
from bzrlib.export import _export_iter_entries
30
 
from bzrlib.filters import (
31
 
    ContentFilterContext,
32
 
    filtered_output_bytes,
33
 
    )
34
30
from bzrlib.trace import mutter
35
31
 
36
32
 
44
40
_DIR_ATTR = stat.S_IFDIR | ZIP_DIRECTORY_BIT | DIR_PERMISSIONS
45
41
 
46
42
 
47
 
def zip_exporter_generator(tree, dest, root, subdir=None, filtered=False,
 
43
def zip_exporter_generator(tree, dest, root, subdir=None,
48
44
    force_mtime=None, fileobj=None):
49
45
    """ Export this tree to a new zip file.
50
46
 
77
73
                            date_time=date_time)
78
74
                zinfo.compress_type = compression
79
75
                zinfo.external_attr = _FILE_ATTR
80
 
                if filtered:
81
 
                    chunks = tree.get_file_lines(file_id)
82
 
                    filters = tree._content_filter_stack(dp)
83
 
                    context = ContentFilterContext(dp, tree, ie)
84
 
                    contents = filtered_output_bytes(chunks, filters, context)
85
 
                    content = ''.join(contents)
86
 
                else:
87
 
                    content = tree.get_file_text(file_id)
 
76
                content = tree.get_file_text(file_id)
88
77
                zipf.writestr(zinfo, content)
89
78
            elif ie.kind == "directory":
90
79
                # Directories must contain a trailing slash, to indicate