~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/inventory.py

  • Committer: John Arbash Meinel
  • Date: 2008-10-30 00:55:00 UTC
  • mto: (3815.2.5 prepare-1.9)
  • mto: This revision was merged to the branch mainline in revision 3811.
  • Revision ID: john@arbash-meinel.com-20081030005500-r5cej1cxflqhs3io
Switch so that we are using a simple timestamp as the first action.

Show diffs side-by-side

added added

removed removed

Lines of Context:
50
50
    BzrCheckError,
51
51
    BzrError,
52
52
    )
53
 
from bzrlib.symbol_versioning import deprecated_method
 
53
from bzrlib.symbol_versioning import deprecated_in, deprecated_method
54
54
from bzrlib.trace import mutter
55
55
 
56
56
 
176
176
                    candidates[ie.revision] = ie
177
177
        return candidates
178
178
 
 
179
    @deprecated_method(deprecated_in((1, 6, 0)))
179
180
    def get_tar_item(self, root, dp, now, tree):
180
181
        """Get a tarfile item and a file stream for its content."""
181
182
        item = tarfile.TarInfo(osutils.pathjoin(root, dp).encode('utf8'))
238
239
        raise BzrError("don't know how to export {%s} of kind %r" %
239
240
                       (self.file_id, self.kind))
240
241
 
 
242
    @deprecated_method(deprecated_in((1, 6, 0)))
241
243
    def put_on_disk(self, dest, dp, tree):
242
244
        """Create a representation of self on disk in the prefix dest.
243
245
        
472
474
 
473
475
    def _check(self, checker, tree_revision_id, tree):
474
476
        """See InventoryEntry._check"""
475
 
        t = (self.file_id, self.revision)
476
 
        if t in checker.checked_texts:
477
 
            prev_sha = checker.checked_texts[t]
 
477
        key = (self.file_id, self.revision)
 
478
        if key in checker.checked_texts:
 
479
            prev_sha = checker.checked_texts[key]
478
480
            if prev_sha != self.text_sha1:
479
481
                raise BzrCheckError(
480
482
                    'mismatched sha1 on {%s} in {%s} (%s != %s) %r' %
484
486
                checker.repeated_text_cnt += 1
485
487
                return
486
488
 
487
 
        if self.file_id not in checker.checked_weaves:
488
 
            mutter('check weave {%s}', self.file_id)
489
 
            w = tree._get_weave(self.file_id)
490
 
            # Not passing a progress bar, because it creates a new
491
 
            # progress, which overwrites the current progress,
492
 
            # and doesn't look nice
493
 
            w.check()
494
 
            checker.checked_weaves[self.file_id] = True
495
 
        else:
496
 
            w = tree._get_weave(self.file_id)
497
 
 
498
489
        mutter('check version {%s} of {%s}', tree_revision_id, self.file_id)
499
490
        checker.checked_text_cnt += 1
500
491
        # We can't check the length, because Weave doesn't store that
501
492
        # information, and the whole point of looking at the weave's
502
493
        # sha1sum is that we don't have to extract the text.
503
 
        if self.text_sha1 != w.get_sha1s([self.revision])[0]:
504
 
            raise BzrCheckError('text {%s} version {%s} wrong sha1' 
505
 
                                % (self.file_id, self.revision))
506
 
        checker.checked_texts[t] = self.text_sha1
 
494
        if (self.text_sha1 != tree._repository.texts.get_sha1s([key])[key]):
 
495
            raise BzrCheckError('text {%s} version {%s} wrong sha1' % key)
 
496
        checker.checked_texts[key] = self.text_sha1
507
497
 
508
498
    def copy(self):
509
499
        other = InventoryFile(self.file_id, self.name, self.parent_id)
825
815
                # adds come later
826
816
                continue
827
817
            # Preserve unaltered children of file_id for later reinsertion.
828
 
            children[file_id] = getattr(self[file_id], 'children', {})
 
818
            file_id_children = getattr(self[file_id], 'children', {})
 
819
            if len(file_id_children):
 
820
                children[file_id] = file_id_children
829
821
            # Remove file_id and the unaltered children. If file_id is not
830
822
            # being deleted it will be reinserted back later.
831
823
            self.remove_recursive_id(file_id)
837
829
        for new_path, new_entry in sorted((np, e) for op, np, f, e in
838
830
                                          delta if np is not None):
839
831
            if new_entry.kind == 'directory':
840
 
                new_entry.children = children.get(new_entry.file_id, {})
 
832
                # Pop the child which to allow detection of children whose
 
833
                # parents were deleted and which were not reattached to a new
 
834
                # parent.
 
835
                new_entry.children = children.pop(new_entry.file_id, {})
841
836
            self.add(new_entry)
 
837
        if len(children):
 
838
            # Get the parent id that was deleted
 
839
            parent_id, children = children.popitem()
 
840
            raise errors.InconsistentDelta("<deleted>", parent_id,
 
841
                "The file id was deleted but its children were not deleted.")
842
842
 
843
843
    def _set_root(self, ie):
844
844
        self.root = ie
850
850
        if self.root is None:
851
851
            return Inventory(root_id=None)
852
852
        other = Inventory(entries.next()[1].file_id)
 
853
        other.root.revision = self.root.revision
853
854
        # copy recursively so we know directories will be added before
854
855
        # their children.  There are more efficient ways than this...
855
856
        for path, entry in entries: