/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to breezy/bundle/bundle_data.py

  • Committer: Breezy landing bot
  • Author(s): Jelmer Vernooij
  • Date: 2018-11-16 15:19:49 UTC
  • mfrom: (7141.7.6 no-file-ids)
  • Revision ID: breezy.the.bot@gmail.com-20181116151949-hrmuv6s7ow1cqdhi
Drop file_id argument from read functions in Tree.

Merged from https://code.launchpad.net/~jelmer/brz/no-file-ids/+merge/357984

Show diffs side-by-side

added added

removed removed

Lines of Context:
616
616
        new_path = self.id2path(file_id)
617
617
        return self.base_tree.path2id(new_path)
618
618
 
619
 
    def get_file(self, path, file_id=None):
 
619
    def get_file(self, path):
620
620
        """Return a file-like object containing the new contents of the
621
621
        file given by file_id.
622
622
 
624
624
                in the text-store, so that the file contents would
625
625
                then be cached.
626
626
        """
627
 
        if file_id is None:
628
 
            file_id = self.path2id(path)
 
627
        file_id = self.path2id(path)
629
628
        base_id = self.old_contents_id(file_id)
630
629
        if (base_id is not None and
631
630
            base_id != self.base_tree.get_root_id()):
632
 
            old_path = self.old_path(path)
633
 
            patch_original = self.base_tree.get_file(
634
 
                    old_path, base_id)
 
631
            old_path = self.base_tree.id2path(base_id)
 
632
            patch_original = self.base_tree.get_file(old_path)
635
633
        else:
636
634
            patch_original = None
637
635
        file_patch = self.patches.get(path)
638
636
        if file_patch is None:
639
637
            if (patch_original is None and
640
 
                self.kind(path, file_id) == 'directory'):
 
638
                self.kind(path) == 'directory'):
641
639
                return BytesIO()
642
640
            if patch_original is None:
643
641
                raise AssertionError("None: %s" % file_id)
648
646
                'Malformed patch for %s, %r' % (file_id, file_patch))
649
647
        return patched_file(file_patch, patch_original)
650
648
 
651
 
    def get_symlink_target(self, path, file_id=None):
 
649
    def get_symlink_target(self, path):
652
650
        try:
653
651
            return self._targets[path]
654
652
        except KeyError:
655
653
            old_path = self.old_path(path)
656
 
            return self.base_tree.get_symlink_target(old_path, file_id)
 
654
            return self.base_tree.get_symlink_target(old_path)
657
655
 
658
 
    def kind(self, path, file_id=None):
 
656
    def kind(self, path):
659
657
        try:
660
658
            return self._kinds[path]
661
659
        except KeyError:
662
660
            old_path = self.old_path(path)
663
 
            return self.base_tree.kind(old_path, file_id)
 
661
            return self.base_tree.kind(old_path)
664
662
 
665
 
    def get_file_revision(self, path, file_id=None):
 
663
    def get_file_revision(self, path):
666
664
        if path in self._last_changed:
667
665
            return self._last_changed[path]
668
666
        else:
669
667
            old_path = self.old_path(path)
670
 
            return self.base_tree.get_file_revision(old_path, file_id)
 
668
            return self.base_tree.get_file_revision(old_path)
671
669
 
672
 
    def is_executable(self, path, file_id=None):
 
670
    def is_executable(self, path):
673
671
        if path in self._executable:
674
672
            return self._executable[path]
675
673
        else:
676
674
            old_path = self.old_path(path)
677
 
            return self.base_tree.is_executable(old_path, file_id)
 
675
            return self.base_tree.is_executable(old_path)
678
676
 
679
 
    def get_last_changed(self, path, file_id=None):
 
677
    def get_last_changed(self, path):
680
678
        if path in self._last_changed:
681
679
            return self._last_changed[path]
682
680
        old_path = self.old_path(path)
683
 
        return self.base_tree.get_file_revision(old_path, file_id)
 
681
        return self.base_tree.get_file_revision(old_path)
684
682
 
685
683
    def get_size_and_sha1(self, new_path, file_id=None):
686
684
        """Return the size and sha1 hash of the given file id.
693
691
            # If the entry does not have a patch, then the
694
692
            # contents must be the same as in the base_tree
695
693
            base_path = self.old_path(new_path)
696
 
            text_size = self.base_tree.get_file_size(base_path, file_id)
697
 
            text_sha1 = self.base_tree.get_file_sha1(base_path, file_id)
 
694
            text_size = self.base_tree.get_file_size(base_path)
 
695
            text_sha1 = self.base_tree.get_file_sha1(base_path)
698
696
            return text_size, text_sha1
699
 
        fileobj = self.get_file(new_path, file_id)
 
697
        fileobj = self.get_file(new_path)
700
698
        content = fileobj.read()
701
699
        return len(content), sha_string(content)
702
700
 
715
713
                parent_path = dirname(path)
716
714
                parent_id = self.path2id(parent_path)
717
715
 
718
 
            kind = self.kind(path, file_id)
719
 
            revision_id = self.get_last_changed(path, file_id)
 
716
            kind = self.kind(path)
 
717
            revision_id = self.get_last_changed(path)
720
718
 
721
719
            name = basename(path)
722
720
            if kind == 'directory':
723
721
                ie = InventoryDirectory(file_id, name, parent_id)
724
722
            elif kind == 'file':
725
723
                ie = InventoryFile(file_id, name, parent_id)
726
 
                ie.executable = self.is_executable(path, file_id)
 
724
                ie.executable = self.is_executable(path)
727
725
            elif kind == 'symlink':
728
726
                ie = InventoryLink(file_id, name, parent_id)
729
 
                ie.symlink_target = self.get_symlink_target(path, file_id)
 
727
                ie.symlink_target = self.get_symlink_target(path)
730
728
            ie.revision = revision_id
731
729
 
732
730
            if kind == 'file':
733
 
                ie.text_size, ie.text_sha1 = self.get_size_and_sha1(
734
 
                        path, file_id)
 
731
                ie.text_size, ie.text_sha1 = self.get_size_and_sha1(path)
735
732
                if ie.text_size is None:
736
733
                    raise BzrError(
737
734
                        'Got a text_size of None for file_id %r' % file_id)