/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 bzrlib/export/zip_exporter.py

  • Committer: Jelmer Vernooij
  • Date: 2011-03-13 18:51:51 UTC
  • mto: This revision was merged to the branch mainline in revision 5724.
  • Revision ID: jelmer@samba.org-20110313185151-2dmxb1e1o23cmgx0
per_file_timestamp -> force_mtime.

Show diffs side-by-side

added added

removed removed

Lines of Context:
43
43
_DIR_ATTR = stat.S_IFDIR | ZIP_DIRECTORY_BIT | DIR_PERMISSIONS
44
44
 
45
45
 
46
 
def zip_exporter(tree, dest, root, subdir, filtered=False,
47
 
                 per_file_timestamps=False):
 
46
def zip_exporter(tree, dest, root, subdir, filtered=False, force_mtime=None):
48
47
    """ Export this tree to a new zip file.
49
48
 
50
49
    `dest` will be created holding the contents of this tree; if it
52
51
    """
53
52
    mutter('export version %r', tree)
54
53
 
55
 
    now = time.localtime()[:6]
56
 
 
57
54
    compression = zipfile.ZIP_DEFLATED
58
55
    zipf = zipfile.ZipFile(dest, "w", compression)
59
56
 
64
61
 
65
62
            # zipfile.ZipFile switches all paths to forward
66
63
            # slashes anyway, so just stick with that.
67
 
            if per_file_timestamps:
 
64
            if force_mtime is not None:
 
65
                mtime = force_mtime
 
66
            else:
68
67
                mtime = tree.get_file_mtime(ie.file_id, dp)
69
 
            else:
70
 
                mtime = now
 
68
            date_time = time.localtime(mtime)[:6]
71
69
            filename = osutils.pathjoin(root, dp).encode('utf8')
72
70
            if ie.kind == "file":
73
71
                zinfo = zipfile.ZipInfo(
74
72
                            filename=filename,
75
 
                            date_time=mtime)
 
73
                            date_time=date_time)
76
74
                zinfo.compress_type = compression
77
75
                zinfo.external_attr = _FILE_ATTR
78
76
                if filtered:
90
88
                # not just empty files.
91
89
                zinfo = zipfile.ZipInfo(
92
90
                            filename=filename + '/',
93
 
                            date_time=mtime)
 
91
                            date_time=date_time)
94
92
                zinfo.compress_type = compression
95
93
                zinfo.external_attr = _DIR_ATTR
96
94
                zipf.writestr(zinfo,'')
97
95
            elif ie.kind == "symlink":
98
96
                zinfo = zipfile.ZipInfo(
99
97
                            filename=(filename + '.lnk'),
100
 
                            date_time=mtime)
 
98
                            date_time=date_time)
101
99
                zinfo.compress_type = compression
102
100
                zinfo.external_attr = _FILE_ATTR
103
101
                zipf.writestr(zinfo, ie.symlink_target)