60
60
When requesting a specific type of export, load the respective path.
62
def _loader(tree, dest, root, subdir, filtered, force_mtime):
62
def _loader(tree, dest, root, subdir, filtered, force_mtime, fileobj):
63
63
func = pyutils.get_named_object(module, funcname)
64
return func(tree, dest, root, subdir, filtered=filtered,
65
force_mtime=force_mtime)
64
return func(tree, dest, root, subdir, filtered=filtered,
65
force_mtime=force_mtime, fileobj=fileobj)
66
66
register_exporter(scheme, extensions, _loader)
69
def export(tree, dest, format=None, root=None, subdir=None, filtered=False,
70
per_file_timestamps=False):
71
"""Export the given Tree to the specific destination.
68
def get_export_generator(tree, dest=None, format=None, root=None, subdir=None,
69
filtered=False, per_file_timestamps=False,
71
"""Returns a generator that exports the given tree.
73
The generator is expected to yield None while exporting the tree while the
74
actual export is written to ``fileobj``.
73
76
:param tree: A Tree (such as RevisionTree) to export
74
:param dest: The destination where the files,etc should be put
78
:param dest: The destination where the files, etc should be put
75
80
:param format: The format (dir, zip, etc), if None, it will check the
76
extension on dest, looking for a match
77
:param root: The root location inside the format.
78
It is common practise to have zipfiles and tarballs
79
extract into a subdirectory, rather than into the
80
current working directory.
81
If root is None, the default root will be
82
selected as the destination without its
81
extension on dest, looking for a match
83
:param root: The root location inside the format. It is common practise to
84
have zipfiles and tarballs extract into a subdirectory, rather than
85
into the current working directory. If root is None, the default root
86
will be selected as the destination without its extension.
84
88
:param subdir: A starting directory within the tree. None means to export
85
89
the entire tree, and anything else should specify the relative path to
86
90
a directory to start exporting from.
87
:param filtered: If True, content filtering is applied to the
89
:param per_file_timestamps: Whether to use the timestamp stored in the
90
tree rather than now(). This will do a revision lookup
91
for every file so will be significantly slower.
92
:param filtered: If True, content filtering is applied to the exported
95
:param per_file_timestamps: Whether to use the timestamp stored in the tree
96
rather than now(). This will do a revision lookup for every file so
97
will be significantly slower.
99
:param fileobj: Optional file object to use
93
101
global _exporters, _exporter_extensions
103
if format is None and dest is not None:
96
104
for ext in _exporter_extensions:
97
105
if dest.endswith(ext):
98
106
format = _exporter_extensions[ext]
114
122
trace.mutter('export version %r', tree)
118
return _exporters[format](tree, dest, root, subdir, filtered=filtered,
119
force_mtime=force_mtime)
127
for _ in _exporters[format](tree, dest, root, subdir,
129
force_mtime=force_mtime, fileobj=fileobj):
136
def export(tree, dest, format=None, root=None, subdir=None, filtered=False,
137
per_file_timestamps=False, fileobj=None):
138
"""Export the given Tree to the specific destination.
140
:param tree: A Tree (such as RevisionTree) to export
141
:param dest: The destination where the files,etc should be put
142
:param format: The format (dir, zip, etc), if None, it will check the
143
extension on dest, looking for a match
144
:param root: The root location inside the format.
145
It is common practise to have zipfiles and tarballs
146
extract into a subdirectory, rather than into the
147
current working directory.
148
If root is None, the default root will be
149
selected as the destination without its
151
:param subdir: A starting directory within the tree. None means to export
152
the entire tree, and anything else should specify the relative path to
153
a directory to start exporting from.
154
:param filtered: If True, content filtering is applied to the
156
:param per_file_timestamps: Whether to use the timestamp stored in the
157
tree rather than now(). This will do a revision lookup
158
for every file so will be significantly slower.
159
:param fileobj: Optional file object to use
161
for _ in get_export_generator(tree, dest, format, root, subdir, filtered,
162
per_file_timestamps, fileobj):
124
166
def get_root_name(dest):
125
167
"""Get just the root name for an export.
167
209
final_path = path
168
210
if not tree.has_filename(path):
170
213
yield final_path, entry
173
register_lazy_exporter(None, [], 'bzrlib.export.dir_exporter', 'dir_exporter')
174
register_lazy_exporter('dir', [], 'bzrlib.export.dir_exporter', 'dir_exporter')
175
register_lazy_exporter('tar', ['.tar'], 'bzrlib.export.tar_exporter', 'plain_tar_exporter')
176
register_lazy_exporter('tgz', ['.tar.gz', '.tgz'], 'bzrlib.export.tar_exporter', 'tgz_exporter')
177
register_lazy_exporter('tbz2', ['.tar.bz2', '.tbz2'], 'bzrlib.export.tar_exporter', 'tbz_exporter')
178
register_lazy_exporter('tlzma', ['.tar.lzma'], 'bzrlib.export.tar_exporter', 'tar_lzma_exporter')
179
register_lazy_exporter('txz', ['.tar.xz'], 'bzrlib.export.tar_exporter', 'tar_xz_exporter')
180
register_lazy_exporter('zip', ['.zip'], 'bzrlib.export.zip_exporter', 'zip_exporter')
216
register_lazy_exporter(None, [], 'bzrlib.export.dir_exporter',
217
'dir_exporter_generator')
218
register_lazy_exporter('dir', [], 'bzrlib.export.dir_exporter',
219
'dir_exporter_generator')
220
register_lazy_exporter('tar', ['.tar'], 'bzrlib.export.tar_exporter',
221
'plain_tar_exporter_generator')
222
register_lazy_exporter('tgz', ['.tar.gz', '.tgz'], 'bzrlib.export.tar_exporter',
223
'tgz_exporter_generator')
224
register_lazy_exporter('tbz2', ['.tar.bz2', '.tbz2'],
225
'bzrlib.export.tar_exporter', 'tbz_exporter_generator')
226
register_lazy_exporter('tlzma', ['.tar.lzma'], 'bzrlib.export.tar_exporter',
227
'tar_lzma_exporter_generator')
228
register_lazy_exporter('txz', ['.tar.xz'], 'bzrlib.export.tar_exporter',
229
'tar_xz_exporter_generator')
230
register_lazy_exporter('zip', ['.zip'], 'bzrlib.export.zip_exporter',
231
'zip_exporter_generator')