~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/bundle/bundle_data.py

  • Committer: Ross Lagerwall
  • Date: 2012-08-07 06:32:51 UTC
  • mto: (6437.63.5 2.5)
  • mto: This revision was merged to the branch mainline in revision 6558.
  • Revision ID: rosslagerwall@gmail.com-20120807063251-x9p03ghg2ws8oqjc
Add bzrlib/locale to .bzrignore

bzrlib/locale is generated with ./setup.py build_mo which is in turn called
by ./setup.py build

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
 
 
582
579
    def path2id(self, path):
583
580
        """Return the id of the file present at path in the target tree."""
584
581
        file_id = self._new_id.get(path)
589
586
            return None
590
587
        if old_path in self.deleted:
591
588
            return None
592
 
        return self.base_tree.path2id(old_path)
 
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)
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.get_root_id()):
 
628
            base_id != self.base_tree.inventory.root.file_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.kind(file_id) == 'directory'):
 
635
                self.get_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 kind(self, file_id):
 
654
    def get_kind(self, file_id):
655
655
        if file_id in self._kinds:
656
656
            return self._kinds[file_id]
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)
 
657
        return self.base_tree.inventory[file_id].kind
665
658
 
666
659
    def is_executable(self, file_id):
667
660
        path = self.id2path(file_id)
668
661
        if path in self._executable:
669
662
            return self._executable[path]
670
663
        else:
671
 
            return self.base_tree.is_executable(file_id)
 
664
            return self.base_tree.inventory[file_id].executable
672
665
 
673
666
    def get_last_changed(self, file_id):
674
667
        path = self.id2path(file_id)
687
680
        if new_path not in self.patches:
688
681
            # If the entry does not have a patch, then the
689
682
            # contents must be the same as in the base_tree
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
 
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
693
687
        fileobj = self.get_file(file_id)
694
688
        content = fileobj.read()
695
689
        return len(content), sha_string(content)
700
694
        This need to be called before ever accessing self.inventory
701
695
        """
702
696
        from os.path import dirname, basename
 
697
        base_inv = self.base_tree.inventory
703
698
        inv = Inventory(None, self.revision_id)
704
699
 
705
700
        def add_entry(file_id):
712
707
                parent_path = dirname(path)
713
708
                parent_id = self.path2id(parent_path)
714
709
 
715
 
            kind = self.kind(file_id)
 
710
            kind = self.get_kind(file_id)
716
711
            revision_id = self.get_last_changed(file_id)
717
712
 
718
713
            name = basename(path)
746
741
    # at that instant
747
742
    inventory = property(_get_inventory)
748
743
 
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()])
 
744
    def __iter__(self):
 
745
        for path, entry in self.inventory.iter_entries():
 
746
            yield entry.file_id
754
747
 
755
748
    def list_files(self, include_root=False, from_dir=None, recursive=True):
756
749
        # The only files returned by this are those from the version