~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/workingtree.py

  • Committer: Patch Queue Manager
  • Date: 2012-02-07 00:57:24 UTC
  • mfrom: (6405.2.18 bzr)
  • Revision ID: pqm@pqm.ubuntu.com-20120207005724-xvfawh5exf1ohusu
(jelmer) Rename Tree.inventory to Tree.root_inventory. (Jelmer Vernooij)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1974
1974
                # parent tree from the repository.
1975
1975
                self._cache_basis_inventory(leftmost_parent_id)
1976
1976
            else:
1977
 
                inv = leftmost_parent_tree.inventory
 
1977
                inv = leftmost_parent_tree.root_inventory
1978
1978
                xml = self._create_basis_xml_from_inventory(
1979
1979
                                        leftmost_parent_id, inv)
1980
1980
                self._write_basis_inventory(xml)
2084
2084
        return osutils.lexists(self.abspath(path))
2085
2085
 
2086
2086
    def has_or_had_id(self, file_id):
2087
 
        if file_id == self.inventory.root.file_id:
 
2087
        if file_id == self.root_inventory.root.file_id:
2088
2088
            return True
2089
2089
        inv, inv_file_id = self._unpack_file_id(file_id)
2090
2090
        return inv.has_id(inv_file_id)
2160
2160
                _mod_revision.NULL_REVISION)
2161
2161
        else:
2162
2162
            rt = self.branch.repository.revision_tree(revision_ids[0])
2163
 
        self._write_inventory(rt.inventory)
 
2163
        self._write_inventory(rt.root_inventory)
2164
2164
        self.set_parent_ids(revision_ids)
2165
2165
 
2166
2166
    def flush(self):
2221
2221
        # should probably put it back with the previous ID.
2222
2222
        # the read and write working inventory should not occur in this
2223
2223
        # function - they should be part of lock_write and unlock.
2224
 
        inv = self.inventory
 
2224
        # FIXME: nested trees
 
2225
        inv = self.root_inventory
2225
2226
        for f, file_id, kind in zip(files, ids, kinds):
2226
2227
            if file_id is None:
2227
2228
                inv.add_path(f, kind=kind)
2374
2375
        other_tree.lock_tree_write()
2375
2376
        try:
2376
2377
            new_parents = other_tree.get_parent_ids()
2377
 
            other_root = other_tree.inventory.root
 
2378
            other_root = other_tree.root_inventory.root
2378
2379
            other_root.parent_id = new_root_parent
2379
2380
            other_root.name = osutils.basename(other_tree_path)
2380
 
            self.inventory.add(other_root)
2381
 
            add_children(self.inventory, other_root)
2382
 
            self._write_inventory(self.inventory)
 
2381
            self.root_inventory.add(other_root)
 
2382
            add_children(self.root_inventory, other_root)
 
2383
            self._write_inventory(self.root_inventory)
2383
2384
            # normally we don't want to fetch whole repositories, but i think
2384
2385
            # here we really do want to consolidate the whole thing.
2385
2386
            for parent_id in other_tree.get_parent_ids():
2428
2429
            tree_bzrdir = branch_bzrdir
2429
2430
        wt = tree_bzrdir.create_workingtree(_mod_revision.NULL_REVISION)
2430
2431
        wt.set_parent_ids(self.get_parent_ids())
2431
 
        my_inv = self.inventory
 
2432
        # FIXME: Support nested trees
 
2433
        my_inv = self.root_inventory
2432
2434
        child_inv = inventory.Inventory(root_id=None)
2433
2435
        new_root = my_inv[file_id]
2434
2436
        my_inv.remove_recursive_id(file_id)
2455
2457
            raise errors.ObjectNotLocked(self)
2456
2458
 
2457
2459
        if from_dir is None and include_root is True:
2458
 
            yield ('', 'V', 'directory', self.get_root_id(), self.inventory.root)
 
2460
            yield ('', 'V', 'directory', self.get_root_id(), self.root_inventory.root)
2459
2461
        # Convert these into local objects to save lookup times
2460
2462
        pathjoin = osutils.pathjoin
2461
2463
        file_kind = self._kind
2474
2476
                return
2475
2477
            from_dir_abspath = pathjoin(self.basedir, from_dir)
2476
2478
        else:
2477
 
            inv = self.inventory
 
2479
            inv = self.root_inventory
2478
2480
            from_dir_id = inv.root.file_id
2479
2481
            from_dir_abspath = self.basedir
2480
2482
        children = os.listdir(from_dir_abspath)
2603
2605
        rename_entries = []
2604
2606
        rename_tuples = []
2605
2607
 
 
2608
        invs_to_write = set()
 
2609
 
2606
2610
        # check for deprecated use of signature
2607
2611
        if to_dir is None:
2608
2612
            raise TypeError('You must supply a target directory')
2699
2703
                raise errors.BzrRenameFailedError(from_rel,to_rel,
2700
2704
                    errors.NotVersionedError(path=from_rel))
2701
2705
            # put entry back in the inventory so we can rename it
2702
 
            from_entry = basis_tree.inventory[from_id].copy()
 
2706
            from_entry = basis_tree.root_inventory[from_id].copy()
2703
2707
            from_inv.add(from_entry)
2704
2708
        else:
2705
2709
            from_inv, from_inv_id = self._unpack_file_id(from_id)
2756
2760
 
2757
2761
        Also does basic plausability tests.
2758
2762
        """
2759
 
        inv = self.inventory
 
2763
        # FIXME: Handling of nested trees
 
2764
        inv = self.root_inventory
2760
2765
 
2761
2766
        for rename_entry in rename_entries:
2762
2767
            # store to local variables for easier reference
2846
2851
                        " Error message is: %s" % e)
2847
2852
 
2848
2853
    def _move_entry(self, entry):
2849
 
        inv = self.inventory
 
2854
        inv = self.root_inventory
2850
2855
        from_rel_abs = self.abspath(entry.from_rel)
2851
2856
        to_rel_abs = self.abspath(entry.to_rel)
2852
2857
        if from_rel_abs == to_rel_abs:
2907
2912
        This is the same order used by 'osutils.walkdirs'.
2908
2913
        """
2909
2914
        ## TODO: Work from given directory downwards
2910
 
        for path, dir_entry in self.inventory.directories():
 
2915
        for path, dir_entry in self.root_inventory.directories():
2911
2916
            # mutter("search for unknowns in %r", path)
2912
2917
            dirabs = self.abspath(path)
2913
2918
            if not isdir(dirabs):