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