~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/mutabletree.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2008-09-26 05:47:03 UTC
  • mfrom: (3696.5.4 integration)
  • Revision ID: pqm@pqm.ubuntu.com-20080926054703-nxn5f1h7z7gvur96
(robertc) Improve the handling of the sha1 cache by updating it
        during commit and avoiding some of the sha generation during
        iter_changes. (Robert Collins)

Show diffs side-by-side

added added

removed removed

Lines of Context:
201
201
        """Helper function for add - sets the entries of kinds."""
202
202
        raise NotImplementedError(self._gather_kinds)
203
203
 
 
204
    def get_file_with_stat(self, file_id, path=None):
 
205
        """Get a file handle and stat object for file_id.
 
206
 
 
207
        The default implementation returns (self.get_file, None) for backwards
 
208
        compatibility.
 
209
 
 
210
        :param file_id: The file id to read.
 
211
        :param path: The path of the file, if it is known.
 
212
        :return: A tuple (file_handle, stat_value_or_None). If the tree has
 
213
            no stat facility, or need for a stat cache feedback during commit,
 
214
            it may return None for the second element of the tuple.
 
215
        """
 
216
        return (self.get_file(file_id, path), None)
 
217
 
204
218
    @needs_read_lock
205
219
    def last_revision(self):
206
220
        """Return the revision id of the last commit performed in this tree.
247
261
        """
248
262
        raise NotImplementedError(self.mkdir)
249
263
 
 
264
    def _observed_sha1(self, file_id, path, (sha1, stat_value)):
 
265
        """Tell the tree we have observed a paths sha1.
 
266
 
 
267
        The intent of this function is to allow trees that have a hashcache to
 
268
        update the hashcache during commit. If the observed file is too new
 
269
        (based on the stat_value) to be safely hash-cached the tree will ignore
 
270
        it. 
 
271
 
 
272
        The default implementation does nothing.
 
273
 
 
274
        :param file_id: The file id
 
275
        :param path: The file path
 
276
        :param sha1: The sha 1 that was observed.
 
277
        :param stat_value: A stat result for the file the sha1 was read from.
 
278
        :return: None
 
279
        """
 
280
 
250
281
    @needs_write_lock
251
282
    def put_file_bytes_non_atomic(self, file_id, bytes):
252
283
        """Update the content of a file in the tree.