~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/bundle/bundle_data.py

  • Committer: Vincent Ladeuil
  • Date: 2012-02-14 17:22:37 UTC
  • mfrom: (6466 +trunk)
  • mto: This revision was merged to the branch mainline in revision 6468.
  • Revision ID: v.ladeuil+lp@free.fr-20120214172237-7dv7er3n4uy8d5m4
Merge trunk

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]
 
690
            ie = self.base_tree.root_inventory[file_id]
684
691
            if ie.text_size is None:
685
692
                return ie.text_size, ie.text_sha1
686
693
            return int(ie.text_size), ie.text_sha1
694
701
        This need to be called before ever accessing self.inventory
695
702
        """
696
703
        from os.path import dirname, basename
697
 
        base_inv = self.base_tree.inventory
 
704
        base_inv = self.base_tree.root_inventory
698
705
        inv = Inventory(None, self.revision_id)
699
706
 
700
707
        def add_entry(file_id):
707
714
                parent_path = dirname(path)
708
715
                parent_id = self.path2id(parent_path)
709
716
 
710
 
            kind = self.get_kind(file_id)
 
717
            kind = self.kind(file_id)
711
718
            revision_id = self.get_last_changed(file_id)
712
719
 
713
720
            name = basename(path)
741
748
    # at that instant
742
749
    inventory = property(_get_inventory)
743
750
 
 
751
    root_inventory = property(_get_inventory)
 
752
 
744
753
    def __iter__(self):
745
754
        for path, entry in self.inventory.iter_entries():
746
755
            yield entry.file_id