17
17
"""Weave-era working tree objects."""
19
19
from cStringIO import StringIO
21
22
from bzrlib import (
22
23
conflicts as _mod_conflicts,
26
28
revision as _mod_revision,
143
146
- uses the branch last-revision.
146
def __init__(self, *args, **kwargs):
147
super(WorkingTree2, self).__init__(*args, **kwargs)
149
def __init__(self, basedir, *args, **kwargs):
150
super(WorkingTree2, self).__init__(basedir, *args, **kwargs)
152
# update the whole cache up front and write to disk if anything changed;
153
# in the future we might want to do this more selectively
154
# two possible ways offer themselves : in self._unlock, write the cache
155
# if needed, or, when the cache sees a change, append it to the hash
156
# cache file, and have the parser take the most recent entry for a
158
wt_trans = self.bzrdir.get_workingtree_transport(None)
159
cache_filename = wt_trans.local_abspath('stat-cache')
160
self._hashcache = hashcache.HashCache(basedir, cache_filename,
161
self.bzrdir._get_file_mode(),
162
self._content_filter_stack_provider())
165
# is this scan needed ? it makes things kinda slow.
169
trace.mutter("write hc")
148
172
# WorkingTree2 has more of a constraint that self._inventory must
149
173
# exist. Because this is an older format, we don't mind the overhead
150
174
# caused by the extra computation here.
158
182
"""Return the references needed to perform a check of this tree."""
159
183
return [('trees', self.last_revision())]
187
def get_file_sha1(self, file_id, path=None, stat_value=None):
189
path = self._inventory.id2path(file_id)
190
return self._hashcache.get_sha1(path, stat_value)
161
192
def lock_tree_write(self):
162
193
"""See WorkingTree.lock_tree_write().
175
206
self.branch.unlock()
209
def _write_hashcache_if_dirty(self):
210
"""Write out the hashcache if it is dirty."""
211
if self._hashcache.needs_write:
213
self._hashcache.write()
215
if e.errno not in (errno.EPERM, errno.EACCES):
217
# TODO: jam 20061219 Should this be a warning? A single line
218
# warning might be sufficient to let the user know what
220
trace.mutter('Could not write hashcache for %s\nError: %s',
221
self._hashcache.cache_file_name(), e)
178
223
def unlock(self):
179
224
# we share control files:
180
225
if self._control_files._lock_count == 3: