~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/inventory.py

[merge] from robert and newformat

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.
165
166
                ie = inv[self.file_id]
166
167
                assert ie.file_id == self.file_id
167
168
                if ie.revision in heads:
 
169
                    # fixup logic, there was a bug in revision updates.
 
170
                    # with x bit support.
 
171
                    try:
 
172
                        if heads[ie.revision].executable != ie.executable:
 
173
                            heads[ie.revision].executable = False
 
174
                            ie.executable = False
 
175
                    except AttributeError:
 
176
                        pass
168
177
                    assert heads[ie.revision] == ie
169
178
                else:
170
179
                    # may want to add it.
310
319
                   self.parent_id))
311
320
 
312
321
    def snapshot(self, revision, path, previous_entries,
313
 
                 work_tree, weave_store):
 
322
                 work_tree, weave_store, transaction):
314
323
        """Make a snapshot of this entry which may or may not have changed.
315
324
        
316
325
        This means that all its fields are populated, that it has its
326
335
                self.revision = parent_ie.revision
327
336
                return "unchanged"
328
337
        return self.snapshot_revision(revision, previous_entries, 
329
 
                                      work_tree, weave_store)
 
338
                                      work_tree, weave_store, transaction)
330
339
 
331
340
    def snapshot_revision(self, revision, previous_entries, work_tree,
332
 
                          weave_store):
 
341
                          weave_store, transaction):
333
342
        """Record this revision unconditionally."""
334
343
        mutter('new revision for {%s}', self.file_id)
335
344
        self.revision = revision
336
345
        change = self._get_snapshot_change(previous_entries)
337
 
        self._snapshot_text(previous_entries, work_tree, weave_store)
 
346
        self._snapshot_text(previous_entries, work_tree, weave_store,
 
347
                            transaction)
338
348
        return change
339
349
 
340
 
    def _snapshot_text(self, file_parents, work_tree, weave_store): 
 
350
    def _snapshot_text(self, file_parents, work_tree, weave_store, transaction): 
341
351
        """Record the 'text' of this entry, whatever form that takes.
342
352
        
343
353
        This default implementation simply adds an empty text.
344
354
        """
345
355
        mutter('storing file {%s} in revision {%s}',
346
356
               self.file_id, self.revision)
347
 
        self._add_text_to_weave([], file_parents, weave_store)
 
357
        self._add_text_to_weave([], file_parents, weave_store, transaction)
348
358
 
349
359
    def __eq__(self, other):
350
360
        if not isinstance(other, InventoryEntry):
539
549
        self.text_sha1 = work_tree.get_file_sha1(self.file_id)
540
550
        self.executable = work_tree.is_executable(self.file_id)
541
551
 
542
 
    def _snapshot_text(self, file_parents, work_tree, weave_store): 
 
552
    def _snapshot_text(self, file_parents, work_tree, weave_store, transaction):
543
553
        """See InventoryEntry._snapshot_text."""
544
554
        mutter('storing file {%s} in revision {%s}',
545
555
               self.file_id, self.revision)
551
561
            previous_ie = file_parents.values()[0]
552
562
            weave_store.add_identical_text(
553
563
                self.file_id, previous_ie.revision, 
554
 
                self.revision, file_parents)
 
564
                self.revision, file_parents, transaction)
555
565
        else:
556
566
            new_lines = work_tree.get_file(self.file_id).readlines()
557
 
            self._add_text_to_weave(new_lines, file_parents, weave_store)
 
567
            self._add_text_to_weave(new_lines, file_parents, weave_store,
 
568
                                    transaction)
558
569
            self.text_sha1 = sha_strings(new_lines)
559
570
            self.text_size = sum(map(len, new_lines))
560
571
 
568
579
            # FIXME: 20050930 probe for the text size when getting sha1
569
580
            # in _read_tree_state
570
581
            self.text_size = previous_ie.text_size
 
582
        if self.executable != previous_ie.executable:
 
583
            compatible = False
571
584
        return compatible
572
585
 
573
586