~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/bundle/bundle_data.py

MergeĀ lp:bzr.

Show diffs side-by-side

added added

removed removed

Lines of Context:
576
576
            return None
577
577
        return new_path
578
578
 
 
579
    def get_root_id(self):
 
580
        return self.path2id('')
 
581
 
579
582
    def path2id(self, path):
580
583
        """Return the id of the file present at path in the target tree."""
581
584
        file_id = self._new_id.get(path)
586
589
            return None
587
590
        if old_path in self.deleted:
588
591
            return None
589
 
        if getattr(self.base_tree, 'path2id', None) is not None:
590
 
            return self.base_tree.path2id(old_path)
591
 
        else:
592
 
            return self.base_tree.inventory.path2id(old_path)
 
592
        return self.base_tree.path2id(old_path)
593
593
 
594
594
    def id2path(self, file_id):
595
595
        """Return the new path in the target tree of the file with id file_id"""
625
625
        """
626
626
        base_id = self.old_contents_id(file_id)
627
627
        if (base_id is not None and
628
 
            base_id != self.base_tree.inventory.root.file_id):
 
628
            base_id != self.base_tree.get_root_id()):
629
629
            patch_original = self.base_tree.get_file(base_id)
630
630
        else:
631
631
            patch_original = None
632
632
        file_patch = self.patches.get(self.id2path(file_id))
633
633
        if file_patch is None:
634
634
            if (patch_original is None and
635
 
                self.get_kind(file_id) == 'directory'):
 
635
                self.kind(file_id) == 'directory'):
636
636
                return StringIO()
637
637
            if patch_original is None:
638
638
                raise AssertionError("None: %s" % file_id)
651
651
        except KeyError:
652
652
            return self.base_tree.get_symlink_target(file_id)
653
653
 
654
 
    def get_kind(self, file_id):
 
654
    def kind(self, file_id):
655
655
        if file_id in self._kinds:
656
656
            return self._kinds[file_id]
657
 
        return self.base_tree.inventory[file_id].kind
 
657
        return self.base_tree.kind(file_id)
 
658
 
 
659
    def get_file_revision(self, file_id):
 
660
        path = self.id2path(file_id)
 
661
        if path in self._last_changed:
 
662
            return self._last_changed[path]
 
663
        else:
 
664
            return self.base_tree.get_file_revision(file_id)
658
665
 
659
666
    def is_executable(self, file_id):
660
667
        path = self.id2path(file_id)
661
668
        if path in self._executable:
662
669
            return self._executable[path]
663
670
        else:
664
 
            return self.base_tree.inventory[file_id].executable
 
671
            return self.base_tree.is_executable(file_id)
665
672
 
666
673
    def get_last_changed(self, file_id):
667
674
        path = self.id2path(file_id)
680
687
        if new_path not in self.patches:
681
688
            # If the entry does not have a patch, then the
682
689
            # contents must be the same as in the base_tree
683
 
            ie = self.base_tree.inventory[file_id]
684
 
            if ie.text_size is None:
685
 
                return ie.text_size, ie.text_sha1
686
 
            return int(ie.text_size), ie.text_sha1
 
690
            text_size = self.base_tree.get_file_size(file_id)
 
691
            text_sha1 = self.base_tree.get_file_sha1(file_id)
 
692
            return text_size, text_sha1
687
693
        fileobj = self.get_file(file_id)
688
694
        content = fileobj.read()
689
695
        return len(content), sha_string(content)
694
700
        This need to be called before ever accessing self.inventory
695
701
        """
696
702
        from os.path import dirname, basename
697
 
        base_inv = self.base_tree.inventory
698
703
        inv = Inventory(None, self.revision_id)
699
704
 
700
705
        def add_entry(file_id):
707
712
                parent_path = dirname(path)
708
713
                parent_id = self.path2id(parent_path)
709
714
 
710
 
            kind = self.get_kind(file_id)
 
715
            kind = self.kind(file_id)
711
716
            revision_id = self.get_last_changed(file_id)
712
717
 
713
718
            name = basename(path)
741
746
    # at that instant
742
747
    inventory = property(_get_inventory)
743
748
 
744
 
    def __iter__(self):
745
 
        for path, entry in self.inventory.iter_entries():
746
 
            yield entry.file_id
 
749
    root_inventory = property(_get_inventory)
 
750
 
 
751
    def all_file_ids(self):
 
752
        return set(
 
753
            [entry.file_id for path, entry in self.inventory.iter_entries()])
747
754
 
748
755
    def list_files(self, include_root=False, from_dir=None, recursive=True):
749
756
        # The only files returned by this are those from the version