~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/dirstate.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:
1199
1199
                    fingerprint = ''
1200
1200
                insertions[file_id] = (key, minikind, inv_entry.executable,
1201
1201
                                       fingerprint, new_path)
 
1202
            # Transform moves into delete+add pairs
1202
1203
            if None not in (old_path, new_path):
1203
1204
                for child in self._iter_child_entries(0, old_path):
1204
1205
                    if child[0][2] in insertions or child[0][2] in removals:
1228
1229
                self._get_block_entry_index(dirname, basename, 0)
1229
1230
            entry = self._dirblocks[block_i][1][entry_i]
1230
1231
            self._make_absent(entry)
 
1232
            # See if we have a malformed delta: deleting a directory must not
 
1233
            # leave crud behind. This increases the number of bisects needed
 
1234
            # substantially, but deletion or renames of large numbers of paths
 
1235
            # is rare enough it shouldn't be an issue (famous last words?) RBC
 
1236
            # 20080730.
 
1237
            block_i, entry_i, d_present, f_present = \
 
1238
                self._get_block_entry_index(path, '', 0)
 
1239
            if d_present:
 
1240
                # The dir block is still present in the dirstate; this could
 
1241
                # be due to it being in a parent tree, or a corrupt delta.
 
1242
                for child_entry in self._dirblocks[block_i][1]:
 
1243
                    if child_entry[1][0][0] not in ('r', 'a'):
 
1244
                        raise errors.InconsistentDelta(path, entry[0][2],
 
1245
                            "The file id was deleted but its children were "
 
1246
                            "not deleted.")
1231
1247
 
1232
1248
    def _apply_insertions(self, adds):
1233
1249
        for key, minikind, executable, fingerprint, path_utf8 in sorted(adds):