144
144
raise NotImplementedError(self._add)
146
@needs_tree_write_lock
147
def apply_inventory_delta(self, changes):
148
"""Apply changes to the inventory as an atomic operation.
150
The argument is a set of changes to apply. It must describe a
151
valid result, but the order is not important. Specifically,
152
intermediate stages *may* be invalid, such as when two files
155
The changes should be structured as a list of tuples, of the form
156
(old_path, new_path, file_id, new_entry). For creation, old_path
157
must be None. For deletion, new_path and new_entry must be None.
158
file_id is always non-None. For renames and other mutations, all
159
values must be non-None.
161
If the new_entry is a directory, its children should be an empty
162
dict. Children are handled by apply_inventory_delta itself.
164
:param changes: A list of tuples for the change to apply:
165
[(old_path, new_path, file_id, new_inventory_entry), ...]
170
for old_path, file_id in sorted(((op, f) for op, np, f, e in changes
171
if op is not None), reverse=True):
172
if file_id not in inv:
174
children[file_id] = getattr(inv[file_id], 'children', {})
175
inv.remove_recursive_id(file_id)
176
for new_path, new_entry in sorted((np, e) for op, np, f, e in
177
changes if np is not None):
178
if getattr(new_entry, 'children', None) is not None:
179
new_entry.children = children.get(new_entry.file_id, {})
181
self._write_inventory(inv)
146
183
@needs_write_lock
147
184
def commit(self, message=None, revprops=None, *args,