~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/workingtree.py

  • Committer: Robert Collins
  • Date: 2005-12-24 02:20:45 UTC
  • mto: (1185.50.57 bzr-jam-integration)
  • mto: This revision was merged to the branch mainline in revision 1550.
  • Revision ID: robertc@robertcollins.net-20051224022045-14efc8dfa0e1a4e9
Start tests for api usage.

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
68
69
                            realpath,
69
70
                            relpath,
70
71
                            rename)
 
72
from bzrlib.textui import show_status
71
73
import bzrlib.tree
72
74
from bzrlib.trace import mutter
73
75
import bzrlib.xml5
172
174
    not listed in the Inventory and vice versa.
173
175
    """
174
176
 
175
 
    def __init__(self, basedir='.', branch=None):
 
177
    def __init__(self, basedir=u'.', branch=None):
176
178
        """Construct a WorkingTree for basedir.
177
179
 
178
180
        If the branch is not supplied, it is opened automatically.
229
231
            if path.find('://') != -1:
230
232
                raise NotBranchError(path=path)
231
233
        path = os.path.abspath(path)
232
 
        tail = ''
 
234
        tail = u''
233
235
        while True:
234
236
            try:
235
237
                return WorkingTree(path), tail
502
504
                for ff in descend(fp, f_ie.file_id, fap):
503
505
                    yield ff
504
506
 
505
 
        for f in descend('', inv.root.file_id, self.basedir):
 
507
        for f in descend(u'', inv.root.file_id, self.basedir):
506
508
            yield f
507
509
 
508
510
    @needs_write_lock
777
779
        """See Branch.lock_write, and WorkingTree.unlock."""
778
780
        return self.branch.lock_write()
779
781
 
 
782
    def _basis_inventory_name(self, revision_id):
 
783
        return 'basis-inventory.%s' % revision_id
 
784
 
 
785
    def set_last_revision(self, new_revision, old_revision=None):
 
786
        if old_revision:
 
787
            try:
 
788
                path = self._basis_inventory_name(old_revision)
 
789
                path = self.branch._rel_controlfilename(path)
 
790
                self.branch._transport.delete(path)
 
791
            except:
 
792
                pass
 
793
        try:
 
794
            xml = self.branch.get_inventory_xml(new_revision)
 
795
            path = self._basis_inventory_name(new_revision)
 
796
            self.branch.put_controlfile(path, xml)
 
797
        except WeaveRevisionNotPresent:
 
798
            pass
 
799
 
 
800
    def read_basis_inventory(self, revision_id):
 
801
        """Read the cached basis inventory."""
 
802
        path = self._basis_inventory_name(revision_id)
 
803
        return self.branch.controlfile(path, 'r').read()
 
804
        
780
805
    @needs_read_lock
781
806
    def read_working_inventory(self):
782
807
        """Read the working inventory."""