~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/export/zip_exporter.py

  • Committer: Jelmer Vernooij
  • Date: 2012-02-20 12:19:29 UTC
  • mfrom: (6437.23.11 2.5)
  • mto: (6581.1.1 trunk)
  • mto: This revision was merged to the branch mainline in revision 6582.
  • Revision ID: jelmer@samba.org-20120220121929-7ni2psvjoatm1yp4
Merge bzr/2.5.

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
"""Export a Tree to a zip file.
18
18
"""
19
19
 
 
20
from __future__ import absolute_import
 
21
 
20
22
import os
21
23
import stat
22
24
import sys
55
57
        dest = sys.stdout
56
58
    zipf = zipfile.ZipFile(dest, "w", compression)
57
59
    try:
58
 
        for dp, ie in _export_iter_entries(tree, subdir):
 
60
        for dp, tp, ie in _export_iter_entries(tree, subdir):
59
61
            file_id = ie.file_id
60
62
            mutter("  export {%s} kind %s to %s", file_id, ie.kind, dest)
61
63
 
64
66
            if force_mtime is not None:
65
67
                mtime = force_mtime
66
68
            else:
67
 
                mtime = tree.get_file_mtime(ie.file_id, dp)
 
69
                mtime = tree.get_file_mtime(ie.file_id, tp)
68
70
            date_time = time.localtime(mtime)[:6]
69
71
            filename = osutils.pathjoin(root, dp).encode('utf8')
70
72
            if ie.kind == "file":
73
75
                            date_time=date_time)
74
76
                zinfo.compress_type = compression
75
77
                zinfo.external_attr = _FILE_ATTR
76
 
                content = tree.get_file_text(file_id)
 
78
                content = tree.get_file_text(file_id, tp)
77
79
                zipf.writestr(zinfo, content)
78
80
            elif ie.kind == "directory":
79
81
                # Directories must contain a trailing slash, to indicate
91
93
                            date_time=date_time)
92
94
                zinfo.compress_type = compression
93
95
                zinfo.external_attr = _FILE_ATTR
94
 
                zipf.writestr(zinfo, tree.get_symlink_target(file_id))
 
96
                zipf.writestr(zinfo, tree.get_symlink_target(file_id, tp))
95
97
            yield
96
98
 
97
99
        zipf.close()