147
148
mutter("%r is a bzr tree", f)
149
count += __add_one(tree, inv, rf, kind, action)
150
added.extend(__add_one(tree, inv, rf, kind, action))
151
152
if kind == 'directory' and recurse and not sub_tree:
152
153
for subf in os.listdir(af):
153
154
subp = os.path.join(rf, subf)
154
155
if subf == bzrlib.BZRDIR:
155
156
mutter("skip control directory %r", subp)
156
elif tree.is_ignored(subp):
157
mutter("skip ignored sub-file %r", subp)
159
mutter("queue to add sub-file %r", subp)
160
file_list.append(tree.abspath(subp))
163
mutter('added %d entries', count)
158
ignore_glob = tree.is_ignored(subp)
159
if ignore_glob is not None:
160
mutter("skip ignored sub-file %r", subp)
161
if ignore_glob not in ignored:
162
ignored[ignore_glob] = []
163
ignored[ignore_glob].append(subp)
165
mutter("queue to add sub-file %r", subp)
166
file_list.append(tree.abspath(subp))
169
mutter('added %d entries', len(added))
166
172
tree._write_inventory(inv)
174
return added, ignored
170
176
def __add_one(tree, inv, path, kind, action):
171
177
"""Add a file or directory, automatically add unversioned parents."""
174
180
# This is safe from infinite recursion because the tree root is
175
181
# always versioned.
176
182
if inv.path2id(path) != None:
180
count = __add_one(tree, inv, dirname(path), 'directory', action)
186
added = __add_one(tree, inv, dirname(path), 'directory', action)
181
187
action(inv, path, kind)
189
return added + [path]