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,
165
return tar_lzma_exporter(tree, dest, root, subdir, filtered=filtered,
166
force_mtime=force_mtime, compression_format="xz")
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.
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".
170
raise errors.BzrError("Writing to stdout not supported for .tar.xz")
176
raise errors.BzrError("Writing to stdout not supported for .tar.lzma")
174
180
except ImportError, e:
175
181
raise errors.DependencyNotPresent('lzma', e)
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)