/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/transform.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2011-06-10 16:19:57 UTC
  • mfrom: (5954.2.7 merge-into-empty-fixups)
  • Revision ID: pqm@pqm.ubuntu.com-20110610161957-hh5ni839m7r3wsan
Cleanups and fixes for merging into null tree. (Aaron Bentley)

Show diffs side-by-side

added added

removed removed

Lines of Context:
137
137
        # A counter of how many files have been renamed
138
138
        self.rename_count = 0
139
139
 
 
140
    def __enter__(self):
 
141
        """Support Context Manager API."""
 
142
        return self
 
143
 
 
144
    def __exit__(self, exc_type, exc_val, exc_tb):
 
145
        """Support Context Manager API."""
 
146
        self.finalize()
 
147
 
140
148
    def finalize(self):
141
149
        """Release the working tree lock, if held.
142
150
 
384
392
        return sorted(FinalPaths(self).get_paths(new_ids))
385
393
 
386
394
    def _inventory_altered(self):
387
 
        """Get the trans_ids and paths of files needing new inv entries."""
388
 
        new_ids = set()
389
 
        for id_set in [self._new_name, self._new_parent, self._new_id,
 
395
        """Determine which trans_ids need new Inventory entries.
 
396
 
 
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.
 
400
 
 
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.
 
404
 
 
405
        :returns: A list of (path, trans_id) for all items requiring an
 
406
            inventory change. Ordered by path.
 
407
        """
 
408
        changed_ids = set()
 
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)
 
417
        # so does adding
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))
399
433
 
400
434
    def final_kind(self, trans_id):
401
435
        """Determine the final file kind, after any changes applied.