~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/inventory.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2008-07-30 21:30:59 UTC
  • mfrom: (3585.2.4 150438)
  • Revision ID: pqm@pqm.ubuntu.com-20080730213059-hcremsawwvcqjcj1
(robertc) Fix bug 150438 - dirstate corruption due to invalid
        inventory delta objects. (Robert Collins)

Show diffs side-by-side

added added

removed removed

Lines of Context:
815
815
                # adds come later
816
816
                continue
817
817
            # Preserve unaltered children of file_id for later reinsertion.
818
 
            children[file_id] = getattr(self[file_id], 'children', {})
 
818
            file_id_children = getattr(self[file_id], 'children', {})
 
819
            if len(file_id_children):
 
820
                children[file_id] = file_id_children
819
821
            # Remove file_id and the unaltered children. If file_id is not
820
822
            # being deleted it will be reinserted back later.
821
823
            self.remove_recursive_id(file_id)
827
829
        for new_path, new_entry in sorted((np, e) for op, np, f, e in
828
830
                                          delta if np is not None):
829
831
            if new_entry.kind == 'directory':
830
 
                new_entry.children = children.get(new_entry.file_id, {})
 
832
                # Pop the child which to allow detection of children whose
 
833
                # parents were deleted and which were not reattached to a new
 
834
                # parent.
 
835
                new_entry.children = children.pop(new_entry.file_id, {})
831
836
            self.add(new_entry)
 
837
        if len(children):
 
838
            # Get the parent id that was deleted
 
839
            parent_id, children = children.popitem()
 
840
            raise errors.InconsistentDelta("<deleted>", parent_id,
 
841
                "The file id was deleted but its children were not deleted.")
832
842
 
833
843
    def _set_root(self, ie):
834
844
        self.root = ie