/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

Merge in dulwich.

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
 
17
17
"""Tests for interfacing with a Git Repository"""
18
18
 
19
 
import dulwich as git
20
 
import os
 
19
import git
21
20
 
22
21
from bzrlib import (
23
22
    errors,
24
23
    inventory,
25
24
    revision,
26
25
    )
27
 
from bzrlib.repository import (
28
 
    Repository,
29
 
    )
 
26
from bzrlib.repository import Repository
30
27
 
31
28
from bzrlib.plugins.git import (
32
29
    dir,
33
30
    repository,
34
31
    tests,
35
32
    )
36
 
from bzrlib.plugins.git.mapping import (
37
 
    default_mapping,
38
 
    )
 
33
from bzrlib.plugins.git.mapping import default_mapping
 
34
 
39
35
 
40
36
class TestGitRepositoryFeatures(tests.TestCaseInTempDir):
41
37
    """Feature tests for GitRepository."""
115
111
        self.assertEqualDiff(
116
112
            printed_inv,
117
113
            "('', False, InventoryDirectory('TREE_ROOT', u'', parent_id=None,"
118
 
            " revision='"+default_mapping.revision_id_foreign_to_bzr("69c39cfa65962f3cf16b9b3eb08a15954e9d8590")+"'))\n"
 
114
            " revision='git-experimental:69c39cfa65962f3cf16b9b3eb08a15954e9d8590'))\n"
119
115
            "(u'data', False, InventoryFile('data', u'data',"
120
116
            " parent_id='TREE_ROOT',"
121
117
            " sha1='aa785adca3fcdfe1884ae840e13c6d294a2414e8', len=5))\n"
123
119
            " parent_id='TREE_ROOT',"
124
120
            " sha1='040f06fd774092478d450774f5ba30c5da78acc8', len=7))\n"
125
121
            "(u'link', False, InventoryLink('link', u'link',"
126
 
            " parent_id='TREE_ROOT', revision='"+default_mapping.revision_id_foreign_to_bzr("69c39cfa65962f3cf16b9b3eb08a15954e9d8590")+"'))\n"
 
122
            " parent_id='TREE_ROOT', revision='git-experimental:69c39cfa65962f3cf16b9b3eb08a15954e9d8590'))\n"
127
123
            "(u'subdir', False, InventoryDirectory('subdir', u'subdir',"
128
 
            " parent_id='TREE_ROOT', revision='"+default_mapping.revision_id_foreign_to_bzr("69c39cfa65962f3cf16b9b3eb08a15954e9d8590")+"'))\n"
 
124
            " parent_id='TREE_ROOT', revision='git-experimental:69c39cfa65962f3cf16b9b3eb08a15954e9d8590'))\n"
129
125
            "(u'subdir/subfile', False, InventoryFile('subdir/subfile',"
130
126
            " u'subfile', parent_id='subdir',"
131
127
            " sha1='67b75c3e49f31fcadddbf9df6a1d8be8c3e44290', len=12))")
139
135
        self.git_repo = Repository.open(self.test_dir)
140
136
 
141
137
    def test_supports_rich_root(self):
 
138
        # GitRepository.supports_rich_root is False, at least for now.
142
139
        repo = self.git_repo
143
 
        self.assertEqual(repo.supports_rich_root(), True)
 
140
        self.assertEqual(repo.supports_rich_root(), False)
144
141
 
145
142
    def test_get_signature_text(self):
146
143
        self.assertRaises(errors.NoSuchRevision, self.git_repo.get_signature_text, revision.NULL_REVISION)
149
146
        self.assertEquals(False, self.git_repo.has_signature_for_revision_id(revision.NULL_REVISION))
150
147
 
151
148
    def test_all_revision_ids_none(self):
152
 
        self.assertEquals(set([revision.NULL_REVISION]), self.git_repo.all_revision_ids())
 
149
        self.assertEquals(set(), self.git_repo.all_revision_ids())
153
150
 
154
151
    def test_get_ancestry_null(self):
155
 
        self.assertEquals([None, revision.NULL_REVISION], self.git_repo.get_ancestry(revision.NULL_REVISION))
 
152
        self.assertEquals([None], self.git_repo.get_ancestry(revision.NULL_REVISION))
156
153
 
157
154
    def assertIsNullInventory(self, inv):
158
155
        self.assertEqual(inv.root, None)
185
182
 
186
183
    def test_get_format_description(self):
187
184
        self.assertEquals("Git Repository", self.format.get_format_description())
188
 
 
189
 
 
190
 
class RevisionGistImportTests(tests.TestCaseWithTransport):
191
 
 
192
 
    def setUp(self):
193
 
        tests.TestCaseWithTransport.setUp(self)
194
 
        self.git_path = os.path.join(self.test_dir, "git")
195
 
        os.mkdir(self.git_path)
196
 
        git.repo.Repo.create(self.git_path)
197
 
        self.git_repo = Repository.open(self.git_path)
198
 
        self.bzr_tree = self.make_branch_and_tree("bzr")
199
 
 
200
 
    def import_rev(self, revid, parent_lookup=None):
201
 
        return self.git_repo.import_revision_gist(
202
 
            self.bzr_tree.branch.repository, revid, parent_lookup)
203
 
 
204
 
    def test_pointless(self):
205
 
        revid = self.bzr_tree.commit("pointless", timestamp=1205433193,
206
 
                  committer="Jelmer Vernooij <jelmer@samba.org>")
207
 
        self.assertEquals("2caa8094a5b794961cd9bf582e3e2bb090db0b14", 
208
 
                self.import_rev(revid))
209
 
        self.assertEquals("2caa8094a5b794961cd9bf582e3e2bb090db0b14", 
210
 
                self.import_rev(revid))