~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/workingtree.py

fix spacing

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,
57
58
    ignores,
58
59
    inventory,
59
60
    merge,
193
194
        self.basedir = realpath(basedir)
194
195
        self._control_files = _control_files
195
196
        self._transport = self._control_files._transport
 
197
        # update the whole cache up front and write to disk if anything changed;
 
198
        # in the future we might want to do this more selectively
 
199
        # two possible ways offer themselves : in self._unlock, write the cache
 
200
        # if needed, or, when the cache sees a change, append it to the hash
 
201
        # cache file, and have the parser take the most recent entry for a
 
202
        # given path only.
 
203
        wt_trans = self.bzrdir.get_workingtree_transport(None)
 
204
        cache_filename = wt_trans.local_abspath('stat-cache')
 
205
        self._hashcache = hashcache.HashCache(basedir, cache_filename,
 
206
            self.bzrdir._get_file_mode(),
 
207
            self._content_filter_stack_provider())
 
208
        hc = self._hashcache
 
209
        hc.read()
 
210
        # is this scan needed ? it makes things kinda slow.
 
211
        #hc.scan()
 
212
 
 
213
        if hc.needs_write:
 
214
            mutter("write hc")
 
215
            hc.write()
 
216
 
 
217
        self._detect_case_handling()
196
218
        self._rules_searcher = None
197
219
        self.views = self._make_views()
198
220
 
216
238
        """
217
239
        return self.bzrdir.is_control_filename(filename)
218
240
 
 
241
    def _detect_case_handling(self):
 
242
        wt_trans = self.bzrdir.get_workingtree_transport(None)
 
243
        try:
 
244
            wt_trans.stat(self._format.case_sensitive_filename)
 
245
        except errors.NoSuchFile:
 
246
            self.case_sensitive = True
 
247
        else:
 
248
            self.case_sensitive = False
 
249
 
 
250
        self._setup_directory_is_tree_reference()
 
251
 
219
252
    branch = property(
220
253
        fget=lambda self: self._branch,
221
254
        doc="""The branch this WorkingTree is connected to.
1029
1062
            stream.write(bytes)
1030
1063
        finally:
1031
1064
            stream.close()
 
1065
        # TODO: update the hashcache here ?
1032
1066
 
1033
1067
    def extras(self):
1034
1068
        """Yield all unversioned files in this WorkingTree.
1542
1576
            last_rev = parent_trees[0][0]
1543
1577
        return nb_conflicts
1544
1578
 
 
1579
    def _write_hashcache_if_dirty(self):
 
1580
        """Write out the hashcache if it is dirty."""
 
1581
        if self._hashcache.needs_write:
 
1582
            try:
 
1583
                self._hashcache.write()
 
1584
            except OSError, e:
 
1585
                if e.errno not in (errno.EPERM, errno.EACCES):
 
1586
                    raise
 
1587
                # TODO: jam 20061219 Should this be a warning? A single line
 
1588
                #       warning might be sufficient to let the user know what
 
1589
                #       is going on.
 
1590
                mutter('Could not write hashcache for %s\nError: %s',
 
1591
                              self._hashcache.cache_file_name(), e)
 
1592
 
1545
1593
    def set_conflicts(self, arg):
1546
1594
        raise errors.UnsupportedOperation(self.set_conflicts, self)
1547
1595
 
1779
1827
            branch=branch, _control_files=_control_files, _internal=_internal,
1780
1828
            _format=_format, _bzrdir=_bzrdir)
1781
1829
 
1782
 
        self._detect_case_handling()
1783
 
 
1784
1830
        if _inventory is None:
1785
1831
            # This will be acquired on lock_read() or lock_write()
1786
1832
            self._inventory_is_modified = False
1805
1851
        self._inventory = inv
1806
1852
        self._inventory_is_modified = dirty
1807
1853
 
1808
 
    def _detect_case_handling(self):
1809
 
        wt_trans = self.bzrdir.get_workingtree_transport(None)
1810
 
        try:
1811
 
            wt_trans.stat(self._format.case_sensitive_filename)
1812
 
        except errors.NoSuchFile:
1813
 
            self.case_sensitive = True
1814
 
        else:
1815
 
            self.case_sensitive = False
1816
 
 
1817
 
        self._setup_directory_is_tree_reference()
1818
 
 
1819
1854
    def _serialize(self, inventory, out_file):
1820
1855
        xml5.serializer_v5.write_inventory(self._inventory, out_file,
1821
1856
            working=True)
2125
2160
            mode=self.bzrdir._get_file_mode())
2126
2161
        self._inventory_is_modified = False
2127
2162
 
 
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
 
2128
2169
    def get_file_mtime(self, file_id, path=None):
2129
2170
        """See Tree.get_file_mtime."""
2130
2171
        if not path: