~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/workingtree_4.py

Merge trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
500
500
            mode = os.lstat(self.abspath(path)).st_mode
501
501
            return bool(stat.S_ISREG(mode) and stat.S_IEXEC & mode)
502
502
 
 
503
    def all_file_ids(self):
 
504
        """See Tree.iter_all_file_ids"""
 
505
        self._must_be_locked()
 
506
        result = set()
 
507
        for key, tree_details in self.current_dirstate()._iter_entries():
 
508
            if tree_details[0][0] in ('a', 'r'): # relocated
 
509
                continue
 
510
            result.add(key[2])
 
511
        return result
 
512
 
503
513
    @needs_read_lock
504
514
    def __iter__(self):
505
515
        """Iterate through file_ids for this tree.
1215
1225
            for file_id in file_ids:
1216
1226
                self._inventory.remove_recursive_id(file_id)
1217
1227
 
 
1228
    @needs_tree_write_lock
 
1229
    def rename_one(self, from_rel, to_rel, after=False):
 
1230
        """See WorkingTree.rename_one"""
 
1231
        self.flush()
 
1232
        WorkingTree.rename_one(self, from_rel, to_rel, after)
 
1233
 
 
1234
    @needs_tree_write_lock
 
1235
    def apply_inventory_delta(self, changes):
 
1236
        """See MutableTree.apply_inventory_delta"""
 
1237
        state = self.current_dirstate()
 
1238
        state.update_by_delta(changes)
 
1239
        self._make_dirty(reset_inventory=True)
 
1240
 
1218
1241
    def update_basis_by_delta(self, new_revid, delta):
1219
1242
        """See MutableTree.update_basis_by_delta."""
1220
1243
        assert self.last_revision() != new_revid
1259
1282
        return "Working tree format 4"
1260
1283
 
1261
1284
    def initialize(self, a_bzrdir, revision_id=None, from_branch=None,
1262
 
                   accelerator_tree=None):
 
1285
                   accelerator_tree=None, hardlink=False):
1263
1286
        """See WorkingTreeFormat.initialize().
1264
1287
 
1265
1288
        :param revision_id: allows creating a working tree at a different
1268
1291
            contents more quickly than the revision tree, i.e. a workingtree.
1269
1292
            The revision tree will be used for cases where accelerator_tree's
1270
1293
            content is different.
 
1294
        :param hardlink: If true, hard-link files from accelerator_tree,
 
1295
            where possible.
1271
1296
 
1272
1297
        These trees get an initial random root id, if their repository supports
1273
1298
        rich root data, TREE_ROOT otherwise.
1320
1345
            else:
1321
1346
                parents_list = [(revision_id, basis)]
1322
1347
            basis.lock_read()
1323
 
            wt.set_parent_trees(parents_list, allow_leftmost_as_ghost=True)
1324
 
            wt.flush()
1325
 
            # if the basis has a root id we have to use that; otherwise we use
1326
 
            # a new random one
1327
 
            basis_root_id = basis.get_root_id()
1328
 
            if basis_root_id is not None:
1329
 
                wt._set_root_id(basis_root_id)
 
1348
            try:
 
1349
                wt.set_parent_trees(parents_list, allow_leftmost_as_ghost=True)
1330
1350
                wt.flush()
1331
 
            transform.build_tree(basis, wt, accelerator_tree)
1332
 
            basis.unlock()
 
1351
                # if the basis has a root id we have to use that; otherwise we
 
1352
                # use a new random one
 
1353
                basis_root_id = basis.get_root_id()
 
1354
                if basis_root_id is not None:
 
1355
                    wt._set_root_id(basis_root_id)
 
1356
                    wt.flush()
 
1357
                transform.build_tree(basis, wt, accelerator_tree,
 
1358
                                     hardlink=hardlink)
 
1359
            finally:
 
1360
                basis.unlock()
1333
1361
        finally:
1334
1362
            control_files.unlock()
1335
1363
            wt.unlock()
1602
1630
            raise errors.NoSuchId(tree=self, file_id=file_id)
1603
1631
        return dirstate.DirState._minikind_to_kind[entry[1][0]]
1604
1632
 
 
1633
    def stored_kind(self, file_id):
 
1634
        """See Tree.stored_kind"""
 
1635
        return self.kind(file_id)
 
1636
 
1605
1637
    def path_content_summary(self, path):
1606
1638
        """See Tree.path_content_summary."""
1607
1639
        id = self.inventory.path2id(path)
1728
1760
    _matching_to_tree_format = WorkingTreeFormat4()
1729
1761
    _test_mutable_trees_to_test_trees = make_source_parent_tree
1730
1762
 
1731
 
    def _iter_changes(self, include_unchanged=False,
 
1763
    def iter_changes(self, include_unchanged=False,
1732
1764
                      specific_files=None, pb=None, extra_trees=[],
1733
1765
                      require_versioned=True, want_unversioned=False):
1734
1766
        """Return the changes from source to target.
1735
1767
 
1736
 
        :return: An iterator that yields tuples. See InterTree._iter_changes
 
1768
        :return: An iterator that yields tuples. See InterTree.iter_changes
1737
1769
            for details.
1738
1770
        :param specific_files: An optional list of file paths to restrict the
1739
1771
            comparison to. When mapping filenames to ids, all matches in all
1758
1790
        # TODO: handle extra trees in the dirstate.
1759
1791
        if (extra_trees or specific_files == []):
1760
1792
            # we can't fast-path these cases (yet)
1761
 
            for f in super(InterDirStateTree, self)._iter_changes(
 
1793
            for f in super(InterDirStateTree, self).iter_changes(
1762
1794
                include_unchanged, specific_files, pb, extra_trees,
1763
1795
                require_versioned, want_unversioned=want_unversioned):
1764
1796
                yield f
1768
1800
                or self.source._revision_id == NULL_REVISION), \
1769
1801
                "revision {%s} is not stored in {%s}, but %s " \
1770
1802
                "can only be used for trees stored in the dirstate" \
1771
 
                % (self.source._revision_id, self.target, self._iter_changes)
 
1803
                % (self.source._revision_id, self.target, self.iter_changes)
1772
1804
        target_index = 0
1773
1805
        if self.source._revision_id == NULL_REVISION:
1774
1806
            source_index = None
1951
1983
                                                 path_utf8=old_path)
1952
1984
                    # update the source details variable to be the real
1953
1985
                    # location.
 
1986
                    if old_entry == (None, None):
 
1987
                        raise errors.CorruptDirstate(state._filename,
 
1988
                            "entry '%s/%s' is considered renamed from %r"
 
1989
                            " but source does not exist\n"
 
1990
                            "entry: %s" % (entry[0][0], entry[0][1], old_path, entry))
1954
1991
                    source_details = old_entry[1][source_index]
1955
1992
                    source_minikind = source_details[0]
1956
1993
                else: