~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/workingtree.py

  • Committer: Vincent Ladeuil
  • Date: 2011-09-08 08:03:35 UTC
  • mfrom: (6123.1.14 +trunk)
  • mto: This revision was merged to the branch mainline in revision 6252.
  • Revision ID: v.ladeuil+lp@free.fr-20110908080335-ddel4ir5grz945xa
Merge into trunk

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.
257
224
            the working tree has been constructed from.
258
225
            """)
259
226
 
 
227
    def has_versioned_directories(self):
 
228
        """See `Tree.has_versioned_directories`."""
 
229
        return self._format.supports_versioned_directories
 
230
 
260
231
    def break_lock(self):
261
232
        """Break a lock if one is present from another instance.
262
233
 
1062
1033
            stream.write(bytes)
1063
1034
        finally:
1064
1035
            stream.close()
1065
 
        # TODO: update the hashcache here ?
1066
1036
 
1067
1037
    def extras(self):
1068
1038
        """Yield all unversioned files in this WorkingTree.
1576
1546
            last_rev = parent_trees[0][0]
1577
1547
        return nb_conflicts
1578
1548
 
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
1549
    def set_conflicts(self, arg):
1594
1550
        raise errors.UnsupportedOperation(self.set_conflicts, self)
1595
1551
 
1827
1783
            branch=branch, _control_files=_control_files, _internal=_internal,
1828
1784
            _format=_format, _bzrdir=_bzrdir)
1829
1785
 
 
1786
        self._detect_case_handling()
 
1787
 
1830
1788
        if _inventory is None:
1831
1789
            # This will be acquired on lock_read() or lock_write()
1832
1790
            self._inventory_is_modified = False
1851
1809
        self._inventory = inv
1852
1810
        self._inventory_is_modified = dirty
1853
1811
 
 
1812
    def _detect_case_handling(self):
 
1813
        wt_trans = self.bzrdir.get_workingtree_transport(None)
 
1814
        try:
 
1815
            wt_trans.stat(self._format.case_sensitive_filename)
 
1816
        except errors.NoSuchFile:
 
1817
            self.case_sensitive = True
 
1818
        else:
 
1819
            self.case_sensitive = False
 
1820
 
 
1821
        self._setup_directory_is_tree_reference()
 
1822
 
1854
1823
    def _serialize(self, inventory, out_file):
1855
1824
        xml5.serializer_v5.write_inventory(self._inventory, out_file,
1856
1825
            working=True)
2160
2129
            mode=self.bzrdir._get_file_mode())
2161
2130
        self._inventory_is_modified = False
2162
2131
 
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
2132
    def get_file_mtime(self, file_id, path=None):
2170
2133
        """See Tree.get_file_mtime."""
2171
2134
        if not path: