1233
1236
def has_id(self, file_id):
1234
1237
return (file_id in self._byid)
1239
def _make_delta(self, old):
1240
"""Make an inventory delta from two inventories."""
1241
old_getter = getattr(old, '_byid', old)
1242
new_getter = self._byid
1243
old_ids = set(old_getter)
1244
new_ids = set(new_getter)
1245
adds = new_ids - old_ids
1246
deletes = old_ids - new_ids
1247
if not adds and not deletes:
1250
common = old_ids.intersection(new_ids)
1252
for file_id in deletes:
1253
delta.append((old.id2path(file_id), None, file_id, None))
1254
for file_id in adds:
1255
delta.append((None, self.id2path(file_id), file_id, self[file_id]))
1256
for file_id in common:
1257
new_ie = new_getter[file_id]
1258
old_ie = old_getter[file_id]
1259
# If xml_serializer returns the cached InventoryEntries (rather
1260
# than always doing .copy()), inlining the 'is' check saves 2.7M
1261
# calls to __eq__. Under lsprof this saves 20s => 6s.
1262
# It is a minor improvement without lsprof.
1263
if old_ie is new_ie or old_ie == new_ie:
1266
delta.append((old.id2path(file_id), self.id2path(file_id),
1236
1270
def remove_recursive_id(self, file_id):
1237
1271
"""Remove file_id, and children, from the inventory.
1239
1273
:param file_id: A file_id to remove.
1241
1275
to_find_delete = [self._byid[file_id]]