~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/bundle/bundle_data.py

  • Committer: Samuel Bronson
  • Date: 2012-08-30 20:36:18 UTC
  • mto: (6015.57.3 2.4)
  • mto: This revision was merged to the branch mainline in revision 6558.
  • Revision ID: naesten@gmail.com-20120830203618-y2dzw91nqpvpgxvx
Update INSTALL for switch to Python 2.6 and up.

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
 
17
17
"""Read in a bundle stream, and process it into a BundleReader object."""
18
18
 
19
 
from __future__ import absolute_import
20
 
 
21
19
import base64
22
20
from cStringIO import StringIO
23
21
import os
576
574
            return None
577
575
        return new_path
578
576
 
579
 
    def get_root_id(self):
580
 
        return self.path2id('')
581
 
 
582
577
    def path2id(self, path):
583
578
        """Return the id of the file present at path in the target tree."""
584
579
        file_id = self._new_id.get(path)
589
584
            return None
590
585
        if old_path in self.deleted:
591
586
            return None
592
 
        return self.base_tree.path2id(old_path)
 
587
        if getattr(self.base_tree, 'path2id', None) is not None:
 
588
            return self.base_tree.path2id(old_path)
 
589
        else:
 
590
            return self.base_tree.inventory.path2id(old_path)
593
591
 
594
592
    def id2path(self, file_id):
595
593
        """Return the new path in the target tree of the file with id file_id"""
625
623
        """
626
624
        base_id = self.old_contents_id(file_id)
627
625
        if (base_id is not None and
628
 
            base_id != self.base_tree.get_root_id()):
 
626
            base_id != self.base_tree.inventory.root.file_id):
629
627
            patch_original = self.base_tree.get_file(base_id)
630
628
        else:
631
629
            patch_original = None
632
630
        file_patch = self.patches.get(self.id2path(file_id))
633
631
        if file_patch is None:
634
632
            if (patch_original is None and
635
 
                self.kind(file_id) == 'directory'):
 
633
                self.get_kind(file_id) == 'directory'):
636
634
                return StringIO()
637
635
            if patch_original is None:
638
636
                raise AssertionError("None: %s" % file_id)
651
649
        except KeyError:
652
650
            return self.base_tree.get_symlink_target(file_id)
653
651
 
654
 
    def kind(self, file_id):
 
652
    def get_kind(self, file_id):
655
653
        if file_id in self._kinds:
656
654
            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)
 
655
        return self.base_tree.inventory[file_id].kind
665
656
 
666
657
    def is_executable(self, file_id):
667
658
        path = self.id2path(file_id)
668
659
        if path in self._executable:
669
660
            return self._executable[path]
670
661
        else:
671
 
            return self.base_tree.is_executable(file_id)
 
662
            return self.base_tree.inventory[file_id].executable
672
663
 
673
664
    def get_last_changed(self, file_id):
674
665
        path = self.id2path(file_id)
714
705
                parent_path = dirname(path)
715
706
                parent_id = self.path2id(parent_path)
716
707
 
717
 
            kind = self.kind(file_id)
 
708
            kind = self.get_kind(file_id)
718
709
            revision_id = self.get_last_changed(file_id)
719
710
 
720
711
            name = basename(path)