1
# Copyright (C) 2005-2010 Canonical Ltd
1
# Copyright (C) 2005-2011 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
143
143
:param subdir: None or the path of an entry to start exporting from.
144
144
:param skip_special: Whether to skip .bzr files.
150
subdir_id = inv.path2id(subdir)
151
if subdir_id is not None:
152
subdir_object = inv[subdir_id]
153
# XXX: subdir is path not an id, so NoSuchId isn't proper error
155
raise errors.NoSuchId(tree, subdir)
156
if subdir_object is not None and subdir_object.kind != 'directory':
157
yield subdir_object.name, subdir_object
160
entries = inv.iter_entries(subdir_object)
162
entries.next() # skip root
163
for entry in entries:
148
if subdir is not None:
149
subdir = subdir.rstrip('/')
150
entries = tree.iter_entries_by_dir()
151
entries.next() # skip root
152
for path, entry in entries:
164
153
# The .bzr* namespace is reserved for "magic" files like
165
154
# .bzrignore and .bzrrules - do not export these
166
if skip_special and entry[0].startswith(".bzr"):
155
if skip_special and path.startswith(".bzr"):
169
if not tree.has_filename(entry[0]):
158
if entry.kind == 'directory':
160
final_path = entry.name
161
elif subdir is not None:
162
if path.startswith(subdir + '/'):
163
final_path = path[len(subdir) + 1:]
172
if not tree.has_filename(os.path.join(subdir, entry[0])):
168
if not tree.has_filename(path):
170
yield final_path, entry
177
173
register_lazy_exporter(None, [], 'bzrlib.export.dir_exporter', 'dir_exporter')