~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/workingtree.py

  • Committer: Jelmer Vernooij
  • Date: 2011-05-14 21:16:04 UTC
  • mfrom: (5861 +trunk)
  • mto: This revision was merged to the branch mainline in revision 5863.
  • Revision ID: jelmer@samba.org-20110514211604-cxcvynog8js68qlx
Merge bzr.dev.

Show diffs side-by-side

added added

removed removed

Lines of Context:
268
268
        self._control_files.break_lock()
269
269
        self.branch.break_lock()
270
270
 
271
 
    def _get_check_refs(self):
272
 
        """Return the references needed to perform a check of this tree.
273
 
        
274
 
        The default implementation returns no refs, and is only suitable for
275
 
        trees that have no local caching and can commit on ghosts at any time.
276
 
 
277
 
        :seealso: bzrlib.check for details about check_refs.
278
 
        """
279
 
        return []
280
 
 
281
271
    def requires_rich_root(self):
282
272
        return self._format.requires_rich_root
283
273
 
873
863
        self.add(path, file_id, 'directory')
874
864
        return file_id
875
865
 
876
 
    def get_symlink_target(self, file_id):
877
 
        abspath = self.id2abspath(file_id)
 
866
    def get_symlink_target(self, file_id, path=None):
 
867
        if path is not None:
 
868
            abspath = self.abspath(path)
 
869
        else:
 
870
            abspath = self.id2abspath(file_id)
878
871
        target = osutils.readlink(abspath)
879
872
        return target
880
873
 
1785
1778
        self.set_conflicts(un_resolved)
1786
1779
        return un_resolved, resolved
1787
1780
 
1788
 
    @needs_read_lock
1789
 
    def _check(self, references):
1790
 
        """Check the tree for consistency.
1791
 
 
1792
 
        :param references: A dict with keys matching the items returned by
1793
 
            self._get_check_refs(), and values from looking those keys up in
1794
 
            the repository.
1795
 
        """
1796
 
        tree_basis = self.basis_tree()
1797
 
        tree_basis.lock_read()
1798
 
        try:
1799
 
            repo_basis = references[('trees', self.last_revision())]
1800
 
            if len(list(repo_basis.iter_changes(tree_basis))) > 0:
1801
 
                raise errors.BzrCheckError(
1802
 
                    "Mismatched basis inventory content.")
1803
 
            self._validate()
1804
 
        finally:
1805
 
            tree_basis.unlock()
1806
 
 
1807
1781
    def _validate(self):
1808
1782
        """Validate internal structures.
1809
1783
 
1815
1789
        """
1816
1790
        return
1817
1791
 
1818
 
    @needs_read_lock
1819
1792
    def check_state(self):
1820
1793
        """Check that the working state is/isn't valid."""
1821
 
        check_refs = self._get_check_refs()
1822
 
        refs = {}
1823
 
        for ref in check_refs:
1824
 
            kind, value = ref
1825
 
            if kind == 'trees':
1826
 
                refs[ref] = self.branch.repository.revision_tree(value)
1827
 
        self._check(refs)
 
1794
        raise NotImplementedError(self.check_state)
1828
1795
 
1829
1796
    def reset_state(self, revision_ids=None):
1830
1797
        """Reset the state of the working tree.
2139
2106
        if self._change_last_revision(new_revision):
2140
2107
            self._cache_basis_inventory(new_revision)
2141
2108
 
 
2109
    def _get_check_refs(self):
 
2110
        """Return the references needed to perform a check of this tree.
 
2111
        
 
2112
        The default implementation returns no refs, and is only suitable for
 
2113
        trees that have no local caching and can commit on ghosts at any time.
 
2114
 
 
2115
        :seealso: bzrlib.check for details about check_refs.
 
2116
        """
 
2117
        return []
 
2118
 
 
2119
    @needs_read_lock
 
2120
    def _check(self, references):
 
2121
        """Check the tree for consistency.
 
2122
 
 
2123
        :param references: A dict with keys matching the items returned by
 
2124
            self._get_check_refs(), and values from looking those keys up in
 
2125
            the repository.
 
2126
        """
 
2127
        tree_basis = self.basis_tree()
 
2128
        tree_basis.lock_read()
 
2129
        try:
 
2130
            repo_basis = references[('trees', self.last_revision())]
 
2131
            if len(list(repo_basis.iter_changes(tree_basis))) > 0:
 
2132
                raise errors.BzrCheckError(
 
2133
                    "Mismatched basis inventory content.")
 
2134
            self._validate()
 
2135
        finally:
 
2136
            tree_basis.unlock()
 
2137
 
 
2138
    @needs_read_lock
 
2139
    def check_state(self):
 
2140
        """Check that the working state is/isn't valid."""
 
2141
        check_refs = self._get_check_refs()
 
2142
        refs = {}
 
2143
        for ref in check_refs:
 
2144
            kind, value = ref
 
2145
            if kind == 'trees':
 
2146
                refs[ref] = self.branch.repository.revision_tree(value)
 
2147
        self._check(refs)
 
2148
 
2142
2149
    @needs_tree_write_lock
2143
2150
    def reset_state(self, revision_ids=None):
2144
2151
        """Reset the state of the working tree.