~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/workingtree.py

Merge from integration.

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
172
173
    not listed in the Inventory and vice versa.
173
174
    """
174
175
 
175
 
    def __init__(self, basedir='.', branch=None):
 
176
    def __init__(self, basedir=u'.', branch=None):
176
177
        """Construct a WorkingTree for basedir.
177
178
 
178
179
        If the branch is not supplied, it is opened automatically.
229
230
            if path.find('://') != -1:
230
231
                raise NotBranchError(path=path)
231
232
        path = os.path.abspath(path)
232
 
        tail = ''
 
233
        tail = u''
233
234
        while True:
234
235
            try:
235
236
                return WorkingTree(path), tail
502
503
                for ff in descend(fp, f_ie.file_id, fap):
503
504
                    yield ff
504
505
 
505
 
        for f in descend('', inv.root.file_id, self.basedir):
 
506
        for f in descend(u'', inv.root.file_id, self.basedir):
506
507
            yield f
507
508
 
508
509
    @needs_write_lock
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.storage.get_inventory_xml(new_revision)
 
794
            path = self._basis_inventory_name(new_revision)
 
795
            self.branch.control_files.put_utf8(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.control_files.controlfile(path, 'r').read()
 
803
        
780
804
    @needs_read_lock
781
805
    def read_working_inventory(self):
782
806
        """Read the working inventory."""