1
# Copyright (C) 2005, 2006, 2008 Canonical Ltd
1
# Copyright (C) 2005, 2006, 2008, 2009, 2010 Canonical Ltd
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
17
17
"""Export a Tree to a non-versioned directory.
26
from bzrlib import errors, export, osutils
25
from bzrlib import export, osutils
27
26
from bzrlib.export import _export_iter_entries
28
27
from bzrlib.filters import (
29
28
ContentFilterContext,
32
31
from bzrlib.trace import mutter
35
def tar_exporter(tree, dest, root, subdir, compression=None, filtered=False):
34
def tar_exporter(tree, dest, root, subdir, compression=None, filtered=False,
35
per_file_timestamps=False):
36
36
"""Export this tree to a new tar file.
38
38
`dest` will be created holding the contents of this tree; if it
52
52
for dp, ie in _export_iter_entries(tree, subdir):
53
53
filename = osutils.pathjoin(root, dp).encode('utf8')
54
54
item = tarfile.TarInfo(filename)
55
if per_file_timestamps:
56
item.mtime = tree.get_file_mtime(ie.file_id, dp)
56
59
if ie.kind == "file":
57
60
item.type = tarfile.REGTYPE
58
61
if tree.is_executable(ie.file_id):
92
def tgz_exporter(tree, dest, root, subdir, filtered=False):
93
tar_exporter(tree, dest, root, subdir, compression='gz', filtered=filtered)
96
def tbz_exporter(tree, dest, root, subdir, filtered=False):
97
tar_exporter(tree, dest, root, subdir, compression='bz2', filtered=filtered)
95
def tgz_exporter(tree, dest, root, subdir, filtered=False,
96
per_file_timestamps=False):
97
tar_exporter(tree, dest, root, subdir, compression='gz',
98
filtered=filtered, per_file_timestamps=per_file_timestamps)
101
def tbz_exporter(tree, dest, root, subdir, filtered=False,
102
per_file_timestamps=False):
103
tar_exporter(tree, dest, root, subdir, compression='bz2',
104
filtered=filtered, per_file_timestamps=per_file_timestamps)