105
105
from bzrlib.errors import BadFileKindError, ForbiddenFileError
106
106
assert isinstance(recurse, bool)
108
orig_list = file_list
109
file_list = _prepare_file_list(file_list)
110
mutter("smart add of %r, originally %r", file_list, orig_list)
108
prepared_list = _prepare_file_list(file_list)
109
mutter("smart add of %r, originally %r", prepared_list, file_list)
111
110
inv = tree.read_working_inventory()
114
user_files = list(file_list)
117
116
# validate user file paths and convert all paths to tree
118
117
# relative : its cheaper to make a tree relative path an abspath
119
118
# than to convert an abspath to tree relative.
120
for filepath in user_files:
119
for filepath in prepared_list:
121
120
rf = tree.relpath(filepath)
122
file_list.append((rf, None))
122
files_to_add.append((rf, None))
123
123
# validate user parameters. Our recursive code avoids adding new files
124
124
# that need such validation
125
125
if tree.is_control_filename(rf):
126
126
raise ForbiddenFileError('cannot add control file %s' % filepath)
128
user_files = set([path for path, parent_ie in file_list])
130
for filepath, parent_ie in file_list:
128
for filepath, parent_ie in files_to_add:
131
129
# filepath is tree-relative
132
130
abspath = tree.abspath(filepath)
221
219
ignored[ignore_glob].append(subp)
223
221
#mutter("queue to add sub-file %r", subp)
224
file_list.append((subp, this_ie))
222
files_to_add.append((subp, this_ie))
226
224
if len(added) > 0:
227
225
tree._write_inventory(inv)
231
229
def __add_one(tree, inv, parent_ie, path, kind, action):
232
"""Add a file or directory, automatically add unversioned parents."""
230
"""Add a new entry to the inventory and automatically add unversioned parents.
232
Actual adding of the entry is delegated to the action callback.
234
:param inv: Inventory which will receive the new entry.
235
:param parent_ie: Parent inventory entry if known, or None. If
236
None, the parent is looked up by name and used if present, otherwise
237
it is recursively added.
238
:param kind: Kind of new entry (file, directory, etc)
239
:param action: callback(inv, parent_ie, path, kind); return ignored.
240
:returns: A list of paths which have been added.
234
243
# Nothing to do if path is already versioned.
235
244
# This is safe from infinite recursion because the tree root is