/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_blackbox.py

More work on roundtrip push support.

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
 
17
17
"""Black-box tests for bzr-git."""
18
18
 
 
19
from dulwich.repo import (
 
20
    Repo as GitRepo,
 
21
    )
 
22
 
19
23
import os
20
24
 
21
 
from bzrlib.tests import KnownFailure
 
25
from bzrlib.bzrdir import (
 
26
    BzrDir,
 
27
    )
 
28
 
22
29
from bzrlib.tests.blackbox import ExternalBase
23
30
 
24
31
from bzrlib.plugins.git import (
30
37
 
31
38
    def simple_commit(self):
32
39
        # Create a git repository with a revision.
33
 
        tests.run_git('init')
 
40
        repo = GitRepo.init(self.test_dir)
34
41
        builder = tests.GitBranchBuilder()
35
42
        builder.set_file('a', 'text for a\n', False)
36
 
        builder.commit('Joe Foo <joe@foo.com>', u'<The commit message>')
37
 
        builder.finish()
 
43
        r1 = builder.commit('Joe Foo <joe@foo.com>', u'<The commit message>')
 
44
        return repo, builder.finish()[r1]
38
45
 
39
46
    def test_nick(self):
40
 
        tests.run_git('init')
 
47
        GitRepo.init(self.test_dir)
 
48
        dir = BzrDir.open(self.test_dir)
 
49
        dir.create_branch()
41
50
        output, error = self.run_bzr(['nick'])
42
51
        self.assertEquals("HEAD\n", output)
43
52
 
45
54
        self.simple_commit()
46
55
        output, error = self.run_bzr(['info'])
47
56
        self.assertEqual(error, '')
48
 
        self.assertTrue("Repository branch (format: git)" in output)
 
57
        self.assertTrue("Standalone tree (format: git)" in output)
49
58
 
50
59
    def test_branch(self):
51
60
        os.mkdir("gitbranch")
52
 
        os.chdir("gitbranch")
53
 
        tests.run_git('init')
 
61
        GitRepo.init(os.path.join(self.test_dir, "gitbranch"))
 
62
        os.chdir('gitbranch')
54
63
        builder = tests.GitBranchBuilder()
55
64
        builder.set_file('a', 'text for a\n', False)
56
65
        builder.commit('Joe Foo <joe@foo.com>', u'<The commit message>')
57
66
        builder.finish()
 
67
        os.chdir('..')
58
68
 
59
 
        os.chdir("..")
60
69
        output, error = self.run_bzr(['branch', 'gitbranch', 'bzrbranch'])
61
70
        self.assertEqual(error, 'Branched 1 revision(s).\n')
62
71
 
74
83
 
75
84
        output, error = self.run_bzr(['info', '-v'])
76
85
        self.assertEqual(error, '')
77
 
        self.assertTrue("Repository branch (format: git)" in output)
 
86
        self.assertTrue("Standalone tree (format: git)" in output)
78
87
        self.assertTrue("control: Local Git Repository" in output)
79
88
        self.assertTrue("branch: Git Branch" in output)
80
89
        self.assertTrue("repository: Git Repository" in output)
81
90
 
82
91
    def test_push(self):
83
92
        os.mkdir("bla")
84
 
        os.chdir("bla")
85
 
        tests.run_git("init")
86
 
        os.chdir("..")
 
93
        GitRepo.init(os.path.join(self.test_dir, "bla"))
87
94
        self.run_bzr(['init', 'foo'])
88
95
        self.run_bzr(['commit', '--unchanged', '-m', 'bla', 'foo'])
89
 
        output, error = self.run_bzr(['push', '-d', 'foo', 'bla'], retcode=3)
90
 
        self.assertEquals('bzr: ERROR: Push is not yet supported for bzr-git. Try dpush instead.\n', error)
 
96
        output, error = self.run_bzr(['push', '-d', 'foo', 'bla'])
91
97
        self.assertEquals("", output)
 
98
        self.assertTrue(error.endswith("Created new branch.\n"))
92
99
 
93
100
    def test_log(self):
94
101
        # Smoke test for "bzr log" in a git repository.
109
116
        output, error = self.run_bzr(['log', '-v'])
110
117
 
111
118
    def test_tags(self):
112
 
        self.simple_commit()
113
 
 
114
 
        tests.run_git("tag", "foo")
 
119
        git_repo, commit_sha1 = self.simple_commit()
 
120
        git_repo.refs["refs/tags/foo"] = commit_sha1
115
121
 
116
122
        output, error = self.run_bzr(['tags'])
117
123
        self.assertEquals(error, '')
128
134
    def test_init_repo(self):
129
135
        output, error = self.run_bzr(["init-repo", "--git", "bla.git"])
130
136
        self.assertEquals(error, '')
131
 
        self.assertEquals(output, 'Repository branch (format: git)\nLocation:\n  shared repository: bla.git\n  repository branch: bla.git\n')
 
137
        self.assertEquals(output, 'Unshared repository with trees (format: git)\nLocation:\n  repository: bla.git\n')
132
138