~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/workingtree.py

merge in trunk and i18n-errors

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,
194
193
        self.basedir = realpath(basedir)
195
194
        self._control_files = _control_files
196
195
        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()
218
196
        self._rules_searcher = None
219
197
        self.views = self._make_views()
220
198
 
238
216
        """
239
217
        return self.bzrdir.is_control_filename(filename)
240
218
 
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
 
 
252
219
    branch = property(
253
220
        fget=lambda self: self._branch,
254
221
        doc="""The branch this WorkingTree is connected to.
1062
1029
            stream.write(bytes)
1063
1030
        finally:
1064
1031
            stream.close()
1065
 
        # TODO: update the hashcache here ?
1066
1032
 
1067
1033
    def extras(self):
1068
1034
        """Yield all unversioned files in this WorkingTree.
1576
1542
            last_rev = parent_trees[0][0]
1577
1543
        return nb_conflicts
1578
1544
 
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
 
 
1593
1545
    def set_conflicts(self, arg):
1594
1546
        raise errors.UnsupportedOperation(self.set_conflicts, self)
1595
1547
 
1827
1779
            branch=branch, _control_files=_control_files, _internal=_internal,
1828
1780
            _format=_format, _bzrdir=_bzrdir)
1829
1781
 
 
1782
        self._detect_case_handling()
 
1783
 
1830
1784
        if _inventory is None:
1831
1785
            # This will be acquired on lock_read() or lock_write()
1832
1786
            self._inventory_is_modified = False
1851
1805
        self._inventory = inv
1852
1806
        self._inventory_is_modified = dirty
1853
1807
 
 
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
 
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: