57
57
def test_open_existing(self):
60
thebranch = d.create_branch()
60
thebranch = Branch.open('.')
61
61
self.assertIsInstance(thebranch, branch.GitBranch)
63
63
def test_repr(self):
66
thebranch = d.create_branch()
67
self.assertEquals("<LocalGitBranch('file://%s/', 'refs/heads/master')>" % self.test_dir, repr(thebranch))
65
thebranch = Branch.open('.')
66
self.assertEquals("LocalGitBranch('file://%s/', 'HEAD')" % self.test_dir, repr(thebranch))
69
68
def test_last_revision_is_null(self):
71
thedir = BzrDir.open('.')
72
thebranch = thedir.create_branch()
71
thebranch = Branch.open('.')
73
72
self.assertEqual(revision.NULL_REVISION, thebranch.last_revision())
74
73
self.assertEqual((0, revision.NULL_REVISION),
75
74
thebranch.last_revision_info())
83
82
def test_last_revision_is_valid(self):
84
83
self.simple_commit_a()
85
84
head = tests.run_git('rev-parse', 'HEAD').strip()
86
86
thebranch = Branch.open('.')
87
87
self.assertEqual(default_mapping.revision_id_foreign_to_bzr(head),
88
88
thebranch.last_revision())
123
123
tests.TestCaseWithTransport.setUp(self)
124
124
dulwich.repo.Repo.create(self.test_dir)
125
d = BzrDir.open(self.test_dir)
126
self.git_branch = d.create_branch()
125
self.git_branch = Branch.open(self.test_dir)
128
127
def test_get_parent(self):
129
128
self.assertIs(None, self.git_branch.get_parent())
204
203
inter_branch.pull()
205
204
self.assertEquals(revid2, newbranch.last_revision())
207
def test_interbranch_pull_noop(self):
208
path, (gitsha1, gitsha2) = self.make_tworev_branch()
209
oldrepo = Repository.open(path)
210
revid2 = oldrepo.get_mapping().revision_id_foreign_to_bzr(gitsha2)
211
newbranch = self.make_branch('g')
212
inter_branch = InterBranch.get(Branch.open(path), newbranch)
214
# This is basically "assertNotRaises"
216
self.assertEquals(revid2, newbranch.last_revision())
218
def test_interbranch_pull_stop_revision(self):
219
path, (gitsha1, gitsha2) = self.make_tworev_branch()
220
oldrepo = Repository.open(path)
221
revid1 = oldrepo.get_mapping().revision_id_foreign_to_bzr(gitsha1)
222
newbranch = self.make_branch('g')
223
inter_branch = InterBranch.get(Branch.open(path), newbranch)
224
inter_branch.pull(stop_revision=revid1)
225
self.assertEquals(revid1, newbranch.last_revision())
227
206
def test_interbranch_limited_pull(self):
228
207
path, (gitsha1, gitsha2) = self.make_tworev_branch()
229
208
oldrepo = Repository.open(path)
240
219
class ForeignTestsBranchFactory(object):
242
221
def make_empty_branch(self, transport):
243
d = LocalGitBzrDirFormat().initialize_on_transport(transport)
244
return d.create_branch()
222
return LocalGitBzrDirFormat().initialize_on_transport(transport).open_branch()
246
224
make_branch = make_empty_branch