/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to breezy/archive/zip.py

  • Committer: Jelmer Vernooij
  • Date: 2018-11-16 23:19:12 UTC
  • mfrom: (7180 work)
  • mto: This revision was merged to the branch mainline in revision 7294.
  • Revision ID: jelmer@jelmer.uk-20181116231912-e043vpq22bdkxa6q
Merge trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
45
45
 
46
46
 
47
47
def zip_archive_generator(tree, dest, root, subdir=None,
48
 
    force_mtime=None):
 
48
                          force_mtime=None):
49
49
    """ Export this tree to a new zip file.
50
50
 
51
51
    `dest` will be created holding the contents of this tree; if it
54
54
    compression = zipfile.ZIP_DEFLATED
55
55
    with tempfile.SpooledTemporaryFile() as buf:
56
56
        with closing(zipfile.ZipFile(buf, "w", compression)) as zipf, \
57
 
             tree.lock_read():
 
57
                tree.lock_read():
58
58
            for dp, tp, ie in _export_iter_entries(tree, subdir):
59
59
                mutter("  export {%s} kind %s to %s", tp, ie.kind, dest)
60
60
 
68
68
                filename = osutils.pathjoin(root, dp)
69
69
                if ie.kind == "file":
70
70
                    zinfo = zipfile.ZipInfo(
71
 
                                filename=filename,
72
 
                                date_time=date_time)
 
71
                        filename=filename,
 
72
                        date_time=date_time)
73
73
                    zinfo.compress_type = compression
74
74
                    zinfo.external_attr = _FILE_ATTR
75
75
                    content = tree.get_file_text(tp)
79
79
                    # to the zip routine that they are really directories and
80
80
                    # not just empty files.
81
81
                    zinfo = zipfile.ZipInfo(
82
 
                                filename=filename + '/',
83
 
                                date_time=date_time)
 
82
                        filename=filename + '/',
 
83
                        date_time=date_time)
84
84
                    zinfo.compress_type = compression
85
85
                    zinfo.external_attr = _DIR_ATTR
86
86
                    zipf.writestr(zinfo, '')
87
87
                elif ie.kind == "symlink":
88
88
                    zinfo = zipfile.ZipInfo(
89
 
                                filename=(filename + '.lnk'),
90
 
                                date_time=date_time)
 
89
                        filename=(filename + '.lnk'),
 
90
                        date_time=date_time)
91
91
                    zinfo.compress_type = compression
92
92
                    zinfo.external_attr = _FILE_ATTR
93
93
                    zipf.writestr(zinfo, tree.get_symlink_target(tp))