331
331
kind = DirState._minikind_to_kind[file_id_entry[1][0][0]]
332
332
info = '%s:%s' % (kind, path)
333
333
raise errors.DuplicateFileId(file_id, info)
334
entry_key = (dirname, basename, file_id)
335
self._read_dirblocks_if_needed()
336
block_index, present = self._find_block_index_from_key(entry_key)
334
first_key = (dirname, basename, '')
335
block_index, present = self._find_block_index_from_key(first_key)
337
# check the path is not in the tree
338
block = self._dirblocks[block_index][1]
339
entry_index, _ = self._find_entry_index(first_key, block)
340
while (entry_index < len(block) and
341
block[entry_index][0][0:2] == first_key[0:2]):
342
if block[entry_index][1][0][0] not in 'ar':
343
# this path is in the dirstate in the current tree.
344
raise Exception, "adding already added path!"
338
346
# The block where we want to put the file is not present. But it
339
347
# might be because the directory was empty, or not loaded yet. Look
340
348
# for a parent entry, if not found, raise NotVersionedError
345
353
raise errors.NotVersionedError(path, str(self))
346
354
self._ensure_block(parent_block_idx, parent_entry_idx, dirname)
347
355
block = self._dirblocks[block_index][1]
356
entry_key = (dirname, basename, file_id)
350
359
packed_stat = DirState.NULLSTAT