~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/workingtree.py

  • Committer: Jelmer Vernooij
  • Date: 2011-08-30 09:29:03 UTC
  • mto: This revision was merged to the branch mainline in revision 6115.
  • Revision ID: jelmer@samba.org-20110830092903-981sb118z3ilvq7x
Move hashcache use to bzrlib.workingtree_3 and bzrlib.plugins.weave_fmt.workingtree.

Show diffs side-by-side

added added

removed removed

Lines of Context:
54
54
    generate_ids,
55
55
    globbing,
56
56
    graph as _mod_graph,
57
 
    hashcache,
58
57
    ignores,
59
58
    inventory,
60
59
    merge,
1030
1029
            stream.write(bytes)
1031
1030
        finally:
1032
1031
            stream.close()
1033
 
        # TODO: update the hashcache here ?
1034
1032
 
1035
1033
    def extras(self):
1036
1034
        """Yield all unversioned files in this WorkingTree.
1781
1779
            branch=branch, _control_files=_control_files, _internal=_internal,
1782
1780
            _format=_format, _bzrdir=_bzrdir)
1783
1781
 
1784
 
        # update the whole cache up front and write to disk if anything changed;
1785
 
        # in the future we might want to do this more selectively
1786
 
        # two possible ways offer themselves : in self._unlock, write the cache
1787
 
        # if needed, or, when the cache sees a change, append it to the hash
1788
 
        # cache file, and have the parser take the most recent entry for a
1789
 
        # given path only.
1790
 
        wt_trans = self.bzrdir.get_workingtree_transport(None)
1791
 
        cache_filename = wt_trans.local_abspath('stat-cache')
1792
 
        self._hashcache = hashcache.HashCache(basedir, cache_filename,
1793
 
            self.bzrdir._get_file_mode(),
1794
 
            self._content_filter_stack_provider())
1795
 
        hc = self._hashcache
1796
 
        hc.read()
1797
 
        # is this scan needed ? it makes things kinda slow.
1798
 
        #hc.scan()
1799
 
 
1800
 
        if hc.needs_write:
1801
 
            mutter("write hc")
1802
 
            hc.write()
1803
1782
        self._detect_case_handling()
1804
1783
 
1805
1784
        if _inventory is None:
1837
1816
 
1838
1817
        self._setup_directory_is_tree_reference()
1839
1818
 
1840
 
    def _write_hashcache_if_dirty(self):
1841
 
        """Write out the hashcache if it is dirty."""
1842
 
        if self._hashcache.needs_write:
1843
 
            try:
1844
 
                self._hashcache.write()
1845
 
            except OSError, e:
1846
 
                if e.errno not in (errno.EPERM, errno.EACCES):
1847
 
                    raise
1848
 
                # TODO: jam 20061219 Should this be a warning? A single line
1849
 
                #       warning might be sufficient to let the user know what
1850
 
                #       is going on.
1851
 
                mutter('Could not write hashcache for %s\nError: %s',
1852
 
                              self._hashcache.cache_file_name(), e)
1853
 
 
1854
1819
    def _serialize(self, inventory, out_file):
1855
1820
        xml5.serializer_v5.write_inventory(self._inventory, out_file,
1856
1821
            working=True)
2160
2125
            mode=self.bzrdir._get_file_mode())
2161
2126
        self._inventory_is_modified = False
2162
2127
 
2163
 
    @needs_read_lock
2164
 
    def get_file_sha1(self, file_id, path=None, stat_value=None):
2165
 
        if not path:
2166
 
            path = self._inventory.id2path(file_id)
2167
 
        return self._hashcache.get_sha1(path, stat_value)
2168
 
 
2169
2128
    def get_file_mtime(self, file_id, path=None):
2170
2129
        """See Tree.get_file_mtime."""
2171
2130
        if not path: