~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/inventory.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2008-06-05 04:05:05 UTC
  • mfrom: (3473.1.1 ianc-integration)
  • Revision ID: pqm@pqm.ubuntu.com-20080605040505-i9kqxg2fps2qjdi0
Add the 'alias' command (Tim Penhey)

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_in, deprecated_method
 
53
from bzrlib.symbol_versioning import 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)))
180
179
    def get_tar_item(self, root, dp, now, tree):
181
180
        """Get a tarfile item and a file stream for its content."""
182
181
        item = tarfile.TarInfo(osutils.pathjoin(root, dp).encode('utf8'))
239
238
        raise BzrError("don't know how to export {%s} of kind %r" %
240
239
                       (self.file_id, self.kind))
241
240
 
242
 
    @deprecated_method(deprecated_in((1, 6, 0)))
243
241
    def put_on_disk(self, dest, dp, tree):
244
242
        """Create a representation of self on disk in the prefix dest.
245
243
        
474
472
 
475
473
    def _check(self, checker, tree_revision_id, tree):
476
474
        """See InventoryEntry._check"""
477
 
        key = (self.file_id, self.revision)
478
 
        if key in checker.checked_texts:
479
 
            prev_sha = checker.checked_texts[key]
 
475
        t = (self.file_id, self.revision)
 
476
        if t in checker.checked_texts:
 
477
            prev_sha = checker.checked_texts[t]
480
478
            if prev_sha != self.text_sha1:
481
479
                raise BzrCheckError(
482
480
                    'mismatched sha1 on {%s} in {%s} (%s != %s) %r' %
486
484
                checker.repeated_text_cnt += 1
487
485
                return
488
486
 
 
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
 
489
498
        mutter('check version {%s} of {%s}', tree_revision_id, self.file_id)
490
499
        checker.checked_text_cnt += 1
491
500
        # We can't check the length, because Weave doesn't store that
492
501
        # information, and the whole point of looking at the weave's
493
502
        # sha1sum is that we don't have to extract the text.
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
 
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
497
507
 
498
508
    def copy(self):
499
509
        other = InventoryFile(self.file_id, self.name, self.parent_id)
815
825
                # adds come later
816
826
                continue
817
827
            # Preserve unaltered children of file_id for later reinsertion.
818
 
            file_id_children = getattr(self[file_id], 'children', {})
819
 
            if len(file_id_children):
820
 
                children[file_id] = file_id_children
 
828
            children[file_id] = getattr(self[file_id], 'children', {})
821
829
            # Remove file_id and the unaltered children. If file_id is not
822
830
            # being deleted it will be reinserted back later.
823
831
            self.remove_recursive_id(file_id)
829
837
        for new_path, new_entry in sorted((np, e) for op, np, f, e in
830
838
                                          delta if np is not None):
831
839
            if new_entry.kind == 'directory':
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, {})
 
840
                new_entry.children = children.get(new_entry.file_id, {})
836
841
            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
854
853
        # copy recursively so we know directories will be added before
855
854
        # their children.  There are more efficient ways than this...
856
855
        for path, entry in entries: