~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/workingtree_4.py

Merge with preview-changed

Show diffs side-by-side

added added

removed removed

Lines of Context:
528
528
        return iter(result)
529
529
 
530
530
    def iter_references(self):
 
531
        if not self._repo_supports_tree_reference:
 
532
            # When the repo doesn't support references, we will have nothing to
 
533
            # return
 
534
            return
531
535
        for key, tree_details in self.current_dirstate()._iter_entries():
532
536
            if tree_details[0][0] in ('a', 'r'): # absent, relocated
533
537
                # not relevant to the working tree
535
539
            if not key[1]:
536
540
                # the root is not a reference.
537
541
                continue
538
 
            path = pathjoin(self.basedir, key[0].decode('utf8'), key[1].decode('utf8'))
 
542
            relpath = pathjoin(key[0].decode('utf8'), key[1].decode('utf8'))
539
543
            try:
540
 
                if self._kind(path) == 'tree-reference':
541
 
                    yield path, key[2]
 
544
                if self._kind(relpath) == 'tree-reference':
 
545
                    yield relpath, key[2]
542
546
            except errors.NoSuchFile:
543
547
                # path is missing on disk.
544
548
                continue
1415
1419
        self._inventory = None
1416
1420
        self._locked = 0
1417
1421
        self._dirstate_locked = False
 
1422
        self._repo_supports_tree_reference = getattr(
 
1423
            repository._format, "supports_tree_reference",
 
1424
            False)
1418
1425
 
1419
1426
    def __repr__(self):
1420
1427
        return "<%s of %s in %s>" % \
1459
1466
        path_utf8 = osutils.pathjoin(entry[0][0], entry[0][1])
1460
1467
        return path_utf8.decode('utf8')
1461
1468
 
 
1469
    def iter_references(self):
 
1470
        if not self._repo_supports_tree_reference:
 
1471
            # When the repo doesn't support references, we will have nothing to
 
1472
            # return
 
1473
            return iter([])
 
1474
        # Otherwise, fall back to the default implementation
 
1475
        return super(DirStateRevisionTree, self).iter_references()
 
1476
 
1462
1477
    def _get_parent_index(self):
1463
1478
        """Return the index in the dirstate referenced by this tree."""
1464
1479
        return self._dirstate.get_parent_ids().index(self._revision_id) + 1
1725
1740
                self._dirstate_locked = False
1726
1741
            self._repository.unlock()
1727
1742
 
 
1743
    @needs_read_lock
 
1744
    def supports_tree_reference(self):
 
1745
        return self._repo_supports_tree_reference
 
1746
 
1728
1747
    def walkdirs(self, prefix=""):
1729
1748
        # TODO: jam 20070215 This is the lazy way by using the RevisionTree
1730
1749
        # implementation based on an inventory.