27
27
from bzrlib.plugins.git import tests
28
28
from bzrlib.plugins.git import (
35
class TestGitRepository(tests.TestCaseInTempDir):
36
class TestGitRepositoryFeatures(tests.TestCaseInTempDir):
36
37
"""Feature tests for GitRepository."""
38
39
_test_needs_features = [tests.GitCommandFeature]
145
146
" u'subfile', parent_id='subdir',"
146
147
" sha1='0ddb53cbe2dd209f550dd8d7f1287a5ed9b1ee8b', len=None))")
150
class MemoryGitRepository(git_repository.GitRepository):
151
"""A git repository without real git data on disk."""
154
def _make_model(klass, transport):
158
class MemoryGitDir(git_dir.GitDir):
159
"""A git tree with real data on disk."""
161
_gitrepository_class = MemoryGitRepository
164
class MemoryGitBzrDirFormat(git_dir.GitBzrDirFormat):
165
"""Format for a git tree without real data on disk."""
167
_gitdir_class = MemoryGitDir
170
class TestGitRepository(tests.TestCaseWithMemoryTransport):
173
tests.TestCaseWithMemoryTransport.setUp(self)
174
self.transport = self.get_transport()
175
self.transport.mkdir('.git')
176
self.git_dir = MemoryGitBzrDirFormat().open(self.transport)
177
self.git_repo = self.git_dir.open_repository()
148
179
def test_supports_rich_root(self):
149
180
# GitRepository.supports_rich_root is False, at least for now.
150
tests.run_git('init')
151
repo = repository.Repository.open('.')
152
182
self.assertEqual(repo.supports_rich_root(), False)
184
def assertIsNullInventory(self, inv):
185
self.assertEqual(inv.root, None)
186
self.assertEqual(inv.revision_id, revision.NULL_REVISION)
187
self.assertEqual(list(inv.iter_entries()), [])
189
def test_get_inventory_none(self):
190
# GitRepository.get_inventory(None) returns the null inventory.
192
inv = repo.get_inventory(None)
193
self.assertIsNullInventory(inv)
195
def test_revision_tree_none(self):
196
# GitRepository.revision_tree(None) returns the null tree.
198
tree = repo.revision_tree(None)
199
self.assertEqual(tree.get_revision_id(), revision.NULL_REVISION)
200
self.assertIsNullInventory(tree.inventory)
155
203
class TestGitRepositoryParseRev(tests.TestCase):
156
204
"""Unit tests for GitRepository._parse_rev."""