~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/workingtree.py

[patch] keep a cached basis inventory (Johan Rydberg)

Show diffs side-by-side

added added

removed removed

Lines of Context:
55
55
from bzrlib.errors import (BzrCheckError,
56
56
                           BzrError,
57
57
                           DivergedBranches,
 
58
                           WeaveRevisionNotPresent,
58
59
                           NotBranchError,
59
60
                           NotVersionedError)
60
61
from bzrlib.inventory import InventoryEntry
777
778
        """See Branch.lock_write, and WorkingTree.unlock."""
778
779
        return self.branch.lock_write()
779
780
 
 
781
    def _basis_inventory_name(self, revision_id):
 
782
        return 'basis-inventory.%s' % revision_id
 
783
 
 
784
    def set_last_revision(self, new_revision, old_revision=None):
 
785
        if old_revision:
 
786
            try:
 
787
                path = self._basis_inventory_name(old_revision)
 
788
                path = self.branch._rel_controlfilename(path)
 
789
                self.branch._transport.delete(path)
 
790
            except:
 
791
                pass
 
792
        try:
 
793
            xml = self.branch.get_inventory_xml(new_revision)
 
794
            path = self._basis_inventory_name(new_revision)
 
795
            self.branch.put_controlfile(path, xml)
 
796
        except WeaveRevisionNotPresent:
 
797
            pass
 
798
 
 
799
    def read_basis_inventory(self, revision_id):
 
800
        """Read the cached basis inventory."""
 
801
        path = self._basis_inventory_name(revision_id)
 
802
        return self.branch.controlfile(path, 'r').read()
 
803
        
780
804
    @needs_read_lock
781
805
    def read_working_inventory(self):
782
806
        """Read the working inventory."""