~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/export/zip_exporter.py

Merge bzr.dev into cleanup

Show diffs side-by-side

added added

removed removed

Lines of Context:
42
42
_DIR_ATTR = stat.S_IFDIR | ZIP_DIRECTORY_BIT
43
43
 
44
44
 
45
 
def zip_exporter(tree, dest, root, subdir, filtered=False):
 
45
def zip_exporter(tree, dest, root, subdir, filtered=False,
 
46
                 per_file_timestamps=False):
46
47
    """ Export this tree to a new zip file.
47
48
 
48
49
    `dest` will be created holding the contents of this tree; if it
62
63
 
63
64
            # zipfile.ZipFile switches all paths to forward
64
65
            # slashes anyway, so just stick with that.
 
66
            if per_file_timestamps:
 
67
                mtime = tree.get_file_mtime(ie.file_id, dp)
 
68
            else:
 
69
                mtime = now
65
70
            filename = osutils.pathjoin(root, dp).encode('utf8')
66
71
            if ie.kind == "file":
67
72
                zinfo = zipfile.ZipInfo(
68
73
                            filename=filename,
69
 
                            date_time=now)
 
74
                            date_time=mtime)
70
75
                zinfo.compress_type = compression
71
76
                zinfo.external_attr = _FILE_ATTR
72
77
                if filtered:
84
89
                # not just empty files.
85
90
                zinfo = zipfile.ZipInfo(
86
91
                            filename=filename + '/',
87
 
                            date_time=now)
 
92
                            date_time=mtime)
88
93
                zinfo.compress_type = compression
89
94
                zinfo.external_attr = _DIR_ATTR
90
95
                zipf.writestr(zinfo,'')
91
96
            elif ie.kind == "symlink":
92
97
                zinfo = zipfile.ZipInfo(
93
98
                            filename=(filename + '.lnk'),
94
 
                            date_time=now)
 
99
                            date_time=mtime)
95
100
                zinfo.compress_type = compression
96
101
                zinfo.external_attr = _FILE_ATTR
97
102
                zipf.writestr(zinfo, ie.symlink_target)