34
35
def test_open_existing(self):
35
36
tests.run_git('init')
37
thebranch = branch.Branch.open('.')
38
self.assertIsInstance(thebranch, git_branch.GitBranch)
38
thebranch = Branch.open('.')
39
self.assertIsInstance(thebranch, branch.GitBranch)
40
41
def test_last_revision_is_null(self):
41
42
tests.run_git('init')
43
thebranch = branch.Branch.open('.')
44
thebranch = Branch.open('.')
44
45
self.assertEqual(revision.NULL_REVISION, thebranch.last_revision())
45
46
self.assertEqual((0, revision.NULL_REVISION),
46
47
thebranch.last_revision_info())
48
def test_last_revision_is_valid(self):
49
def simple_commit_a(self):
49
50
tests.run_git('init')
50
51
self.build_tree(['a'])
51
52
tests.run_git('add', 'a')
52
53
tests.run_git('commit', '-m', 'a')
55
def test_last_revision_is_valid(self):
56
self.simple_commit_a()
53
57
head = tests.run_git('rev-parse', 'HEAD').strip()
55
thebranch = branch.Branch.open('.')
56
self.assertEqual(ids.convert_revision_id_git_to_bzr(head),
59
thebranch = Branch.open('.')
60
self.assertEqual(default_mapping.revision_id_foreign_to_bzr(head),
57
61
thebranch.last_revision())
63
def test_revision_history(self):
64
self.simple_commit_a()
65
reva = tests.run_git('rev-parse', 'HEAD').strip()
66
self.build_tree(['b'])
67
tests.run_git('add', 'b')
68
tests.run_git('commit', '-m', 'b')
69
revb = tests.run_git('rev-parse', 'HEAD').strip()
71
thebranch = Branch.open('.')
72
self.assertEqual([default_mapping.revision_id_foreign_to_bzr(r) for r in (reva, revb)],
73
thebranch.revision_history())
76
self.simple_commit_a()
77
reva = tests.run_git('rev-parse', 'HEAD').strip()
79
tests.run_git('tag', '-a', '-m', 'add tag', 'foo')
81
thebranch = Branch.open('.')
82
self.assertEquals({"foo": default_mapping.revision_id_foreign_to_bzr(reva)},
83
thebranch.tags.get_tag_dict())
86
class TestWithGitBranch(tests.TestCaseWithTransport):
89
tests.TestCaseWithTransport.setUp(self)
90
git.repo.Repo.create(self.test_dir)
91
self.git_branch = Branch.open(self.test_dir)
93
def test_get_parent(self):
94
self.assertIs(None, self.git_branch.get_parent())
96
def test_get_stacked_on_url(self):
97
self.assertIs(None, self.git_branch.get_stacked_on_url())
99
def test_get_physical_lock_status(self):
100
self.assertFalse(self.git_branch.get_physical_lock_status())
103
class TestGitBranchFormat(tests.TestCase):
106
super(TestGitBranchFormat, self).setUp()
107
self.format = branch.GitBranchFormat()
109
def test_get_format_description(self):
110
self.assertEquals("Git Branch", self.format.get_format_description())