/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to tests/test_repository.py

Implement GitRevisionTree.get_file_sha1.

Show diffs side-by-side

added added

removed removed

Lines of Context:
24
24
 
25
25
from bzrlib import (
26
26
    errors,
27
 
    inventory,
28
27
    revision,
29
28
    )
30
29
from bzrlib.repository import (
130
129
        self.assertEquals(tree.get_revision_id(), revid)
131
130
        self.assertEquals("text\n", tree.get_file_text(tree.path2id("data")))
132
131
 
133
 
    def test_get_inventory(self):
134
 
        # GitRepository.get_inventory gives a GitInventory object with
135
 
        # plausible entries for typical cases.
136
 
 
137
 
        commit_id = self.simple_commit()
138
 
 
139
 
        # Get the corresponding Inventory object.
140
 
        revid = default_mapping.revision_id_foreign_to_bzr(commit_id)
141
 
        repo = Repository.open('.')
142
 
        inv = repo.get_inventory(revid)
143
 
        self.assertIsInstance(inv, inventory.Inventory)
144
 
        printed_inv = '\n'.join(
145
 
            repr((path, entry.executable, entry))
146
 
            for path, entry in inv.iter_entries())
147
 
        self.assertEqualDiff(
148
 
            printed_inv,
149
 
            "('', False, GitInventoryDirectory('TREE_ROOT', u'', parent_id=None,"
150
 
            " revision='"+default_mapping.revision_id_foreign_to_bzr("69c39cfa65962f3cf16b9b3eb08a15954e9d8590")+"'))\n"
151
 
            "(u'data', False, GitInventoryFile('data', u'data',"
152
 
            " parent_id='TREE_ROOT',"
153
 
            " sha1='aa785adca3fcdfe1884ae840e13c6d294a2414e8', len=5, revision="+default_mapping.revid_prefix+":69c39cfa65962f3cf16b9b3eb08a15954e9d8590))\n"
154
 
            "(u'executable', True, GitInventoryFile('executable', u'executable',"
155
 
            " parent_id='TREE_ROOT',"
156
 
            " sha1='040f06fd774092478d450774f5ba30c5da78acc8', len=7, revision="+default_mapping.revid_prefix+":69c39cfa65962f3cf16b9b3eb08a15954e9d8590))\n"
157
 
            "(u'link', False, GitInventoryLink('link', u'link',"
158
 
            " parent_id='TREE_ROOT', revision='"+default_mapping.revision_id_foreign_to_bzr("69c39cfa65962f3cf16b9b3eb08a15954e9d8590")+"'))\n"
159
 
            "(u'subdir', False, GitInventoryDirectory('subdir', u'subdir',"
160
 
            " parent_id='TREE_ROOT', revision='"+default_mapping.revision_id_foreign_to_bzr("69c39cfa65962f3cf16b9b3eb08a15954e9d8590")+"'))\n"
161
 
            "(u'subdir/subfile', False, GitInventoryFile('subdir/subfile',"
162
 
            " u'subfile', parent_id='subdir',"
163
 
            " sha1='67b75c3e49f31fcadddbf9df6a1d8be8c3e44290', len=12, revision="+default_mapping.revid_prefix+":69c39cfa65962f3cf16b9b3eb08a15954e9d8590))")
164
 
 
165
132
 
166
133
class TestGitRepository(tests.TestCaseWithTransport):
167
134
 
197
164
                self.git_repo.all_revision_ids())
198
165
 
199
166
    def test_get_ancestry_null(self):
200
 
        self.assertEquals([None, revision.NULL_REVISION], self.git_repo.get_ancestry(revision.NULL_REVISION))
 
167
        self.assertEquals([None], self.git_repo.get_ancestry(revision.NULL_REVISION))
201
168
 
202
169
    def assertIsNullInventory(self, inv):
203
170
        self.assertEqual(inv.root, None)
204
171
        self.assertEqual(inv.revision_id, revision.NULL_REVISION)
205
172
        self.assertEqual(list(inv.iter_entries()), [])
206
173
 
207
 
    def test_get_inventory_none(self):
208
 
        # GitRepository.get_inventory(None) returns the null inventory.
209
 
        repo = self.git_repo
210
 
        inv = repo.get_inventory(revision.NULL_REVISION)
211
 
        self.assertIsNullInventory(inv)
212
 
 
213
174
    def test_revision_tree_none(self):
214
175
        # GitRepository.revision_tree(None) returns the null tree.
215
176
        repo = self.git_repo
216
177
        tree = repo.revision_tree(revision.NULL_REVISION)
217
178
        self.assertEqual(tree.get_revision_id(), revision.NULL_REVISION)
218
 
        self.assertIsNullInventory(tree.inventory)
219
179
 
220
180
    def test_get_parent_map_null(self):
221
181
        self.assertEquals({revision.NULL_REVISION: ()},