/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 bzr_commit_handler.py

make the file-id cache optional and branch-ref aware

Show diffs side-by-side

added added

removed removed

Lines of Context:
45
45
        self.cache_mgr = cache_mgr
46
46
        self.rev_store = rev_store
47
47
        self.verbose = verbose
 
48
        self.branch_ref = command.ref
48
49
 
49
50
    def pre_process_files(self):
50
51
        """Prepare for committing."""
147
148
          is_new = True if the file_id is newly created
148
149
        """
149
150
        try:
150
 
            id = self.cache_mgr.file_ids[path]
 
151
            id = self.cache_mgr.fetch_file_id(self.branch_ref, path)
151
152
            return id, False
152
153
        except KeyError:
153
 
            id = generate_ids.gen_file_id(path)
154
 
            self.cache_mgr.file_ids[path] = id
155
 
            self.debug("Generated new file id %s for '%s'", id, path)
 
154
            # Not in the cache, try the inventory
 
155
            id = self.basis_inventory.path2id(path)
 
156
            if id is None:
 
157
                # Doesn't exist yet so create it
 
158
                id = generate_ids.gen_file_id(path)
 
159
                self.debug("Generated new file id %s for '%s' in '%s'",
 
160
                    id, path, self.branch_ref)
 
161
            self.cache_mgr.store_file_id(self.branch_ref, path, id)
156
162
            return id, True
157
163
 
158
164
    def bzr_file_id(self, path):
316
322
            self.record_delete(new_path, inv[new_file_id])
317
323
        ie.revision = self.revision_id
318
324
        self.record_rename(old_path, new_path, file_id, ie)
319
 
        self.cache_mgr.rename_path(old_path, new_path)
 
325
        self.cache_mgr.rename_path(self.branch_ref, old_path, new_path)
320
326
 
321
327
        # The revision-id for this entry will be/has been updated and
322
328
        # that means the loader then needs to know what the "new" text is.
343
349
    def pre_process_files(self):
344
350
        super(InventoryCommitHandler, self).pre_process_files()
345
351
 
346
 
        # Seed the inventory from the previous one
 
352
        # Seed the inventory from the previous one. Note that
 
353
        # the parent class version of pre_process_files() has
 
354
        # already set the right basis_inventory for this branch
 
355
        # but we need to copy it in order to mutate it safely
 
356
        # without corrupting the cached inventory value.
347
357
        if len(self.parents) == 0:
348
358
            self.inventory = self.basis_inventory
349
359
        else:
415
425
                del inv[fileid]
416
426
            else:
417
427
                # already added by some other name?
418
 
                if dirname in self.cache_mgr.file_ids:
419
 
                    parent_id = self.cache_mgr.file_ids[dirname]
 
428
                try:
 
429
                    parent_id = self.cache_mgr.fetch_file_id(self.branch_ref,
 
430
                        dirname)
 
431
                except KeyError:
 
432
                    pass
 
433
                else:
420
434
                    del inv[parent_id].children[basename]
421
435
        except KeyError:
422
436
            self._warn_unless_in_merges(fileid, path)
430
444
            else:
431
445
                raise
432
446
        try:
433
 
            self.cache_mgr.delete_path(path)
 
447
            self.cache_mgr.delete_path(self.branch_ref, path)
434
448
        except KeyError:
435
449
            pass
436
450