137
137
# A counter of how many files have been renamed
138
138
self.rename_count = 0
141
"""Support Context Manager API."""
144
def __exit__(self, exc_type, exc_val, exc_tb):
145
"""Support Context Manager API."""
140
148
def finalize(self):
141
149
"""Release the working tree lock, if held.
384
392
return sorted(FinalPaths(self).get_paths(new_ids))
386
394
def _inventory_altered(self):
387
"""Get the trans_ids and paths of files needing new inv entries."""
389
for id_set in [self._new_name, self._new_parent, self._new_id,
395
"""Determine which trans_ids need new Inventory entries.
397
An new entry is needed when anything that would be reflected by an
398
inventory entry changes, including file name, file_id, parent file_id,
399
file kind, and the execute bit.
401
Some care is taken to return entries with real changes, not cases
402
where the value is deleted and then restored to its original value,
403
but some actually unchanged values may be returned.
405
:returns: A list of (path, trans_id) for all items requiring an
406
inventory change. Ordered by path.
409
# Find entries whose file_ids are new (or changed).
410
new_file_id = set(t for t in self._new_id
411
if self._new_id[t] != self.tree_file_id(t))
412
for id_set in [self._new_name, self._new_parent, new_file_id,
390
413
self._new_executability]:
391
new_ids.update(id_set)
414
changed_ids.update(id_set)
415
# removing implies a kind change
392
416
changed_kind = set(self._removed_contents)
393
418
changed_kind.intersection_update(self._new_contents)
394
changed_kind.difference_update(new_ids)
419
# Ignore entries that are already known to have changed.
420
changed_kind.difference_update(changed_ids)
421
# to keep only the truly changed ones
395
422
changed_kind = (t for t in changed_kind
396
423
if self.tree_kind(t) != self.final_kind(t))
397
new_ids.update(changed_kind)
398
return sorted(FinalPaths(self).get_paths(new_ids))
424
# all kind changes will alter the inventory
425
changed_ids.update(changed_kind)
426
# To find entries with changed parent_ids, find parents which existed,
427
# but changed file_id.
428
changed_file_id = set(t for t in new_file_id if t in self._removed_id)
429
# Now add all their children to the set.
430
for parent_trans_id in new_file_id:
431
changed_ids.update(self.iter_tree_children(parent_trans_id))
432
return sorted(FinalPaths(self).get_paths(changed_ids))
400
434
def final_kind(self, trans_id):
401
435
"""Determine the final file kind, after any changes applied.