~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/workingtree.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2011-05-13 15:37:47 UTC
  • mfrom: (5850.1.6 check)
  • Revision ID: pqm@pqm.ubuntu.com-20110513153747-aw3d2lsjyk40bp9q
(jelmer) Split versioned-file specific bits out Check into
 VersionedFileCheck. (Jelmer Vernooij)

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
 
1785
1775
        self.set_conflicts(un_resolved)
1786
1776
        return un_resolved, resolved
1787
1777
 
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
1778
    def _validate(self):
1808
1779
        """Validate internal structures.
1809
1780
 
1815
1786
        """
1816
1787
        return
1817
1788
 
1818
 
    @needs_read_lock
1819
1789
    def check_state(self):
1820
1790
        """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)
 
1791
        raise NotImplementedError(self.check_state)
1828
1792
 
1829
1793
    def reset_state(self, revision_ids=None):
1830
1794
        """Reset the state of the working tree.
2139
2103
        if self._change_last_revision(new_revision):
2140
2104
            self._cache_basis_inventory(new_revision)
2141
2105
 
 
2106
    def _get_check_refs(self):
 
2107
        """Return the references needed to perform a check of this tree.
 
2108
        
 
2109
        The default implementation returns no refs, and is only suitable for
 
2110
        trees that have no local caching and can commit on ghosts at any time.
 
2111
 
 
2112
        :seealso: bzrlib.check for details about check_refs.
 
2113
        """
 
2114
        return []
 
2115
 
 
2116
    @needs_read_lock
 
2117
    def _check(self, references):
 
2118
        """Check the tree for consistency.
 
2119
 
 
2120
        :param references: A dict with keys matching the items returned by
 
2121
            self._get_check_refs(), and values from looking those keys up in
 
2122
            the repository.
 
2123
        """
 
2124
        tree_basis = self.basis_tree()
 
2125
        tree_basis.lock_read()
 
2126
        try:
 
2127
            repo_basis = references[('trees', self.last_revision())]
 
2128
            if len(list(repo_basis.iter_changes(tree_basis))) > 0:
 
2129
                raise errors.BzrCheckError(
 
2130
                    "Mismatched basis inventory content.")
 
2131
            self._validate()
 
2132
        finally:
 
2133
            tree_basis.unlock()
 
2134
 
 
2135
    @needs_read_lock
 
2136
    def check_state(self):
 
2137
        """Check that the working state is/isn't valid."""
 
2138
        check_refs = self._get_check_refs()
 
2139
        refs = {}
 
2140
        for ref in check_refs:
 
2141
            kind, value = ref
 
2142
            if kind == 'trees':
 
2143
                refs[ref] = self.branch.repository.revision_tree(value)
 
2144
        self._check(refs)
 
2145
 
2142
2146
    @needs_tree_write_lock
2143
2147
    def reset_state(self, revision_ids=None):
2144
2148
        """Reset the state of the working tree.