1236
1239
def _make_delta(self, old):
1237
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)
1240
1245
adds = new_ids - old_ids
1241
1246
deletes = old_ids - new_ids
1242
common = old_ids.intersection(new_ids)
1247
if not adds and not deletes:
1250
common = old_ids.intersection(new_ids)
1244
1252
for file_id in deletes:
1245
1253
delta.append((old.id2path(file_id), None, file_id, None))
1246
1254
for file_id in adds:
1247
1255
delta.append((None, self.id2path(file_id), file_id, self[file_id]))
1248
1256
for file_id in common:
1249
if old[file_id] != self[file_id]:
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:
1250
1266
delta.append((old.id2path(file_id), self.id2path(file_id),
1251
file_id, self[file_id]))
1254
1270
def remove_recursive_id(self, file_id):