~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/workingtree.py

Merge bzr.dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
55
55
    errors,
56
56
    generate_ids,
57
57
    globbing,
 
58
    hashcache,
58
59
    ignores,
59
60
    merge,
60
61
    osutils,
232
233
            self._set_inventory(wt._inventory, dirty=False)
233
234
            self._format = wt._format
234
235
            self.bzrdir = wt.bzrdir
235
 
        from bzrlib.hashcache import HashCache
236
 
        from bzrlib.trace import note, mutter
237
236
        assert isinstance(basedir, basestring), \
238
237
            "base directory %r is not a string" % basedir
239
238
        basedir = safe_unicode(basedir)
267
266
        # cache file, and have the parser take the most recent entry for a
268
267
        # given path only.
269
268
        cache_filename = self.bzrdir.get_workingtree_transport(None).local_abspath('stat-cache')
270
 
        hc = self._hashcache = HashCache(basedir, cache_filename, self._control_files._file_mode)
 
269
        self._hashcache = hashcache.HashCache(basedir, cache_filename,
 
270
                                              self._control_files._file_mode)
 
271
        hc = self._hashcache
271
272
        hc.read()
272
273
        # is this scan needed ? it makes things kinda slow.
273
274
        #hc.scan()
1698
1699
                                  this_tree=self)
1699
1700
        return result
1700
1701
 
 
1702
    def _write_hashcache_if_dirty(self):
 
1703
        """Write out the hashcache if it is dirty."""
 
1704
        if self._hashcache.needs_write:
 
1705
            try:
 
1706
                self._hashcache.write()
 
1707
            except OSError, e:
 
1708
                if e.errno not in (errno.EPERM, errno.EACCES):
 
1709
                    raise
 
1710
                # TODO: jam 20061219 Should this be a warning? A single line
 
1711
                #       warning might be sufficient to let the user know what
 
1712
                #       is going on.
 
1713
                mutter('Could not write hashcache for %s\nError: %s',
 
1714
                       self._hashcache.cache_file_name(), e)
 
1715
 
1701
1716
    @needs_tree_write_lock
1702
1717
    def _write_inventory(self, inv):
1703
1718
        """Write inventory as the current inventory."""
1764
1779
            # _inventory_is_modified is always False during a read lock.
1765
1780
            if self._inventory_is_modified:
1766
1781
                self.flush()
1767
 
            if self._hashcache.needs_write:
1768
 
                self._hashcache.write()
 
1782
            self._write_hashcache_if_dirty()
 
1783
                    
1769
1784
        # reverse order of locking.
1770
1785
        try:
1771
1786
            return self._control_files.unlock()
1833
1848
            # _inventory_is_modified is always False during a read lock.
1834
1849
            if self._inventory_is_modified:
1835
1850
                self.flush()
1836
 
            if self._hashcache.needs_write:
1837
 
                self._hashcache.write()
 
1851
            self._write_hashcache_if_dirty()
1838
1852
        # reverse order of locking.
1839
1853
        try:
1840
1854
            return self._control_files.unlock()