~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/workingtree_4.py

  • Committer: Alexander Belchenko
  • Date: 2008-02-06 15:33:12 UTC
  • mto: This revision was merged to the branch mainline in revision 3231.
  • Revision ID: bialix@ukr.net-20080206153312-qycs7u05d7fjtwqq
Ian's review

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
 
 
513
503
    @needs_read_lock
514
504
    def __iter__(self):
515
505
        """Iterate through file_ids for this tree.
1225
1215
            for file_id in file_ids:
1226
1216
                self._inventory.remove_recursive_id(file_id)
1227
1217
 
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
 
 
1241
1218
    def update_basis_by_delta(self, new_revid, delta):
1242
1219
        """See MutableTree.update_basis_by_delta."""
1243
1220
        assert self.last_revision() != new_revid
1282
1259
        return "Working tree format 4"
1283
1260
 
1284
1261
    def initialize(self, a_bzrdir, revision_id=None, from_branch=None,
1285
 
                   accelerator_tree=None, hardlink=False):
 
1262
                   accelerator_tree=None):
1286
1263
        """See WorkingTreeFormat.initialize().
1287
1264
 
1288
1265
        :param revision_id: allows creating a working tree at a different
1291
1268
            contents more quickly than the revision tree, i.e. a workingtree.
1292
1269
            The revision tree will be used for cases where accelerator_tree's
1293
1270
            content is different.
1294
 
        :param hardlink: If true, hard-link files from accelerator_tree,
1295
 
            where possible.
1296
1271
 
1297
1272
        These trees get an initial random root id, if their repository supports
1298
1273
        rich root data, TREE_ROOT otherwise.
1345
1320
            else:
1346
1321
                parents_list = [(revision_id, basis)]
1347
1322
            basis.lock_read()
1348
 
            try:
1349
 
                wt.set_parent_trees(parents_list, allow_leftmost_as_ghost=True)
 
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)
1350
1330
                wt.flush()
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()
 
1331
            transform.build_tree(basis, wt, accelerator_tree)
 
1332
            basis.unlock()
1361
1333
        finally:
1362
1334
            control_files.unlock()
1363
1335
            wt.unlock()
1630
1602
            raise errors.NoSuchId(tree=self, file_id=file_id)
1631
1603
        return dirstate.DirState._minikind_to_kind[entry[1][0]]
1632
1604
 
1633
 
    def stored_kind(self, file_id):
1634
 
        """See Tree.stored_kind"""
1635
 
        return self.kind(file_id)
1636
 
 
1637
1605
    def path_content_summary(self, path):
1638
1606
        """See Tree.path_content_summary."""
1639
1607
        id = self.inventory.path2id(path)
1760
1728
    _matching_to_tree_format = WorkingTreeFormat4()
1761
1729
    _test_mutable_trees_to_test_trees = make_source_parent_tree
1762
1730
 
1763
 
    def iter_changes(self, include_unchanged=False,
 
1731
    def _iter_changes(self, include_unchanged=False,
1764
1732
                      specific_files=None, pb=None, extra_trees=[],
1765
1733
                      require_versioned=True, want_unversioned=False):
1766
1734
        """Return the changes from source to target.
1767
1735
 
1768
 
        :return: An iterator that yields tuples. See InterTree.iter_changes
 
1736
        :return: An iterator that yields tuples. See InterTree._iter_changes
1769
1737
            for details.
1770
1738
        :param specific_files: An optional list of file paths to restrict the
1771
1739
            comparison to. When mapping filenames to ids, all matches in all
1790
1758
        # TODO: handle extra trees in the dirstate.
1791
1759
        if (extra_trees or specific_files == []):
1792
1760
            # we can't fast-path these cases (yet)
1793
 
            for f in super(InterDirStateTree, self).iter_changes(
 
1761
            for f in super(InterDirStateTree, self)._iter_changes(
1794
1762
                include_unchanged, specific_files, pb, extra_trees,
1795
1763
                require_versioned, want_unversioned=want_unversioned):
1796
1764
                yield f
1800
1768
                or self.source._revision_id == NULL_REVISION), \
1801
1769
                "revision {%s} is not stored in {%s}, but %s " \
1802
1770
                "can only be used for trees stored in the dirstate" \
1803
 
                % (self.source._revision_id, self.target, self.iter_changes)
 
1771
                % (self.source._revision_id, self.target, self._iter_changes)
1804
1772
        target_index = 0
1805
1773
        if self.source._revision_id == NULL_REVISION:
1806
1774
            source_index = None
1983
1951
                                                 path_utf8=old_path)
1984
1952
                    # update the source details variable to be the real
1985
1953
                    # 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))
1991
1954
                    source_details = old_entry[1][source_index]
1992
1955
                    source_minikind = source_details[0]
1993
1956
                else: