50
50
class TestGitRepositoryFeatures(tests.TestCaseInTempDir):
51
51
"""Feature tests for GitRepository."""
54
builder = tests.GitBranchBuilder()
55
builder.set_file('a', 'text for a\n', False)
56
commit_handle = builder.commit('Joe Foo <joe@foo.com>', u'message')
57
mapping = builder.finish()
58
return mapping[commit_handle]
53
_test_needs_features = [tests.GitCommandFeature]
60
55
def test_open_existing(self):
61
56
GitRepo.init(self.test_dir)
67
62
GitRepo.init(self.test_dir)
69
64
repo = Repository.open('.')
70
self.assertIsInstance(repo._git, dulwich.repo.BaseRepo)
72
def test_has_revision(self):
73
GitRepo.init(self.test_dir)
74
commit_id = self._do_commit()
75
repo = Repository.open('.')
76
self.assertFalse(repo.has_revision('foobar'))
77
revid = default_mapping.revision_id_foreign_to_bzr(commit_id)
78
self.assertTrue(repo.has_revision(revid))
80
def test_has_revisions(self):
81
GitRepo.init(self.test_dir)
82
commit_id = self._do_commit()
83
repo = Repository.open('.')
84
self.assertEquals(set(), repo.has_revisions(['foobar']))
85
revid = default_mapping.revision_id_foreign_to_bzr(commit_id)
86
self.assertEquals(set([revid]), repo.has_revisions(['foobar', revid]))
65
self.assertIsInstance(repo._git, dulwich.repo.Repo)
88
67
def test_get_revision(self):
89
68
# GitRepository.get_revision gives a Revision object.
91
70
# Create a git repository with a revision.
92
71
GitRepo.init(self.test_dir)
93
commit_id = self._do_commit()
72
builder = tests.GitBranchBuilder()
73
builder.set_file('a', 'text for a\n', False)
74
commit_handle = builder.commit('Joe Foo <joe@foo.com>', u'message')
75
mapping = builder.finish()
76
commit_id = mapping[commit_handle]
95
78
# Get the corresponding Revision object.
96
79
revid = default_mapping.revision_id_foreign_to_bzr(commit_id)
117
100
mapping = builder.finish()
118
101
return mapping[commit_handle]
121
commit_id = self.simple_commit()
122
repo = Repository.open('.')
125
103
def test_revision_tree(self):
126
104
commit_id = self.simple_commit()
127
105
revid = default_mapping.revision_id_foreign_to_bzr(commit_id)
166
144
class TestGitRepository(tests.TestCaseWithTransport):
168
def _do_commit(self):
169
builder = tests.GitBranchBuilder()
170
builder.set_file('a', 'text for a\n', False)
171
commit_handle = builder.commit('Joe Foo <joe@foo.com>', u'message')
172
mapping = builder.finish()
173
return mapping[commit_handle]
176
147
tests.TestCaseWithTransport.setUp(self)
177
148
dulwich.repo.Repo.create(self.test_dir)
190
161
def test_all_revision_ids_none(self):
191
162
self.assertEquals(set([]), self.git_repo.all_revision_ids())
193
def test_all_revision_ids(self):
194
commit_id = self._do_commit()
196
set([default_mapping.revision_id_foreign_to_bzr(commit_id)]),
197
self.git_repo.all_revision_ids())
199
164
def test_get_ancestry_null(self):
200
165
self.assertEquals([None, revision.NULL_REVISION], self.git_repo.get_ancestry(revision.NULL_REVISION))
255
220
store, store_iter = self.object_iter()
256
221
store._cache.idmap.start_write_group()
258
return store_iter.import_revision(revid, roundtrip=False)
223
return store_iter.import_revision(revid)
260
225
store._cache.idmap.abort_write_group()
275
240
class ForeignTestsRepositoryFactory(object):
277
242
def make_repository(self, transport):
278
return dir.LocalGitControlDirFormat().initialize_on_transport(transport).open_repository()
243
return dir.LocalGitBzrDirFormat().initialize_on_transport(transport).open_repository()