/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

Fix unpeel map.

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
 
190
157
    def test_all_revision_ids_none(self):
191
158
        self.assertEquals(set([]), self.git_repo.all_revision_ids())
192
159
 
 
160
    def test_get_known_graph_ancestry(self):
 
161
        cid = self._do_commit()
 
162
        revid = default_mapping.revision_id_foreign_to_bzr(cid)
 
163
        g = self.git_repo.get_known_graph_ancestry([revid])
 
164
        self.assertEquals(frozenset([revid]),
 
165
            g.heads([revision.NULL_REVISION, revid]))
 
166
        self.assertEqual([(revid, 0, (2,), False), (revision.NULL_REVISION, 0, (1,), True)],
 
167
            [(n.key, n.merge_depth, n.revno, n.end_of_merge)
 
168
                 for n in g.merge_sort(revid)])
 
169
 
193
170
    def test_all_revision_ids(self):
194
171
        commit_id = self._do_commit()
195
172
        self.assertEquals(
196
173
                set([default_mapping.revision_id_foreign_to_bzr(commit_id)]),
197
174
                self.git_repo.all_revision_ids())
198
175
 
199
 
    def test_get_ancestry_null(self):
200
 
        self.assertEquals([None, revision.NULL_REVISION], self.git_repo.get_ancestry(revision.NULL_REVISION))
201
 
 
202
176
    def assertIsNullInventory(self, inv):
203
177
        self.assertEqual(inv.root, None)
204
178
        self.assertEqual(inv.revision_id, revision.NULL_REVISION)
205
179
        self.assertEqual(list(inv.iter_entries()), [])
206
180
 
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
181
    def test_revision_tree_none(self):
214
182
        # GitRepository.revision_tree(None) returns the null tree.
215
183
        repo = self.git_repo
216
184
        tree = repo.revision_tree(revision.NULL_REVISION)
217
185
        self.assertEqual(tree.get_revision_id(), revision.NULL_REVISION)
218
 
        self.assertIsNullInventory(tree.inventory)
219
186
 
220
187
    def test_get_parent_map_null(self):
221
188
        self.assertEquals({revision.NULL_REVISION: ()},