~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/inventory.py

  • Committer: Robert Collins
  • Date: 2005-10-07 06:13:14 UTC
  • mto: This revision was merged to the branch mainline in revision 1420.
  • Revision ID: robertc@robertcollins.net-20051007061313-9a835e979434e721
use transactions in the weave store interface, which enables caching for log

Show diffs side-by-side

added added

removed removed

Lines of Context:
114
114
                 'text_id', 'parent_id', 'children', 'executable', 
115
115
                 'revision']
116
116
 
117
 
    def _add_text_to_weave(self, new_lines, parents, weave_store):
118
 
        weave_store.add_text(self.file_id, self.revision, new_lines, parents)
 
117
    def _add_text_to_weave(self, new_lines, parents, weave_store, transaction):
 
118
        weave_store.add_text(self.file_id, self.revision, new_lines, parents,
 
119
                             transaction)
119
120
 
120
121
    def detect_changes(self, old_entry):
121
122
        """Return a (text_modified, meta_modified) from this to old_entry.
310
311
                   self.parent_id))
311
312
 
312
313
    def snapshot(self, revision, path, previous_entries,
313
 
                 work_tree, weave_store):
 
314
                 work_tree, weave_store, transaction):
314
315
        """Make a snapshot of this entry which may or may not have changed.
315
316
        
316
317
        This means that all its fields are populated, that it has its
326
327
                self.revision = parent_ie.revision
327
328
                return "unchanged"
328
329
        return self.snapshot_revision(revision, previous_entries, 
329
 
                                      work_tree, weave_store)
 
330
                                      work_tree, weave_store, transaction)
330
331
 
331
332
    def snapshot_revision(self, revision, previous_entries, work_tree,
332
 
                          weave_store):
 
333
                          weave_store, transaction):
333
334
        """Record this revision unconditionally."""
334
335
        mutter('new revision for {%s}', self.file_id)
335
336
        self.revision = revision
336
337
        change = self._get_snapshot_change(previous_entries)
337
 
        self._snapshot_text(previous_entries, work_tree, weave_store)
 
338
        self._snapshot_text(previous_entries, work_tree, weave_store,
 
339
                            transaction)
338
340
        return change
339
341
 
340
 
    def _snapshot_text(self, file_parents, work_tree, weave_store): 
 
342
    def _snapshot_text(self, file_parents, work_tree, weave_store, transaction): 
341
343
        """Record the 'text' of this entry, whatever form that takes.
342
344
        
343
345
        This default implementation simply adds an empty text.
344
346
        """
345
347
        mutter('storing file {%s} in revision {%s}',
346
348
               self.file_id, self.revision)
347
 
        self._add_text_to_weave([], file_parents, weave_store)
 
349
        self._add_text_to_weave([], file_parents, weave_store, transaction)
348
350
 
349
351
    def __eq__(self, other):
350
352
        if not isinstance(other, InventoryEntry):
539
541
        self.text_sha1 = work_tree.get_file_sha1(self.file_id)
540
542
        self.executable = work_tree.is_executable(self.file_id)
541
543
 
542
 
    def _snapshot_text(self, file_parents, work_tree, weave_store): 
 
544
    def _snapshot_text(self, file_parents, work_tree, weave_store, transaction):
543
545
        """See InventoryEntry._snapshot_text."""
544
546
        mutter('storing file {%s} in revision {%s}',
545
547
               self.file_id, self.revision)
551
553
            previous_ie = file_parents.values()[0]
552
554
            weave_store.add_identical_text(
553
555
                self.file_id, previous_ie.revision, 
554
 
                self.revision, file_parents)
 
556
                self.revision, file_parents, transaction)
555
557
        else:
556
558
            new_lines = work_tree.get_file(self.file_id).readlines()
557
 
            self._add_text_to_weave(new_lines, file_parents, weave_store)
 
559
            self._add_text_to_weave(new_lines, file_parents, weave_store,
 
560
                                    transaction)
558
561
            self.text_sha1 = sha_strings(new_lines)
559
562
            self.text_size = sum(map(len, new_lines))
560
563