/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 processors/generic_processor.py

fix more inventory lookup bugs

Show diffs side-by-side

added added

removed removed

Lines of Context:
174
174
        # most parents are recent in history
175
175
        self.inventories = lru_cache.LRUCache(inventory_cache_size)
176
176
 
177
 
        # directory-path -> inventory-entry lookup table
178
 
        # we need to keep all of these but they are small
179
 
        self.directory_entries = {}
180
 
 
181
177
        # import-ref -> revision-id lookup table
182
178
        # we need to keep all of these but they are small
183
179
        self.revision_ids = {}
185
181
        # branch -> last revision-id lookup table
186
182
        self.last_revision_ids = {}
187
183
 
188
 
        # path -> file-ids
 
184
        # path -> file-ids - as generated
189
185
        self.file_ids = {}
190
186
 
191
187
    def _delete_path(self, path):
192
188
        """Remove a path from caches."""
193
 
        del self.file_ids[path]
 
189
        # we actually want to remember what file-id we gave a path,
 
190
        # even when that file is deleted, so doing nothing is correct
 
191
        pass
194
192
 
195
193
    def _rename_path(self, old_path, new_path):
196
194
        """Rename a path in the caches."""
 
195
        # we actually want to remember what file-id we gave a path,
 
196
        # even when that file is renamed, so both paths should have
 
197
        # the same value and we don't delete any information
197
198
        self.file_ids[new_path] = self.file_ids[old_path]
198
 
        del self.file_ids[old_path]
199
199
 
200
200
 
201
201
class GenericCommitHandler(processor.CommitHandler):
243
243
            # the new revision_id.
244
244
            self.inventory.root.revision = self.revision_id
245
245
 
 
246
        # directory-path -> inventory-entry for current inventory
 
247
        self.directory_entries = dict(self.inventory.directories())
 
248
 
246
249
    def post_process_files(self):
247
250
        """Save the revision."""
248
251
        if self.verbose:
406
409
        """Add to or change an item in the inventory."""
407
410
        # Create the new InventoryEntry
408
411
        basename, parent_ie = self._ensure_directory(path)
409
 
        file_id, is_new = self.bzr_file_id_and_new(path)
 
412
        file_id = self.bzr_file_id(path)
410
413
        ie = inventory.make_entry(kind, basename, parent_ie.file_id, file_id)
411
414
        ie.revision = self.revision_id
412
415
        if isinstance(ie, inventory.InventoryFile):
422
425
                (kind,))
423
426
 
424
427
        # Record this new inventory entry
425
 
        if is_new:
426
 
            self.inventory.add(ie)
427
 
        else:
 
428
        if file_id in self.inventory:
428
429
            # HACK: no API for this (del+add does more than it needs to)
429
430
            self.inventory._byid[file_id] = ie
 
431
        else:
 
432
            self.inventory.add(ie)
430
433
 
431
434
    def _ensure_directory(self, path):
432
435
        """Ensure that the containing directory exists for 'path'"""
435
438
            # the root node doesn't get updated
436
439
            return basename, self.inventory.root
437
440
        try:
438
 
            ie = self.cache_mgr.directory_entries[dirname]
 
441
            ie = self.directory_entries[dirname]
439
442
        except KeyError:
440
443
            # We will create this entry, since it doesn't exist
441
444
            pass
450
453
                                                  dir_basename,
451
454
                                                  parent_ie.file_id)
452
455
        ie.revision = self.revision_id
453
 
        self.cache_mgr.directory_entries[dirname] = ie
 
456
        self.directory_entries[dirname] = ie
454
457
        # There are no lines stored for a directory so
455
458
        # make sure the cache used by get_lines knows that
456
459
        self.lines_for_commit[dir_file_id] = []