~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/export/tar_exporter.py

  • Committer: Jelmer Vernooij
  • Date: 2011-03-14 14:06:34 UTC
  • mto: This revision was merged to the branch mainline in revision 5724.
  • Revision ID: jelmer@samba.org-20110314140634-50uoh85asl1ic6qd
Cope with mtime not always being available.

Show diffs side-by-side

added added

removed removed

Lines of Context:
106
106
    else:
107
107
        root_mtime = time.time()
108
108
    if dest == '-':
109
 
        stream = gzip.GzipFile(None, mode='w', mtime=root_mtime,
110
 
            fileobj=sys.stdout)
 
109
        basename = None
 
110
        stream = sys.stdout
111
111
    else:
112
112
        stream = open(dest.encode(osutils._fs_enc), 'w')
113
113
        # gzip file is used with an explicit fileobj so that
114
114
        # the basename can be stored in the gzip file rather than
115
115
        # dest. (bug 102234)
116
 
        stream = gzip.GzipFile(os.path.basename(dest), 'w',
117
 
            mtime=root_mtime, fileobj=stream)
 
116
        basename = os.path.basename(dest)
 
117
    try:
 
118
        stream = gzip.GzipFile(basename, 'w', fileobj=stream, mtime=root_mtime)
 
119
    except TypeError:
 
120
        # Python < 2.7 doesn't support the mtime argument
 
121
        stream = gzip.GzipFile(basename, 'w', fileobj=stream)
118
122
    ball = tarfile.open(None, 'w|', fileobj=stream)
119
123
    export_tarball(tree, ball, root, subdir, filtered=filtered,
120
124
                   force_mtime=force_mtime)