~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_bundle.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:
75
75
        self.root = InventoryDirectory(ROOT_ID, '', None)
76
76
 
77
77
    inventory = property(lambda x:x)
 
78
    root_inventory = property(lambda x:x)
 
79
 
 
80
    def get_root_id(self):
 
81
        return self.root.file_id
 
82
 
 
83
    def get_root_id(self):
 
84
        return self.root.file_id
78
85
 
79
86
    def all_file_ids(self):
80
87
        return set(self.paths.keys())
81
88
 
 
89
    def is_executable(self, file_id):
 
90
        # Not all the files are executable.
 
91
        return False
 
92
 
82
93
    def __getitem__(self, file_id):
83
94
        if file_id == self.root.file_id:
84
95
            return self.root
95
106
        for path, file_id in self.ids.iteritems():
96
107
            yield path, self[file_id]
97
108
 
98
 
    def get_file_kind(self, file_id):
 
109
    def kind(self, file_id):
99
110
        if file_id in self.contents:
100
111
            kind = 'file'
101
112
        else:
106
117
        from bzrlib.inventory import (InventoryEntry, InventoryFile
107
118
                                    , InventoryDirectory, InventoryLink)
108
119
        name = os.path.basename(path)
109
 
        kind = self.get_file_kind(file_id)
 
120
        kind = self.kind(file_id)
110
121
        parent_id = self.parent_id(file_id)
111
122
        text_sha_1, text_size = self.contents_stats(file_id)
112
123
        if kind == 'directory':
649
660
        bundle = self.get_valid_bundle('null:', 'a@cset-0-4')
650
661
 
651
662
        # Modified files
652
 
        open('b1/sub/dir/WithCaps.txt', 'ab').write('\nAdding some text\n')
653
 
        open('b1/sub/dir/ pre space', 'ab').write(
 
663
        with open('b1/sub/dir/WithCaps.txt', 'ab') as f: f.write('\nAdding some text\n')
 
664
        with open('b1/sub/dir/ pre space', 'ab') as f: f.write(
654
665
             '\r\nAdding some\r\nDOS format lines\r\n')
655
 
        open('b1/sub/dir/nolastnewline.txt', 'ab').write('\n')
 
666
        with open('b1/sub/dir/nolastnewline.txt', 'ab') as f: f.write('\n')
656
667
        self.tree1.rename_one('sub/dir/ pre space',
657
668
                              'sub/ start space')
658
669
        self.tree1.commit('Modified files', rev_id='a@cset-0-5')
807
818
        self.tree1 = self.make_branch_and_tree('b1')
808
819
        self.b1 = self.tree1.branch
809
820
 
810
 
        open('b1/one', 'wb').write('one\n')
 
821
        with open('b1/one', 'wb') as f: f.write('one\n')
811
822
        self.tree1.add('one')
812
823
        self.tree1.commit('add file', rev_id='a@cset-0-1')
813
 
        open('b1/one', 'wb').write('two\n')
 
824
        with open('b1/one', 'wb') as f: f.write('two\n')
814
825
        self.tree1.commit('modify', rev_id='a@cset-0-2')
815
 
        open('b1/one', 'wb').write('three\n')
 
826
        with open('b1/one', 'wb') as f: f.write('three\n')
816
827
        self.tree1.commit('modify', rev_id='a@cset-0-3')
817
828
        bundle_file = StringIO()
818
829
        rev_ids = write_bundle(self.tree1.branch.repository, 'a@cset-0-3',
897
908
        bundle = self.get_valid_bundle('null:', 'white-1')
898
909
 
899
910
        # Modified
900
 
        open('b1/trailing space ', 'ab').write('add some text\n')
 
911
        with open('b1/trailing space ', 'ab') as f: f.write('add some text\n')
901
912
        self.tree1.commit('add text', rev_id='white-2')
902
913
 
903
914
        bundle = self.get_valid_bundle('white-1', 'white-2')
945
956
        self.tree1.commit('message', rev_id='revid1')
946
957
        bundle = self.get_valid_bundle('null:', 'revid1')
947
958
        tree = self.get_bundle_tree(bundle, 'revid1')
948
 
        self.assertEqual('revid1', tree.inventory.root.revision)
 
959
        root_revision = tree.get_file_revision(tree.get_root_id())
 
960
        self.assertEqual('revid1', root_revision)
949
961
 
950
962
    def test_install_revisions(self):
951
963
        self.tree1 = self.make_branch_and_tree('b1')