~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 11:50:13 UTC
  • mto: This revision was merged to the branch mainline in revision 5724.
  • Revision ID: jelmer@samba.org-20110314115013-o9vwm8chuff6t8e1
SupportĀ tar.lzma.

Show diffs side-by-side

added added

removed removed

Lines of Context:
160
160
    ball.close()
161
161
 
162
162
 
163
 
def txz_exporter(tree, dest, root, subdir, filtered=False, force_mtime=None):
164
 
    """Export this tree to a new .tar.xz file.
 
163
def tar_xz_exporter(tree, dest, root, subdir, filtered=False,
 
164
                    force_mtime=None):
 
165
    return tar_lzma_exporter(tree, dest, root, subdir, filtered=filtered,
 
166
        force_mtime=force_mtime, compression_format="xz")
 
167
 
 
168
 
 
169
def tar_lzma_exporter(tree, dest, root, subdir, filtered=False, force_mtime=None, compression_format="lzma"):
 
170
    """Export this tree to a new .tar.lzma file.
165
171
 
166
172
    `dest` will be created holding the contents of this tree; if it
167
173
    already exists, it will be clobbered, like with "tar -c".
168
174
    """
169
175
    if dest == '-':
170
 
        raise errors.BzrError("Writing to stdout not supported for .tar.xz")
 
176
        raise errors.BzrError("Writing to stdout not supported for .tar.lzma")
171
177
 
172
178
    try:
173
179
        import lzma
174
180
    except ImportError, e:
175
181
        raise errors.DependencyNotPresent('lzma', e)
176
182
 
177
 
    stream = lzma.LZMAFile(dest.encode(osutils._fs_enc), 'w')
 
183
    assert compression_format in ("lzma", "xz")
 
184
    stream = lzma.LZMAFile(dest.encode(osutils._fs_enc), 'w',
 
185
            options={"format": compression_format})
178
186
    ball = tarfile.open(None, 'w:', fileobj=stream)
179
187
    export_tarball(tree, ball, root, subdir, filtered=filtered,
180
188
                   force_mtime=force_mtime)