~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/builtins.py

  • Committer: Robert Collins
  • Date: 2005-10-30 23:58:46 UTC
  • Revision ID: robertc@robertcollins.net-20051030235846-fda8b626748cce52
Move Branch.read_working_inventory to WorkingTree.

Branch.read_working_inventory has moved to
WorkingTree.read_working_inventory. This necessitated changes to
Branch.get_root_id, and a move of Branch.set_inventory to WorkingTree
as well. To make it clear that a WorkingTree cannot always be obtained
Branch.working_tree() will raise 'errors.NoWorkingTree' if one cannot
be obtained. (Robert Collins)

Show diffs side-by-side

added added

removed removed

Lines of Context:
27
27
from bzrlib.commands import Command, display_command
28
28
from bzrlib.branch import Branch
29
29
from bzrlib.errors import BzrError, BzrCheckError, BzrCommandError, NotBranchError
30
 
from bzrlib.errors import DivergedBranches, NoSuchFile
 
30
from bzrlib.errors import DivergedBranches, NoSuchFile, NoWorkingTree
31
31
from bzrlib.option import Option
32
32
from bzrlib.revisionspec import RevisionSpec
33
33
import bzrlib.trace
262
262
    def run(self, revision=None, show_ids=False):
263
263
        b = Branch.open_containing('.')[0]
264
264
        if revision is None:
265
 
            inv = b.read_working_inventory()
 
265
            inv = b.working_tree().read_working_inventory()
266
266
        else:
267
267
            if len(revision) > 1:
268
268
                raise BzrCommandError('bzr inventory --revision takes'
560
560
    def run(self, dir='.'):
561
561
        b = Branch.open_containing(dir)[0]
562
562
        old_inv = b.basis_tree().inventory
563
 
        new_inv = b.read_working_inventory()
 
563
        new_inv = b.working_tree().read_working_inventory()
564
564
 
565
565
        renames = list(bzrlib.tree.find_renames(old_inv, new_inv))
566
566
        renames.sort()
655
655
    """Display list of versioned directories in this branch."""
656
656
    @display_command
657
657
    def run(self):
658
 
        for name, ie in Branch.open_containing('.')[0].read_working_inventory().directories():
 
658
        for name, ie in (Branch.open_containing('.')[0].working_tree().
 
659
                         read_working_inventory().directories()):
659
660
            if name == '':
660
661
                print '.'
661
662
            else:
838
839
        if filename:
839
840
            b, fp = Branch.open_containing(filename)
840
841
            if fp != '':
841
 
                file_id = b.read_working_inventory().path2id(fp)
 
842
                try:
 
843
                    inv = b.working_tree().read_working_inventory()
 
844
                except NoWorkingTree:
 
845
                    inv = b.get_inventory(b.last_revision())
 
846
                file_id = inv.path2id(fp)
842
847
            else:
843
848
                file_id = None  # points to branch root
844
849
        else:
897
902
    @display_command
898
903
    def run(self, filename):
899
904
        b, relpath = Branch.open_containing(filename)[0]
900
 
        inv = b.read_working_inventory()
 
905
        inv = b.working_tree().read_working_inventory()
901
906
        file_id = inv.path2id(relpath)
902
907
        for revno, revision_id, what in bzrlib.log.find_touching_revisions(b, file_id):
903
908
            print "%6d %s" % (revno, what)